From 4072a153239485bd851c78f20b5f1e4376547457 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Mon, 12 Mar 2018 17:17:54 -0400 Subject: [PATCH] bgp_vrf_netns: attempt cleanup of previous test abnormal exit. skip test if setup fails Signed-off-by: Lou Berger --- tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py b/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py index 58e0857546..780a62e2e9 100755 --- a/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py +++ b/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py @@ -103,13 +103,17 @@ def setup_module(module): # create VRF r1-cust1 # move r1-eth0 to VRF r1-cust1 - cmds = ['ip netns add {0}-cust1', + cmds = ['if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi', + 'ip netns add {0}-cust1', 'ip link set dev {0}-eth0 netns {0}-cust1', 'ip netns exec {0}-cust1 ifconfig {0}-eth0 up'] for cmd in cmds: + cmd = cmd.format('r1') + logger.info('cmd: '+cmd); output = router.run(cmd.format('r1')) if output != None and len(output) > 0: - logger.info('unexpected output: cmd="{}" output=\n{}'.format(cmd, output)) + logger.info('Aborting due to unexpected output: cmd="{}" output=\n{}'.format(cmd, output)) + return pytest.skip('Skipping BGP VRF NETNS Test. Unexpected output to command: '+cmd) #run daemons router.load_config( TopoRouter.RD_ZEBRA, -- 2.39.5