Avoid using the nose plugin for cord-tester to restore on failure.
The instantiation of the plugin with nose main causes issues where tests have setUp/Class methods.
Use the traditional try/finally block to restore on test failures.
Change-Id: I5f927cc87092b38e405ba833f2fa8771bffb2488
diff --git a/src/test/vsg/__init__.py b/src/test/vsg/__init__.py
index 082009e..8da76c4 100644
--- a/src/test/vsg/__init__.py
+++ b/src/test/vsg/__init__.py
@@ -15,7 +15,6 @@
#
import os,sys
import logging
-from nose import main as nosetest_main
logging.getLogger('scapy.runtime').setLevel(logging.ERROR)
##add the python path to lookup the utils
working_dir = os.path.dirname(os.path.realpath(sys.argv[-1]))
@@ -27,5 +26,7 @@
__path__.append(subscriber_dir)
cli_dir = os.path.join(working_dir, '../cli')
__path__.append(cli_dir)
-from CordTestConfig import CordTestConfigRestore
-nosetest_main(addplugins = [ CordTestConfigRestore() ])
+
+#from nose import main as nosetest_main
+#from CordTestConfig import CordTestConfigRestore
+#nosetest_main(addplugins = [ CordTestConfigRestore() ])
diff --git a/src/test/vsg/vsgTest.py b/src/test/vsg/vsgTest.py
index 9748f27..777b664 100644
--- a/src/test/vsg/vsgTest.py
+++ b/src/test/vsg/vsgTest.py
@@ -393,22 +393,24 @@
assert_not_equal(vcpe, None)
assert_not_equal(self.vcpe_dhcp, None)
#first get dhcp on the vcpe interface
- vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
- assert_not_equal(vcpe_ip, None)
- log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
- log.info('Sending ICMP pings to host %s' %(host))
- st, _ = getstatusoutput('ping -c 1 {}'.format(host))
- assert_equal(st, 0)
- #bring down the wan interface and check again
- st = VSGAccess.vcpe_wan_down(vcpe)
- assert_equal(st, True)
- st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host))
- st = VSGAccess.vcpe_wan_up(vcpe)
- assert_not_equal(st_ping, 0)
- assert_equal(st, True)
- st, _ = getstatusoutput('ping -c 1 {}'.format(host))
- VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
- assert_equal(st, 0)
+ try:
+ vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
+ assert_not_equal(vcpe_ip, None)
+ log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
+ log.info('Sending ICMP pings to host %s' %(host))
+ st, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ assert_equal(st, 0)
+ #bring down the wan interface and check again
+ st = VSGAccess.vcpe_wan_down(vcpe)
+ assert_equal(st, True)
+ st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ st = VSGAccess.vcpe_wan_up(vcpe)
+ assert_not_equal(st_ping, 0)
+ assert_equal(st, True)
+ st, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ assert_equal(st, 0)
+ finally:
+ self.config_restore()
def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe(self):
"""
@@ -428,22 +430,24 @@
assert_not_equal(vcpe, None)
assert_not_equal(self.vcpe_dhcp, None)
#first get dhcp on the vcpe interface
- vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
- assert_not_equal(vcpe_ip, None)
- log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
- log.info('Sending ICMP pings to host %s' %(host))
- st, _ = getstatusoutput('ping -c 1 {}'.format(host))
- assert_equal(st, 0)
- #bring down the lan interface and check again
- st = VSGAccess.vcpe_lan_down(vcpe)
- assert_equal(st, True)
- st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host))
- st = VSGAccess.vcpe_lan_up(vcpe)
- assert_not_equal(st_ping, 0)
- assert_equal(st, True)
- st, _ = getstatusoutput('ping -c 1 {}'.format(host))
- VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
- assert_equal(st, 0)
+ try:
+ vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
+ assert_not_equal(vcpe_ip, None)
+ log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
+ log.info('Sending ICMP pings to host %s' %(host))
+ st, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ assert_equal(st, 0)
+ #bring down the lan interface and check again
+ st = VSGAccess.vcpe_lan_down(vcpe)
+ assert_equal(st, True)
+ st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ st = VSGAccess.vcpe_lan_up(vcpe)
+ assert_not_equal(st_ping, 0)
+ assert_equal(st, True)
+ st, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ assert_equal(st, 0)
+ finally:
+ self.config_restore()
def test_vsg_firewall_with_deny_destination_ip(self, vcpe=None):
"""
@@ -461,18 +465,18 @@
vcpe = self.vcpe_container
vsg = VSGAccess.get_vcpe_vsg(vcpe)
assert_not_equal(vsg, None)
- vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
- assert_not_equal(vcpe_ip, None)
- st, _ = getstatusoutput('ping -c 1 {}'.format(host))
- assert_equal(st, 0)
try:
+ vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
+ assert_not_equal(vcpe_ip, None)
+ st, _ = getstatusoutput('ping -c 1 {}'.format(host))
+ assert_equal(st, 0)
st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host))
st, _ = getstatusoutput('ping -c 1 {}'.format(host))
assert_not_equal(st, 0)
finally:
vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe))
vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe))
- VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
+ self.config_restore()
def test_vsg_firewall_with_rule_add_and_delete_dest_ip(self, vcpe=None):
"""