Ejemplo n.º 1
0
def test_ospf_on_startup(topology, configuration, step):
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None

    step('###### Step 1 - Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw2, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW2 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW2 and SW1(router-id = %s)" % SW1_ROUTER_ID

    retval = wait_for_adjacency(sw3, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between "
        "SW3 and SW1(router-id = %s)" % SW1_ROUTER_ID

    step('######Step 2 - Configuring sw1(DUT) as stub router '
         'using max-metric router-lsa on-startup ######')
    with sw1.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.max_metric_router_lsa_on_startup('10')

    step('#### Step 3 - Verifying whether not directly connected route is '
         'removed ####')
    retval = verify_route(sw2, '10.10.20.0', '24')
    if retval is True:
        sw2('show rib'.format(**locals()), shell='vtysh')
        assert False, "Failed to remove OSPF route 10.10.20.0"
    else:
        step('###### OSPF routes 10.10.20.0 has been removed ######')

    step('##### Step 4 - Waiting to verify if stub router '
         'has acts as normal router')
    # Wait to check if the router acts as normal router after startup
    time.sleep(10)
    step('##### Step 5 - Verifying whether not directly connected route is '
         'removed')
    retval = verify_route(sw2, '10.10.20.0', '24')
    if retval is True:
        step('#### Routes has been removed ####')
    else:
        sw2('show rib'.format(**locals()), shell='vtysh')
        assert False, "Failed to remove OSPF route 10.10.20.0."
    step('###### TEST CASE [10.02] PASSED ######')
Ejemplo n.º 2
0
def test_ospf_redistribute_connected_routes(topology, configuration, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert hs1 is not None
    assert hs2 is not None

    step('######Step 1 -  Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw1, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW1 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw1(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW1 and SW2(router-id = %s)" % SW2_ROUTER_ID

    step('######Step 2 - Redistibuting connected routes in sw1######')
    with sw1.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.redistribute_connected()

    # Waiting for connected route to get updated in show rib command
    time.sleep(10)
    step('######step 3 - Verifying the sw1 advertised routes in sw2 ######')
    retval = verify_route(sw2, '10.10.40.0', '24')
    if retval is True:
        step('sw1 connected routes successfully advertised to sw2')
    else:
        sw2('show rib'.format(**locals()), shell='vtysh')
        assert False, "sw1 connected routes not advertised to sw2"

    step('###### Step 4 - Disabling redistibution of connected '
         'route in sw1 ######')
    with sw1.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.no_redistribute_connected()

    step('########### TEST CASE [4.02] PASSED ###########')
Ejemplo n.º 3
0
def test_ospf_redistribute_default_routes(topology, configuration, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert hs1 is not None
    assert hs2 is not None

    step('######Step 1 -  Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw1, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW1 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw1(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW1 and SW2(router-id = %s)" % SW2_ROUTER_ID

    step('######Step 2 - Configuring default routes in sw1 ######')
    with sw1.libs.vtysh.Configure() as ctx:
        ctx.ip_route('0.0.0.0/0', '1')

    step('######Step 3 - Redistibuting default routes in sw1 ######')
    with sw1.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.default_information_originate_always()

    # Waiting for default route to get updated in show rib command
    time.sleep(10)
    step('######step 4 - Verifying the sw1 default routes in sw2 ######')
    retval = verify_route(sw2, '0.0.0.0', '0')
    if retval is True:
        step('sw2 connected routes advertised to sw1')
    else:
        sw2('show rib'.format(**locals()), shell='vtysh')
        assert False, "sw2 connected routes not advertised to sw1"

    step('########### TEST CASE [4.04] PASSED ###########')
Ejemplo n.º 4
0
def test_ospf_network_betwn_areas(topology, configuration, step):
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    sw4 = topology.get('sw4')
    sw5 = topology.get('sw5')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert sw4 is not None
    assert sw5 is not None

    step('###### Step 1 - Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw2, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW2 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW2 and SW1(router-id = %s)" % SW1_ROUTER_ID

    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw5, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW5 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw5(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW5 and SW1(router-id = %s)" % SW1_ROUTER_ID

    step('###### Step 2 - Verify if SW2 and SW3 are acting as ABR ######')
    retval = verify_router_type(sw2)
    if(retval == 2):
        step('###### SW2 is ABR ######')
    else:
        cmd = 'show ip ospf'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, 'SW2 failed to become ABR'

    retval = verify_router_type(sw3)
    if(retval == 2):
        step('###### SW3 is ABR ######')
    else:
        cmd = 'show ip ospf'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, 'SW3 failed to become ABR'

    # Waiting time for routes to be updated in sw3
    time.sleep(20)
    step(
        '###### Step 3 - Verifying the connected routes to sw1 '
        'using show rib command ######'
        )
    retval = verify_route(sw3, '10.10.10.0', '24')
    if retval is True:
        step('###### Connected route 10.10.10.0/24 found in sw3 ######')
    else:
        sw3('show rib'.format(**locals()), shell='vtysh')
        assert False, 'Failed to remove connected route 10.10.10.0/24 in sw3'

    retval = verify_route(sw4, '10.10.10.0', '24')
    if retval is True:
        step('###### Connected route 10.10.10.0/24 found in sw4 ######')
    else:
        sw4('show rib'.format(**locals()), shell='vtysh')
        assert False, 'Failed to remove connected route 10.10.10.0/24 in sw4'

    # TODO:
    # Verifying using "show ip ospf database summary"
    # Command is not supported currently
    # step('###### Step 4 - Verifying sw1 learnt routes in sw3 and sw4 #####')

    step('###### Test Case- [6.03]---PASSED ######')
Ejemplo n.º 5
0
def test_ospf_routes_abr(topology, configuration, step):
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    sw4 = topology.get('sw4')
    sw5 = topology.get('sw5')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert sw4 is not None
    assert sw5 is not None

    step('###### Step 1 - Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw2, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW2 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW2 and SW1(router-id = %s)" % SW1_ROUTER_ID

    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw5, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW5 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw5(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW5 and SW1(router-id = %s)" % SW1_ROUTER_ID

    step('###### Step 2 - Verify if SW2 and SW3 are acting as ABR ######')
    retval = verify_router_type(sw2)
    if retval == 2:
        step('###### Switch2 is ABR ######')
    else:
        cmd = 'show ip ospf'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, 'Switch2 not acting as ABR'

    retval = verify_router_type(sw3)
    if retval == 2:
        step('###### Switch3 is ABR ######')
    else:
        cmd = 'show ip ospf'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, 'Switch3 not acting as ABR'

    step('###### Step 3 - Disabling ospf process in switch1 ######')
    with sw1.libs.vtysh.Configure() as ctx:
        ctx.no_router_ospf()

    # Waiting time for routes of sw3 to be updated
    time.sleep(40)
    step(
        '###### Step 4 - Verifying whether connected route 10.10.10.0/24 '
        'is removed from sw3 using show rib command ######'
        )
    retval = verify_route(sw3, '10.10.10.0', '24')
    if retval is True:
        sw3('show rib'.format(**locals()), shell='vtysh')
        assert False, 'Failed to remove connected route from 10.10.10.0/24'
    else:
        step(
            '###### Connected route 10.10.10.0/24 is removed '
            'from sw3 after disabling OSPF in sw1 ######'
            )

    retval = verify_route(sw4, '10.10.10.0', '24')
    if retval is True:
        sw4('show rib'.format(**locals()), shell='vtysh')
        assert False, 'Failed to remove connected route 10.10.10.0 from sw4'
    else:
        step(
            '###### Connected route 10.10.10.0/24 is removed '
            'from sw4 after disabling OSPF in switch1 ######'
            )

    # Enabling OSPF in sw1
    configure_ospf_router(sw1, SW1_ROUTER_ID, SW1_INTF1_IPV4_ADDR,
                          OSPF_AREA_100)
    configure_ospf_router(sw1, SW1_ROUTER_ID, SW1_INTF2_IPV4_ADDR,
                          OSPF_AREA_100)
    step('###### Test Case [6.02] PASSED ######')
Ejemplo n.º 6
0
def test_ospf_abr(topology, configuration, step):
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    sw4 = topology.get('sw4')
    sw5 = topology.get('sw5')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert sw4 is not None
    assert sw5 is not None

    step('###### Step 1 - Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw2, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW2 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW2 and SW1(router-id = %s)" % SW1_ROUTER_ID

    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw5, SW1_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW5 and SW1(router-id = 1.1.1.1)')
    else:
        cmd = 'show ip ospf neighbor'
        sw5(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW5 and SW1(router-id = %s)" % SW1_ROUTER_ID

    step('###### Step 2 - Verify if SW2 and SW3 are acting as  ABR ######')
    retval = verify_router_type(sw2)
    if(retval == 2):
        step('###### Switch2 is ABR ######')
    else:
        cmd = 'show ip ospf neighbor'
        sw2(cmd.format(**locals()), shell='vtysh')
        assert False, 'Switch2 failed to become ABR'

    retval = verify_router_type(sw3)
    if(retval == 2):
        step('###### Switch3 is ABR ######')
    else:
        cmd = 'show ip ospf'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, 'Switch3 failed to become ABR'

    # Waiting time for routes of sw3 to be updated
    time.sleep(20)
    step(
        '###### Step 3 -Verifying connected routes to sw1 '
        'using show rib command ######'
        )
    retval = verify_route(sw3, '10.10.10.0', '24')
    if retval is True:
        step('###### Connected route 10.10.10.0/24 is found in sw3 ######')
    else:
        sw3('show rib'.format(**locals()), shell='vtysh')
        assert False, 'Connected route 10.10.10.0/24 not found in sw3'

    retval = verify_route(sw4, '10.10.10.0', '24')
    if retval is True:
        step('###### Connected route 10.10.10.0/24 is found in sw4  ######')
    else:
        sw4('show rib'.format(**locals()), shell='vtysh')
        assert False, 'Connected route 10.10.10.0/24 failed '
        'to be removed'

    step('###### Test Case [6.01] PASSED ######')
Ejemplo n.º 7
0
def test_ospf_redistribute_bgp_routes(topology, configuration, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert hs1 is not None
    assert hs2 is not None

    step('######Step 1 -  Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw1, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW1 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw1(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW1 and SW2(router-id = %s)" % SW2_ROUTER_ID

    step('###### Step 2 - Disabling OSPF process in sw3 ######')
    with sw3.libs.vtysh.Configure() as ctx:
        ctx.no_router_ospf()

    step('###### Step 3 - Disabling OSPF configuration from '
         'sw2 ---> interface 2 ######')
    unconfigure_ospf_network(sw2, SW2_INTF2_IPV4_ADDR, OSPF_AREA_1)

    step('######Step 4 - Redistibuting BGP routes to sw1######')
    with sw2.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.redistribute_bgp()

    step('######Step 5 - Configuring BGP in sw2 and sw3')
    configure_bgp_network(sw2, ASN_2, SW2_ROUTER_ID, SW2_INTF1_IPV4_ADDR,
                          SW2_NEIGHBOR, ASN_3)

    configure_bgp_network(sw3, ASN_3, SW3_ROUTER_ID, SW3_INTF1_IPV4_ADDR,
                          SW3_NEIGHBOR, ASN_2)

    # Waiting for BGP routes to be updated in show rib command
    time.sleep(20)
    step('###### Verifying the redistributed BGP route '
         'in sw3 from sw1 ######')
    retval = verify_route(sw1, '10.10.30.0', '24')
    if retval is True:
        step('###### Redistributed bgp route present in sw1 ######')
    else:
        sw1('show rib'.format(**locals()), shell='vtysh')
        assert False, 'sw2 Failed to redistribute BGP routes'

    step('###### Step 6 - Disabling BGP process in sw2 and sw3 ######')
    with sw2.libs.vtysh.Configure() as ctx:
        ctx.no_router_bgp(ASN_2)
    with sw3.libs.vtysh.Configure() as ctx:
        ctx.no_router_bgp(ASN_3)

    step('###### Step 7 - Enabling OSPF configurations '
         'in sw2 and sw3 ######')
    configure_ospf_router(sw2, SW2_ROUTER_ID, SW2_INTF2_IPV4_ADDR, OSPF_AREA_1)
    configure_ospf_router(sw3, SW3_ROUTER_ID, SW3_INTF2_IPV4_ADDR, OSPF_AREA_1)

    step('########### TEST CASE [4.03] PASSED ###########')
Ejemplo n.º 8
0
def test_ospf_redistribute_static_routes(topology, configuration, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert sw3 is not None
    assert hs1 is not None
    assert hs2 is not None

    step('######Step 1 -  Verifying adjacency between switches ######')
    retval = wait_for_adjacency(sw3, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW3 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw3(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW3 and SW2(router-id = %s)" % SW2_ROUTER_ID

    retval = wait_for_adjacency(sw1, SW2_ROUTER_ID)
    if retval:
        step('Adjacency formed between SW1 and SW2(router-id = 2.2.2.2)')
    else:
        cmd = 'show ip ospf neighbor'
        sw1(cmd.format(**locals()), shell='vtysh')
        assert False, "Failed to form adjacency between"
        "SW1 and SW2(router-id = %s)" % SW2_ROUTER_ID

    step('######Step 2 - Configuring static routes in sw2 ######')
    with sw2.libs.vtysh.Configure() as ctx:
        ctx.ip_route('192.168.1.0/24', '1')
        ctx.ip_route('192.168.2.0/24', '1')
        ctx.ip_route('192.168.3.0/24', '1')

    step('######Step 3 - Redistibuting static routes configued in sw1 ######')
    with sw2.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.redistribute_static()

    # Waiting for static route to get updated in show rib command
    time.sleep(10)
    step('######step 4 - Verifying the sw2 advertised routes in sw1 ######')
    retval = verify_route(sw1, '192.168.1.0', '24')
    if retval is True:
        step('Static route 192.168.1.0 in SW2 is advertised to SW1')
    else:
        sw1('show rib'.format(**locals()), shell='vtysh')
        assert False, "Static route 192.168.1.0 in SW2 is not"
        " advertised to SW1"

    retval = verify_route(sw1, '192.168.2.0', '24')
    if retval is True:
        step('Static route 192.168.2.0 in SW2 is advertised to SW1')
    else:
        sw1('show rib'.format(**locals()), shell='vtysh')
        assert False, "Static route 192.168.2.0 in SW2 is not"
        " advertised to SW1"

    retval = verify_route(sw1, '192.168.3.0', '24')
    if retval is True:
        step('Static route 192.168.3.0 in SW2 is advertised to SW1')
    else:
        sw1('show rib'.format(**locals()), shell='vtysh')
        assert False, "Static route 192.168.3.0 in SW2 is not"
        " advertised to SW1"

    step('######Step 5 - Disabling static route redistribution '
         'on sw1######')
    with sw2.libs.vtysh.ConfigRouterOspf() as ctx:
        ctx.no_redistribute_static()

    step('########### TEST CASE [4.01] PASSED ###########')