Example #1
0
def test_ospf_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for OSPF'''

    if 'basic_dual_bgp' in datadir:
        # No OSPF in this datadir
        return

    df = get_table_data

    ns_dict = {'eos': 8, 'junos': 6, 'nxos': 8, 'ospf-ibgp': 8, 'mixed': 8}

    if datadir.endswith(('vmx/parquet-out')):
        # mixed dataset has no evpn
        assert (True)
        return

    validate_host_shape(df, ns_dict)
    # These apply to all sessions
    _validate_common_ospf_data(df)

    estd_df = df.query('adjState.isin(["full", "passive"])').reset_index()
    notestd_df = df.query(
        'not adjState.isin(["full", "passive"])').reset_index()

    _validate_notestd_ospf_data(notestd_df)
    _validate_estd_ospf_data(estd_df)
Example #2
0
def test_routes_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for Routes'''

    df = get_table_data

    ns_dict = {
        'eos': 14,
        'junos': 12,
        'nxos': 14,
        'ospf-ibgp': 14,
        'vmx': 5,
    }

    assert not df.empty
    validate_host_shape(df, ns_dict)
    validate_routes(df)
Example #3
0
def test_lldp_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for LLDP table'''

    df = get_table_data

    ns_dict = {
        'eos': 9,
        'junos': 7,
        'nxos': 9,
        'ospf-ibgp': 10,
        'vmx': 5,
    }

    assert not df.empty
    validate_host_shape(df, ns_dict)
    validate_lldp_tbl(df)
Example #4
0
def test_mlag_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for MLAG table'''

    df = get_table_data

    ns_dict = {
        'eos': 4,
        'junos': 4,
        'nxos': 4,
        'ospf-ibgp': 4,
    }

    if datadir.endswith(('mixed/parquet-out', 'vmx/parquet-out')):
        assert (True)
        return
    assert not df.empty
    validate_host_shape(df, ns_dict)
    validate_mlag_tbl(df)
Example #5
0
def test_macs_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for MAC table'''

    df = get_table_data

    ns_dict = {
        'eos': 11,
        'junos': 7,
        'nxos': 13,
        'ospf-ibgp': 7,
        'mixed': 2,
    }

    if datadir.endswith(('vmx/parquet-out')):
        # mixed dataset has no evpn
        assert (True)
        return

    assert not df.empty
    validate_host_shape(df, ns_dict)
    validate_macs(df)
Example #6
0
def test_bgp_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for BGP'''

    df = get_table_data

    ns_dict = {
        'eos': 10,
        'junos': 8,
        'nxos': 10,
        'ospf-ibgp': 10,
        'mixed': 0,
        'vmx': 3,
    }

    if datadir.endswith('mixed/parquet-out'):
        # mixed dataset has no BGP
        assert (True)
        return

    assert not df.empty
    validate_host_shape(df, ns_dict)
    validate_bgp_data(df)
Example #7
0
def test_evpnVni_parsing(table, datadir, get_table_data):
    '''Main workhorse routine to test parsed output for EVPN VNI table'''

    if 'basic_dual_bgp' in datadir:
        # No EVPN info in this one
        return

    df = get_table_data

    ns_dict = {
        'eos': 6,
        'junos': 4,
        'nxos': 6,
        'ospf-ibgp': 6,
    }

    if datadir.endswith(('mixed/parquet-out', 'vmx/parquet-out')):
        # mixed dataset has no evpn
        assert (True)
        return
    assert not df.empty
    validate_host_shape(df, ns_dict)
    validate_evpnVni(df)
def test_interfaces(table, datadir, get_table_data):
    '''Main workhorse routine to test interfaces'''

    df = get_table_data

    validation_fns = {'adaptive-services': None,
                      'bond': _validate_bond_if,
                      'bond_slave': _validate_bond_if,
                      'bridge': None,
                      'ethernet': _validate_ethernet_if,
                      'ethernet-ccc': _validate_ethernet_if,
                      'flexible-ethernet': None,
                      'flexible-tunnel-interface': None,
                      'gre': _validate_gre_if,
                      'igbe': None,
                      'internal': None,
                      'ip-over-ip': None,
                      'linkservice': None,
                      'logical': None,
                      'logical-tunnel': None,
                      'loopback': _validate_loopback_if,
                      'lsi': None,
                      'macvlan': None,
                      'mgmt-vlan': None,
                      'null': _validate_null_if,
                      'pim-decapsulator': None,
                      'pim-encapsulator': None,
                      'pppoe': None,
                      'remote-beb': None,
                      'secure-tunnel': None,
                      'software-pseudo': None,
                      'subinterface': None,
                      'tap': None,
                      'tunnel': None,
                      'tunnel-te': _validate_tunnel_te_if,
                      'virtual': None,
                      'vlan': _validate_svi_and_subif,
                      'vlan-l2': None,
                      'vpls': None,
                      'vtep': _validate_junos_vtep_if,
                      'vxlan': _validate_vxlan_if,
                      'vrf': _validate_vrf_if
                      }

    ns_dict = {
        'eos': 14,
        'junos': 12,
        'nxos': 14,
        'ospf-ibgp': 14,
        'mixed': 8,
        'vmx': 5,
    }

    assert not df.empty
    validate_host_shape(df, ns_dict)

    assert df.state.isin(['up', 'down', 'notPresent', 'notConnected',
                          'errDisabled']).all()
    # EOS uses disabled admin state on interfaces that have no XCVR
    assert df.adminState.isin(['up', 'down', 'disabled']).all()

    assert (df.type != "").all()
    assert df.type.isin(validation_fns.keys()).all()

    for iftype, fn in validation_fns.items():
        if fn:
            subdf = df.query(f'type == "{iftype}"').reset_index(drop=True)
            subdf_without_junos = subdf.query(
                'os.str.match("^(?:(?!junos).)*$")')
            if not subdf.empty:
                # validate interface speed without Juniper
                validate_speed_if(subdf_without_junos)
                fn(subdf, df)

                assert (subdf.macaddr.str.len() == 17).all()
                assert (subdf.macaddr.str.contains(':')).all()
        assert (df.query('state != "notConnected" and type != "vpls"')
                .mtu != 0).all()

    # Juniper interfaces speed must be tested with specific function
    _validate_junos_speed_if(df.query('os.str.match("junos.*")'))