def test_ospf_link_down_kernel_route(): "Test OSPF kernel route installation" tgen = get_topogen() if tgen.routers_have_failure(): pytest.skip("skipped because of router(s) failure") rlist = tgen.routers().values() for router in rlist: logger.info( 'Checking OSPF IPv4 kernel routes in "%s" after link down', router.name ) routes = topotest.ip4_route(router) expected = { "10.0.1.0/24": {}, "10.0.2.0/24": {}, "10.0.3.0/24": {}, "10.0.10.0/24": {}, "172.16.0.0/24": {}, "172.16.1.0/24": {}, } if router.name == "r1" or router.name == "r2": expected.update( { "10.0.10.0/24": None, "172.16.0.0/24": None, "172.16.1.0/24": None, } ) elif router.name == "r3" or router.name == "r4": expected.update( { "10.0.1.0/24": None, "10.0.2.0/24": None, } ) # Route '10.0.3.0' is no longer available for r4 since it is down. if router.name == "r4": expected.update( { "10.0.3.0/24": None, } ) assertmsg = 'OSPF IPv4 route mismatch in router "{}" after link down'.format( router.name ) count = 0 not_found = True while not_found and count < 10: not_found = topotest.json_cmp(routes, expected) if not_found: sleep(1) routes = topotest.ip4_route(router) count += 1 else: not_found = False break assert not_found is False, assertmsg
def test_isis_linux_route_installation(): "Check whether all expected routes are present and installed in the OS" tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) logger.info("Checking routers for installed ISIS routes in OS") # Check for routes in `ip route` for rname, router in tgen.routers().items(): filename = "{0}/{1}/{1}_route_linux.json".format(CWD, rname) expected = json.loads(open(filename, "r").read()) actual = topotest.ip4_route(router) assertmsg = "Router '{}' OS routes mismatch".format(rname) assert topotest.json_cmp(actual, expected) is None, assertmsg
def test_ospf_kernel_route(): "Test OSPF kernel route installation" tgen = get_topogen() if tgen.routers_have_failure(): pytest.skip("skipped because of router(s) failure") rlist = tgen.routers().values() for router in rlist: logger.info('Checking OSPF IPv4 kernel routes in "%s"', router.name) routes = topotest.ip4_route(router) expected = { "10.0.1.0/24": {}, "10.0.2.0/24": {}, "10.0.3.0/24": {}, "10.0.10.0/24": {}, "172.16.0.0/24": {}, "172.16.1.0/24": {}, } assertmsg = 'OSPF IPv4 route mismatch in router "{}"'.format(router.name) assert topotest.json_cmp(routes, expected) is None, assertmsg
def test_ospf_link_down_kernel_route(): "Test OSPF kernel route installation" tgen = get_topogen() if tgen.routers_have_failure(): pytest.skip('skipped because of router(s) failure') rlist = tgen.routers().values() for router in rlist: logger.info('Checking OSPF IPv4 kernel routes in "%s" after link down', router.name) routes = topotest.ip4_route(router) expected = { '10.0.1.0/24': {}, '10.0.2.0/24': {}, '10.0.3.0/24': {}, '10.0.10.0/24': {}, '172.16.0.0/24': {}, '172.16.1.0/24': {}, } if router.name == 'r1' or router.name == 'r2': expected.update({ '10.0.10.0/24': None, '172.16.0.0/24': None, '172.16.1.0/24': None, }) elif router.name == 'r3' or router.name == 'r4': expected.update({ '10.0.1.0/24': None, '10.0.2.0/24': None, }) # Route '10.0.3.0' is no longer available for r4 since it is down. if router.name == 'r4': expected.update({ '10.0.3.0/24': None, }) assertmsg = 'OSPF IPv4 route mismatch in router "{}" after link down'.format( router.name) assert topotest.json_cmp(routes, expected) is None, assertmsg
def test_isis_linux_route_installation(): "Check whether all expected routes are present and installed in the OS" tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) logger.info('Checking routers for installed ISIS routes in OS') # Check for routes in `ip route` for rname, router in tgen.routers().iteritems(): filename = '{0}/{1}/{1}_route_linux.json'.format(CWD, rname) expected = json.loads(open(filename, 'r').read()) actual = topotest.ip4_route(router) # Older FRR versions install routes using different proto if router.has_version('<', '3.1'): for network, netoptions in expected.iteritems(): if 'proto' in netoptions and netoptions['proto'] == '187': netoptions['proto'] = 'zebra' assertmsg = "Router '{}' OS routes mismatch".format(rname) assert topotest.json_cmp(actual, expected) is None, assertmsg
def test_isis_linux_route_installation(): "Check whether all expected routes are present and installed in the OS" tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) logger.info("Checking routers for installed ISIS routes in OS") # Check for routes in `ip route` for rname, router in tgen.routers().items(): filename = "{0}/{1}/{1}_route_linux.json".format(CWD, rname) expected = json.loads(open(filename, "r").read()) actual = topotest.ip4_route(router) # Older FRR versions install routes using different proto if router.has_version("<", "3.1"): for network, netoptions in expected.items(): if "proto" in netoptions and netoptions["proto"] == "187": netoptions["proto"] = "zebra" assertmsg = "Router '{}' OS routes mismatch".format(rname) assert topotest.json_cmp(actual, expected) is None, assertmsg