mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-11-04 13:30:17 +00:00 
			
		
		
		
	topotests: redispatch tests in bfd_topo3
Redispatch tests in bfd_topo3 in order to prepare next commit. Cosmetic change. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
		
							parent
							
								
									580c605194
								
							
						
					
					
						commit
						8f5bf65f26
					
				@ -65,6 +65,41 @@ def setup_module(mod):
 | 
			
		||||
    tgen.start_router()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def expect_static_bfd_output(router, filename):
 | 
			
		||||
    "Load JSON file and compare with 'show bfd peer json'"
 | 
			
		||||
 | 
			
		||||
    tgen = get_topogen()
 | 
			
		||||
 | 
			
		||||
    logger.info("waiting BFD configuration on router {}".format(router))
 | 
			
		||||
    bfd_config = json.loads(open("{}/{}/{}.json".format(CWD, router, filename)).read())
 | 
			
		||||
    test_func = partial(
 | 
			
		||||
        topotest.router_json_cmp,
 | 
			
		||||
        tgen.gears[router],
 | 
			
		||||
        "show bfd static route json",
 | 
			
		||||
        bfd_config,
 | 
			
		||||
    )
 | 
			
		||||
    _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
 | 
			
		||||
    assertmsg = '"{}" BFD static route status failure'.format(router)
 | 
			
		||||
    assert result is None, assertmsg
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def expect_route_missing(router, iptype, route):
 | 
			
		||||
    "Wait until route is present on RIB for protocol."
 | 
			
		||||
 | 
			
		||||
    tgen = get_topogen()
 | 
			
		||||
 | 
			
		||||
    logger.info("waiting route {} to disapear in {}".format(route, router))
 | 
			
		||||
    test_func = partial(
 | 
			
		||||
        topotest.router_json_cmp,
 | 
			
		||||
        tgen.gears[router],
 | 
			
		||||
        "show {} route json".format(iptype),
 | 
			
		||||
        {route: None},
 | 
			
		||||
    )
 | 
			
		||||
    rv, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
 | 
			
		||||
    assertmsg = '"{}" convergence failure'.format(router)
 | 
			
		||||
    assert result is None, assertmsg
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_wait_bgp_convergence():
 | 
			
		||||
    "Wait for BGP to converge"
 | 
			
		||||
    tgen = get_topogen()
 | 
			
		||||
@ -166,7 +201,7 @@ def test_wait_bfd_convergence():
 | 
			
		||||
    expect_bfd_configuration("r6")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_static_route_monitoring():
 | 
			
		||||
def test_static_route_monitoring_convergence():
 | 
			
		||||
    "Test static route monitoring output."
 | 
			
		||||
    tgen = get_topogen()
 | 
			
		||||
    if tgen.routers_have_failure():
 | 
			
		||||
@ -174,32 +209,9 @@ def test_static_route_monitoring():
 | 
			
		||||
 | 
			
		||||
    logger.info("test BFD static route status")
 | 
			
		||||
 | 
			
		||||
    def expect_static_bfd_output(router, filename):
 | 
			
		||||
        "Load JSON file and compare with 'show bfd peer json'"
 | 
			
		||||
        logger.info("waiting BFD configuration on router {}".format(router))
 | 
			
		||||
        bfd_config = json.loads(
 | 
			
		||||
            open("{}/{}/{}.json".format(CWD, router, filename)).read()
 | 
			
		||||
        )
 | 
			
		||||
        test_func = partial(
 | 
			
		||||
            topotest.router_json_cmp,
 | 
			
		||||
            tgen.gears[router],
 | 
			
		||||
            "show bfd static route json",
 | 
			
		||||
            bfd_config,
 | 
			
		||||
        )
 | 
			
		||||
        _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
 | 
			
		||||
        assertmsg = '"{}" BFD static route status failure'.format(router)
 | 
			
		||||
        assert result is None, assertmsg
 | 
			
		||||
 | 
			
		||||
    expect_static_bfd_output("r3", "bfd-static")
 | 
			
		||||
    expect_static_bfd_output("r6", "bfd-static")
 | 
			
		||||
 | 
			
		||||
    logger.info("Setting r4 link down ...")
 | 
			
		||||
 | 
			
		||||
    tgen.gears["r4"].link_enable("r4-eth0", False)
 | 
			
		||||
 | 
			
		||||
    expect_static_bfd_output("r3", "bfd-static-down")
 | 
			
		||||
    expect_static_bfd_output("r6", "bfd-static-down")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_expect_static_rib_removal():
 | 
			
		||||
    "Test that route got removed from RIB (staticd and bgpd)."
 | 
			
		||||
@ -208,18 +220,12 @@ def test_expect_static_rib_removal():
 | 
			
		||||
    if tgen.routers_have_failure():
 | 
			
		||||
        pytest.skip(tgen.errors)
 | 
			
		||||
 | 
			
		||||
    def expect_route_missing(router, iptype, route):
 | 
			
		||||
        "Wait until route is present on RIB for protocol."
 | 
			
		||||
        logger.info("waiting route {} to disapear in {}".format(route, router))
 | 
			
		||||
        test_func = partial(
 | 
			
		||||
            topotest.router_json_cmp,
 | 
			
		||||
            tgen.gears[router],
 | 
			
		||||
            "show {} route json".format(iptype),
 | 
			
		||||
            {route: None},
 | 
			
		||||
        )
 | 
			
		||||
        rv, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
 | 
			
		||||
        assertmsg = '"{}" convergence failure'.format(router)
 | 
			
		||||
        assert result is None, assertmsg
 | 
			
		||||
    logger.info("Setting r4 link down ...")
 | 
			
		||||
 | 
			
		||||
    tgen.gears["r4"].link_enable("r4-eth0", False)
 | 
			
		||||
 | 
			
		||||
    expect_static_bfd_output("r3", "bfd-static-down")
 | 
			
		||||
    expect_static_bfd_output("r6", "bfd-static-down")
 | 
			
		||||
 | 
			
		||||
    expect_route_missing("r1", "ip", "10.254.254.5/32")
 | 
			
		||||
    expect_route_missing("r2", "ip", "10.254.254.5/32")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user