From 96984a17a5fa8661a62ec773f94a28d0c720249b Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Sat, 4 Aug 2018 11:48:00 -0300 Subject: [PATCH] ldp-vpls-topo1: remove duplicated code and sleep Use the new standardized code for router output compare and remove a code sleep. Signed-off-by: Rafael Zalamena --- .../ldp-vpls-topo1/test_ldp_vpls_topo1.py | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py b/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py index e279c8fc68..0948c2e41b 100755 --- a/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py +++ b/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py @@ -155,20 +155,20 @@ def teardown_module(mod): # This function tears down the whole topology. tgen.stop_topology() -def router_compare_json_output_cb(rname, command, reference): - tgen = get_topogen() - router = tgen.gears[rname] - output = router.vtysh_cmd(command, isjson=True) - refTableFile = '{}/{}/{}'.format(CWD, router.name, reference) - expected = json.loads(open(refTableFile).read()) - return topotest.json_cmp(output, expected) def router_compare_json_output(rname, command, reference): + "Compare router JSON output" + logger.info('Comparing router "%s" "%s" output', rname, command) - # Run test function until we get an result. Wait at most 60 seconds. - test_func = partial(router_compare_json_output_cb, rname, command, reference) - _, diff = topotest.run_and_expect(test_func, None, count=20, wait=3) + tgen = get_topogen() + filename = '{}/{}/{}'.format(CWD, rname, reference) + expected = json.loads(open(filename).read()) + + # Run test function until we get an result. Wait at most 80 seconds. + test_func = partial(topotest.router_json_cmp, + tgen.gears[rname], command, expected) + _, diff = topotest.run_and_expect(test_func, None, count=160, wait=0.5) assertmsg = '"{}" JSON output mismatches the expected result'.format(rname) assert diff is None, assertmsg @@ -283,9 +283,6 @@ def test_ldp_pseudowires_after_link_down(): tgen = get_topogen() tgen.gears['r1'].peer_link_enable('r1-eth1', False) - # Wait 15 seconds for the r1-r2 LDP link adjacencies to time out - sleep(15) - # check if the pseudowire is still up (using an alternate path for nexthop resolution) for rname in ['r1', 'r2', 'r3']: router_compare_json_output(rname, "show l2vpn atom vc json", "show_l2vpn_vc.ref") -- 2.39.5