From: Paul Vinciguerra Date: Wed, 13 Mar 2019 16:23:05 +0000 (-0700) Subject: Tests: Refactor tearDown show command logging, add lifecycle markers. X-Git-Tag: v20.01-rc0~838 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=commitdiff_plain;h=90cf21b5d8fd2d3e531e841dcd752311df5f8a50 Tests: Refactor tearDown show command logging, add lifecycle markers. This change adds a consistent interface for adding test-specific show commands to log.txt. It also adds log markers for the execution of setUp[Class], tearDown[Class] in the logs. Change-Id: I7d42e396e594a59e866a7d55dac0af25548e657a Signed-off-by: Paul Vinciguerra --- diff --git a/test/framework.py b/test/framework.py index 22a4dd87571..8a92229249b 100644 --- a/test/framework.py +++ b/test/framework.py @@ -411,6 +411,7 @@ class VppTestCase(unittest.TestCase): if hasattr(cls, 'parallel_handler'): cls.logger.addHandler(cls.parallel_handler) cls.logger.propagate = False + cls.tempdir = tempfile.mkdtemp( prefix='vpp-unittest-%s-' % cls.__name__) cls.stats_sock = "%s/stats.sock" % cls.tempdir @@ -420,6 +421,8 @@ class VppTestCase(unittest.TestCase): datefmt="%H:%M:%S")) cls.file_handler.setLevel(DEBUG) cls.logger.addHandler(cls.file_handler) + cls.logger.debug("--- setUpClass() for %s called ---" % + cls.__name__) cls.shm_prefix = os.path.basename(cls.tempdir) os.chdir(cls.tempdir) cls.logger.info("Temporary dir is %s, shm prefix is %s", @@ -561,6 +564,8 @@ class VppTestCase(unittest.TestCase): @classmethod def tearDownClass(cls): """ Perform final cleanup after running all tests in this test-case """ + cls.logger.debug("--- tearDownClass() for %s called ---" % + cls.__name__) cls.reporter.send_keep_alive(cls, 'tearDownClass') cls.quit() cls.file_handler.close() @@ -568,18 +573,26 @@ class VppTestCase(unittest.TestCase): if debug_framework: debug_internal.on_tear_down_class(cls) + def show_commands_at_teardown(self): + """ Allow subclass specific teardown logging additions.""" + self.logger.info("--- No test specific show commands provided. ---") + def tearDown(self): """ Show various debug prints after each test """ self.logger.debug("--- tearDown() for %s.%s(%s) called ---" % (self.__class__.__name__, self._testMethodName, self._testMethodDoc)) if not self.vpp_dead: + self.logger.info( + "--- Logging show commands common to all testcases. ---") self.logger.debug(self.vapi.cli("show trace max 1000")) self.logger.info(self.vapi.ppcli("show interface")) self.logger.info(self.vapi.ppcli("show hardware")) self.logger.info(self.statistics.set_errors_str()) self.logger.info(self.vapi.ppcli("show run")) self.logger.info(self.vapi.ppcli("show log")) + self.logger.info("Logging testcase specific show commands.") + self.show_commands_at_teardown() self.registry.remove_vpp_config(self.logger) # Save/Dump VPP api trace log api_trace = "vpp_api_trace.%s.log" % self._testMethodName @@ -598,9 +611,6 @@ class VppTestCase(unittest.TestCase): """ Clear trace before running each test""" super(VppTestCase, self).setUp() self.reporter.send_keep_alive(self) - self.logger.debug("--- setUp() for %s.%s(%s) called ---" % - (self.__class__.__name__, self._testMethodName, - self._testMethodDoc)) if self.vpp_dead: raise Exception("VPP is dead when setting up the test") self.sleep(.1, "during setUp") diff --git a/test/template_ipsec.py b/test/template_ipsec.py index de779648645..6854a352108 100644 --- a/test/template_ipsec.py +++ b/test/template_ipsec.py @@ -188,6 +188,7 @@ class TemplateIpsec(VppTestCase): IPSEC_API_PROTO_AH) self.config_interfaces() + self.ipsec_select_backend() def unconfig_interfaces(self): @@ -201,8 +202,8 @@ class TemplateIpsec(VppTestCase): self.unconfig_interfaces() - if not self.vpp_dead: - self.vapi.cli("show hardware") + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show hardware")) def gen_encrypt_pkts(self, sa, sw_intf, src, dst, count=1, payload_size=54): diff --git a/test/test_acl_plugin.py b/test/test_acl_plugin.py index 772b5bbb415..1ca74d186bc 100644 --- a/test/test_acl_plugin.py +++ b/test/test_acl_plugin.py @@ -157,21 +157,22 @@ class TestACLplugin(VppTestCase): Show various debug prints after each test. """ super(TestACLplugin, self).tearDown() - if not self.vpp_dead: - cli = "show vlib graph l2-input-feat-arc" - self.logger.info(self.vapi.ppcli(cli)) - cli = "show vlib graph l2-input-feat-arc-end" - self.logger.info(self.vapi.ppcli(cli)) - cli = "show vlib graph l2-output-feat-arc" - self.logger.info(self.vapi.ppcli(cli)) - cli = "show vlib graph l2-output-feat-arc-end" - self.logger.info(self.vapi.ppcli(cli)) - self.logger.info(self.vapi.ppcli("show l2fib verbose")) - self.logger.info(self.vapi.ppcli("show acl-plugin acl")) - self.logger.info(self.vapi.ppcli("show acl-plugin interface")) - self.logger.info(self.vapi.ppcli("show acl-plugin tables")) - self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" - % self.bd_id)) + + def show_commands_at_teardown(self): + cli = "show vlib graph l2-input-feat-arc" + self.logger.info(self.vapi.ppcli(cli)) + cli = "show vlib graph l2-input-feat-arc-end" + self.logger.info(self.vapi.ppcli(cli)) + cli = "show vlib graph l2-output-feat-arc" + self.logger.info(self.vapi.ppcli(cli)) + cli = "show vlib graph l2-output-feat-arc-end" + self.logger.info(self.vapi.ppcli(cli)) + self.logger.info(self.vapi.ppcli("show l2fib verbose")) + self.logger.info(self.vapi.ppcli("show acl-plugin acl")) + self.logger.info(self.vapi.ppcli("show acl-plugin interface")) + self.logger.info(self.vapi.ppcli("show acl-plugin tables")) + self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" + % self.bd_id)) def create_rule(self, ip=0, permit_deny=0, ports=PORTS_ALL, proto=-1, s_prefix=0, s_ip='\x00\x00\x00\x00', diff --git a/test/test_acl_plugin_conns.py b/test/test_acl_plugin_conns.py index b6c47373b8f..58c44e68262 100644 --- a/test/test_acl_plugin_conns.py +++ b/test/test_acl_plugin_conns.py @@ -150,14 +150,15 @@ class ACLPluginConnTestCase(VppTestCase): """Run standard test teardown and log various show commands """ super(ACLPluginConnTestCase, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show ip arp")) - self.logger.info(self.vapi.cli("show ip6 neighbors")) - self.logger.info(self.vapi.cli("show acl-plugin sessions")) - self.logger.info(self.vapi.cli("show acl-plugin acl")) - self.logger.info(self.vapi.cli("show acl-plugin interface")) - self.logger.info(self.vapi.cli("show acl-plugin tables")) - self.logger.info(self.vapi.cli("show event-logger all")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show ip arp")) + self.logger.info(self.vapi.cli("show ip6 neighbors")) + self.logger.info(self.vapi.cli("show acl-plugin sessions")) + self.logger.info(self.vapi.cli("show acl-plugin acl")) + self.logger.info(self.vapi.cli("show acl-plugin interface")) + self.logger.info(self.vapi.cli("show acl-plugin tables")) + self.logger.info(self.vapi.cli("show event-logger all")) def run_basic_conn_test(self, af, acl_side): """ Basic conn timeout test """ diff --git a/test/test_acl_plugin_l2l3.py b/test/test_acl_plugin_l2l3.py index 7f54b0594b2..6b4ea476eb4 100644 --- a/test/test_acl_plugin_l2l3.py +++ b/test/test_acl_plugin_l2l3.py @@ -114,19 +114,20 @@ class TestACLpluginL2L3(VppTestCase): ``show ip arp``. """ super(TestACLpluginL2L3, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show l2patch")) - self.logger.info(self.vapi.cli("show classify tables")) - self.logger.info(self.vapi.cli("show l2fib verbose")) - self.logger.info(self.vapi.cli("show bridge-domain %s detail" % - self.bd_id)) - self.logger.info(self.vapi.cli("show ip arp")) - self.logger.info(self.vapi.cli("show ip6 neighbors")) - cmd = "show acl-plugin sessions verbose 1" - self.logger.info(self.vapi.cli(cmd)) - self.logger.info(self.vapi.cli("show acl-plugin acl")) - self.logger.info(self.vapi.cli("show acl-plugin interface")) - self.logger.info(self.vapi.cli("show acl-plugin tables")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show l2patch")) + self.logger.info(self.vapi.cli("show classify tables")) + self.logger.info(self.vapi.cli("show l2fib verbose")) + self.logger.info(self.vapi.cli("show bridge-domain %s detail" % + self.bd_id)) + self.logger.info(self.vapi.cli("show ip arp")) + self.logger.info(self.vapi.cli("show ip6 neighbors")) + cmd = "show acl-plugin sessions verbose 1" + self.logger.info(self.vapi.cli(cmd)) + self.logger.info(self.vapi.cli("show acl-plugin acl")) + self.logger.info(self.vapi.cli("show acl-plugin interface")) + self.logger.info(self.vapi.cli("show acl-plugin tables")) def create_stream(self, src_ip_if, dst_ip_if, reverse, packet_sizes, is_ip6, expect_blocked, expect_established, diff --git a/test/test_acl_plugin_macip.py b/test/test_acl_plugin_macip.py index fe34cd06312..fa051093fdf 100644 --- a/test/test_acl_plugin_macip.py +++ b/test/test_acl_plugin_macip.py @@ -165,19 +165,20 @@ class MethodHolder(VppTestCase): Show various debug prints after each test. """ super(MethodHolder, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show interface address")) - self.logger.info(self.vapi.ppcli("show hardware")) - self.logger.info(self.vapi.ppcli("sh acl-plugin macip acl")) - self.logger.info(self.vapi.ppcli("sh acl-plugin macip interface")) - self.logger.info(self.vapi.ppcli("sh classify tables verbose")) - self.logger.info(self.vapi.ppcli("sh acl-plugin acl")) - self.logger.info(self.vapi.ppcli("sh acl-plugin interface")) - self.logger.info(self.vapi.ppcli("sh acl-plugin tables")) - # print(self.vapi.ppcli("show interface address")) - # print(self.vapi.ppcli("show hardware")) - # print(self.vapi.ppcli("sh acl-plugin macip interface")) - # print(self.vapi.ppcli("sh acl-plugin macip acl")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show interface address")) + self.logger.info(self.vapi.ppcli("show hardware")) + self.logger.info(self.vapi.ppcli("sh acl-plugin macip acl")) + self.logger.info(self.vapi.ppcli("sh acl-plugin macip interface")) + self.logger.info(self.vapi.ppcli("sh classify tables verbose")) + self.logger.info(self.vapi.ppcli("sh acl-plugin acl")) + self.logger.info(self.vapi.ppcli("sh acl-plugin interface")) + self.logger.info(self.vapi.ppcli("sh acl-plugin tables")) + # print(self.vapi.ppcli("show interface address")) + # print(self.vapi.ppcli("show hardware")) + # print(self.vapi.ppcli("sh acl-plugin macip interface")) + # print(self.vapi.ppcli("sh acl-plugin macip acl")) self.delete_acls() def macip_acl_dump_debug(self): diff --git a/test/test_bond.py b/test/test_bond.py index a888993584b..03f0eea4c7e 100644 --- a/test/test_bond.py +++ b/test/test_bond.py @@ -40,8 +40,9 @@ class TestBondInterface(VppTestCase): def tearDown(self): super(TestBondInterface, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show interface")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show interface")) def test_bond_traffic(self): """ Bond traffic test """ diff --git a/test/test_classifier.py b/test/test_classifier.py index 51449016ffb..5b0eddb5bce 100644 --- a/test/test_classifier.py +++ b/test/test_classifier.py @@ -75,10 +75,6 @@ class TestClassifier(VppTestCase): def tearDown(self): """Run standard test teardown and acl related log.""" if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show inacl type ip4")) - self.logger.info(self.vapi.ppcli("show outacl type ip4")) - self.logger.info(self.vapi.cli("show classify table verbose")) - self.logger.info(self.vapi.cli("show ip fib")) if self.acl_active_table == 'ip_out': self.output_acl_set_interface( self.pg0, self.acl_tbl_idx.get(self.acl_active_table), 0) @@ -93,6 +89,12 @@ class TestClassifier(VppTestCase): super(TestClassifier, self).tearDown() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show inacl type ip4")) + self.logger.info(self.vapi.ppcli("show outacl type ip4")) + self.logger.info(self.vapi.cli("show classify table verbose")) + self.logger.info(self.vapi.cli("show ip fib")) + def config_pbr_fib_entry(self, intf, is_add=1): """Configure fib entry to route traffic toward PBR VRF table diff --git a/test/test_classifier_ip6.py b/test/test_classifier_ip6.py index 6725f6123e5..ea6adcb713f 100644 --- a/test/test_classifier_ip6.py +++ b/test/test_classifier_ip6.py @@ -73,10 +73,6 @@ class TestClassifier(VppTestCase): def tearDown(self): """Run standard test teardown and acl related log.""" if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show inacl type ip6")) - self.logger.info(self.vapi.ppcli("show outacl type ip6")) - self.logger.info(self.vapi.cli("show classify table verbose")) - self.logger.info(self.vapi.cli("show ip fib")) if self.acl_active_table == 'ip6_out': self.output_acl_set_interface( self.pg0, self.acl_tbl_idx.get(self.acl_active_table), 0) @@ -91,6 +87,12 @@ class TestClassifier(VppTestCase): super(TestClassifier, self).tearDown() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show inacl type ip6")) + self.logger.info(self.vapi.ppcli("show outacl type ip6")) + self.logger.info(self.vapi.cli("show classify table verbose")) + self.logger.info(self.vapi.cli("show ip fib")) + def create_stream(self, src_if, dst_if, packet_sizes, proto_l=UDP(sport=1234, dport=5678)): """Create input packet stream for defined interfaces. diff --git a/test/test_classify_l2_acl.py b/test/test_classify_l2_acl.py index fb9e03ba3d4..8ba7181aef1 100644 --- a/test/test_classify_l2_acl.py +++ b/test/test_classify_l2_acl.py @@ -147,11 +147,6 @@ class TestClassifyAcl(VppTestCase): Show various debug prints after each test. """ if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show inacl type l2")) - self.logger.info(self.vapi.ppcli("show outacl type l2")) - self.logger.info(self.vapi.ppcli("show classify tables verbose")) - self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" - % self.bd_id)) if self.acl_active_table == 'mac_inout': self.output_acl_set_interface( self.pg1, self.acl_tbl_idx.get(self.acl_active_table), 0) @@ -169,6 +164,13 @@ class TestClassifyAcl(VppTestCase): super(TestClassifyAcl, self).tearDown() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show inacl type l2")) + self.logger.info(self.vapi.ppcli("show outacl type l2")) + self.logger.info(self.vapi.ppcli("show classify tables verbose")) + self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" + % self.bd_id)) + @staticmethod def build_mac_mask(dst_mac='', src_mac='', ether_type=''): """Build MAC ACL mask data with hexstring format diff --git a/test/test_container.py b/test/test_container.py index 56644bce610..139dfcfbcaf 100644 --- a/test/test_container.py +++ b/test/test_container.py @@ -45,9 +45,10 @@ class ContainerIntegrationTestCase(VppTestCase): """Run standard test teardown and log various show commands """ super(ContainerIntegrationTestCase, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show ip arp")) - self.logger.info(self.vapi.cli("show ip6 neighbors")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show ip arp")) + self.logger.info(self.vapi.cli("show ip6 neighbors")) def run_basic_conn_test(self, af, acl_side): """ Basic connectivity test """ diff --git a/test/test_geneve.py b/test/test_geneve.py index 4d6e3f5932a..86515f40430 100644 --- a/test/test_geneve.py +++ b/test/test_geneve.py @@ -223,11 +223,12 @@ class TestGeneve(BridgeDomain, VppTestCase): # @param self The object pointer. def tearDown(self): super(TestGeneve, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 2 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) - self.logger.info(self.vapi.cli("show geneve tunnel")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 2 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) + self.logger.info(self.vapi.cli("show geneve tunnel")) if __name__ == '__main__': diff --git a/test/test_gtpu.py b/test/test_gtpu.py index 0d764f55edb..199bd7d98ca 100644 --- a/test/test_gtpu.py +++ b/test/test_gtpu.py @@ -287,13 +287,14 @@ class TestGtpu(BridgeDomain, VppTestCase): # @param self The object pointer. def tearDown(self): super(TestGtpu, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show bridge-domain 11 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 12 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 13 detail")) - self.logger.info(self.vapi.cli("show int")) - self.logger.info(self.vapi.cli("show gtpu tunnel")) - self.logger.info(self.vapi.cli("show trace")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show bridge-domain 11 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 12 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 13 detail")) + self.logger.info(self.vapi.cli("show int")) + self.logger.info(self.vapi.cli("show gtpu tunnel")) + self.logger.info(self.vapi.cli("show trace")) if __name__ == '__main__': diff --git a/test/test_ip4.py b/test/test_ip4.py index 7ed6580315e..ed7a5659322 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -82,9 +82,10 @@ class TestIPv4(VppTestCase): def tearDown(self): """Run standard test teardown and log ``show ip arp``.""" super(TestIPv4, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show ip arp")) - # info(self.vapi.cli("show ip fib")) # many entries + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show ip arp")) + # info(self.vapi.cli("show ip fib")) # many entries def config_fib_entries(self, count): """For each interface add to the FIB table *count* routes to diff --git a/test/test_ip4_irb.py b/test/test_ip4_irb.py index f4f2b610d1c..df663552f42 100644 --- a/test/test_ip4_irb.py +++ b/test/test_ip4_irb.py @@ -99,12 +99,13 @@ class TestIpIrb(VppTestCase): ``show ip arp``. """ super(TestIpIrb, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show l2patch")) - self.logger.info(self.vapi.cli("show l2fib verbose")) - self.logger.info(self.vapi.cli("show bridge-domain %s detail" % - self.bd_id)) - self.logger.info(self.vapi.cli("show ip arp")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show l2patch")) + self.logger.info(self.vapi.cli("show l2fib verbose")) + self.logger.info(self.vapi.cli("show bridge-domain %s detail" % + self.bd_id)) + self.logger.info(self.vapi.cli("show ip arp")) def create_stream(self, src_ip_if, dst_ip_if, packet_sizes): pkts = [] diff --git a/test/test_ip4_vrf_multi_instance.py b/test/test_ip4_vrf_multi_instance.py index ff6a7227b6f..38604a53474 100644 --- a/test/test_ip4_vrf_multi_instance.py +++ b/test/test_ip4_vrf_multi_instance.py @@ -164,9 +164,10 @@ class TestIp4VrfMultiInst(VppTestCase): Show various debug prints after each test. """ super(TestIp4VrfMultiInst, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show ip fib")) - self.logger.info(self.vapi.ppcli("show ip arp")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show ip fib")) + self.logger.info(self.vapi.ppcli("show ip arp")) def create_vrf_and_assign_interfaces(self, count, start=1): """ diff --git a/test/test_ip6_vrf_multi_instance.py b/test/test_ip6_vrf_multi_instance.py index 45c192de868..c4b057ba29d 100644 --- a/test/test_ip6_vrf_multi_instance.py +++ b/test/test_ip6_vrf_multi_instance.py @@ -176,9 +176,10 @@ class TestIP6VrfMultiInst(VppTestCase): Show various debug prints after each test. """ super(TestIP6VrfMultiInst, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show ip6 fib")) - self.logger.info(self.vapi.ppcli("show ip6 neighbors")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show ip6 fib")) + self.logger.info(self.vapi.ppcli("show ip6 neighbors")) def create_vrf_and_assign_interfaces(self, count, start=1): """ diff --git a/test/test_ip_ecmp.py b/test/test_ip_ecmp.py index c6a33c815b8..e3ceb594826 100644 --- a/test/test_ip_ecmp.py +++ b/test/test_ip_ecmp.py @@ -72,9 +72,10 @@ class TestECMP(VppTestCase): Show various debug prints after each test. """ super(TestECMP, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show ip arp")) - self.logger.info(self.vapi.ppcli("show ip6 neighbors")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show ip arp")) + self.logger.info(self.vapi.ppcli("show ip6 neighbors")) def get_ip_address(self, ip_addr_start, ip_prefix_len): """ diff --git a/test/test_ipsec_esp.py b/test/test_ipsec_esp.py index a8b28c53ee6..e5db0a627a5 100644 --- a/test/test_ipsec_esp.py +++ b/test/test_ipsec_esp.py @@ -332,8 +332,9 @@ class TemplateIpsecEspUdp(ConfigIpsecESP): def tearDown(self): super(TemplateIpsecEspUdp, self).tearDown() - if not self.vpp_dead: - self.vapi.cli("show hardware") + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show hardware")) class TestIpsecEspUdp(TemplateIpsecEspUdp, IpsecTra4Tests, IpsecTun4Tests): diff --git a/test/test_l2_fib.py b/test/test_l2_fib.py index a75672ab079..4a5cb56352a 100644 --- a/test/test_l2_fib.py +++ b/test/test_l2_fib.py @@ -145,11 +145,13 @@ class TestL2fib(VppTestCase): """ super(TestL2fib, self).tearDown() if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2fib verbose")) for bd_id in self.n_brs: self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % bd_id)) + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2fib verbose")) + def create_hosts(self, n_hosts_per_if, subnet): """ Create required number of host MAC addresses and distribute them among diff --git a/test/test_l2bd_arp_term.py b/test/test_l2bd_arp_term.py index 9a14d1db55e..a3feb99a9c7 100644 --- a/test/test_l2bd_arp_term.py +++ b/test/test_l2bd_arp_term.py @@ -67,9 +67,10 @@ class TestL2bdArpTerm(VppTestCase): Show various debug prints after each test. """ super(TestL2bdArpTerm, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2fib verbose")) - self.logger.info(self.vapi.ppcli("show bridge-domain 1 detail")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2fib verbose")) + self.logger.info(self.vapi.ppcli("show bridge-domain 1 detail")) def add_del_arp_term_hosts(self, entries, bd_id=1, is_add=1, is_ipv6=0): for e in entries: diff --git a/test/test_l2xc.py b/test/test_l2xc.py index 845579b037b..1e786e48b4d 100644 --- a/test/test_l2xc.py +++ b/test/test_l2xc.py @@ -89,8 +89,9 @@ class TestL2xc(VppTestCase): Show various debug prints after each test. """ super(TestL2xc, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2patch")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2patch")) @classmethod def create_host_lists(cls, count): diff --git a/test/test_l2xc_multi_instance.py b/test/test_l2xc_multi_instance.py index 0fb080aea2b..f7cffa3eb12 100644 --- a/test/test_l2xc_multi_instance.py +++ b/test/test_l2xc_multi_instance.py @@ -128,8 +128,9 @@ class TestL2xcMultiInst(VppTestCase): Show various debug prints after each test. """ super(TestL2xcMultiInst, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2patch")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2patch")) @classmethod def create_hosts(cls, count): diff --git a/test/test_lb.py b/test/test_lb.py index 4c0bfadaccb..93b389a1444 100644 --- a/test/test_lb.py +++ b/test/test_lb.py @@ -69,8 +69,9 @@ class TestLB(VppTestCase): def tearDown(self): super(TestLB, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show lb vip verbose")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show lb vip verbose")) def getIPv4Flow(self, id): return (IP(dst="90.0.%u.%u" % (id / 255, id % 255), diff --git a/test/test_nat.py b/test/test_nat.py index 5cd0ad9d8ab..29d747d0932 100644 --- a/test/test_nat.py +++ b/test/test_nat.py @@ -4161,20 +4161,21 @@ class TestNAT44(MethodHolder): def tearDown(self): super(TestNAT44, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show nat44 addresses")) - self.logger.info(self.vapi.cli("show nat44 interfaces")) - self.logger.info(self.vapi.cli("show nat44 static mappings")) - self.logger.info(self.vapi.cli("show nat44 interface address")) - self.logger.info(self.vapi.cli("show nat44 sessions detail")) - self.logger.info(self.vapi.cli("show nat virtual-reassembly")) - self.logger.info(self.vapi.cli("show nat44 hash tables detail")) - self.logger.info(self.vapi.cli("show nat timeouts")) - self.logger.info( - self.vapi.cli("show nat addr-port-assignment-alg")) - self.logger.info(self.vapi.cli("show nat ha")) - self.clear_nat44() - self.vapi.cli("clear logging") + self.clear_nat44() + self.vapi.cli("clear logging") + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show nat44 addresses")) + self.logger.info(self.vapi.cli("show nat44 interfaces")) + self.logger.info(self.vapi.cli("show nat44 static mappings")) + self.logger.info(self.vapi.cli("show nat44 interface address")) + self.logger.info(self.vapi.cli("show nat44 sessions detail")) + self.logger.info(self.vapi.cli("show nat virtual-reassembly")) + self.logger.info(self.vapi.cli("show nat44 hash tables detail")) + self.logger.info(self.vapi.cli("show nat timeouts")) + self.logger.info( + self.vapi.cli("show nat addr-port-assignment-alg")) + self.logger.info(self.vapi.cli("show nat ha")) class TestNAT44EndpointDependent(MethodHolder): @@ -6419,16 +6420,18 @@ class TestNAT44EndpointDependent(MethodHolder): def tearDown(self): super(TestNAT44EndpointDependent, self).tearDown() if not self.vpp_dead: - self.logger.info(self.vapi.cli("show nat44 addresses")) - self.logger.info(self.vapi.cli("show nat44 interfaces")) - self.logger.info(self.vapi.cli("show nat44 static mappings")) - self.logger.info(self.vapi.cli("show nat44 interface address")) - self.logger.info(self.vapi.cli("show nat44 sessions detail")) - self.logger.info(self.vapi.cli("show nat44 hash tables detail")) - self.logger.info(self.vapi.cli("show nat timeouts")) self.clear_nat44() self.vapi.cli("clear logging") + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show nat44 addresses")) + self.logger.info(self.vapi.cli("show nat44 interfaces")) + self.logger.info(self.vapi.cli("show nat44 static mappings")) + self.logger.info(self.vapi.cli("show nat44 interface address")) + self.logger.info(self.vapi.cli("show nat44 sessions detail")) + self.logger.info(self.vapi.cli("show nat44 hash tables detail")) + self.logger.info(self.vapi.cli("show nat timeouts")) + class TestNAT44Out2InDPO(MethodHolder): """ NAT44 Test Cases using out2in DPO """ @@ -7142,14 +7145,16 @@ class TestDeterministicNAT(MethodHolder): def tearDown(self): super(TestDeterministicNAT, self).tearDown() if not self.vpp_dead: - self.logger.info(self.vapi.cli("show nat44 interfaces")) - self.logger.info(self.vapi.cli("show nat timeouts")) - self.logger.info( - self.vapi.cli("show nat44 deterministic mappings")) - self.logger.info( - self.vapi.cli("show nat44 deterministic sessions")) self.clear_nat_det() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show nat44 interfaces")) + self.logger.info(self.vapi.cli("show nat timeouts")) + self.logger.info( + self.vapi.cli("show nat44 deterministic mappings")) + self.logger.info( + self.vapi.cli("show nat44 deterministic sessions")) + class TestNAT64(MethodHolder): """ NAT64 Test Cases """ @@ -8517,14 +8522,16 @@ class TestNAT64(MethodHolder): def tearDown(self): super(TestNAT64, self).tearDown() if not self.vpp_dead: - self.logger.info(self.vapi.cli("show nat64 pool")) - self.logger.info(self.vapi.cli("show nat64 interfaces")) - self.logger.info(self.vapi.cli("show nat64 prefix")) - self.logger.info(self.vapi.cli("show nat64 bib all")) - self.logger.info(self.vapi.cli("show nat64 session table all")) - self.logger.info(self.vapi.cli("show nat virtual-reassembly")) self.clear_nat64() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show nat64 pool")) + self.logger.info(self.vapi.cli("show nat64 interfaces")) + self.logger.info(self.vapi.cli("show nat64 prefix")) + self.logger.info(self.vapi.cli("show nat64 bib all")) + self.logger.info(self.vapi.cli("show nat64 session table all")) + self.logger.info(self.vapi.cli("show nat virtual-reassembly")) + class TestDSlite(MethodHolder): """ DS-Lite Test Cases """ @@ -8718,11 +8725,12 @@ class TestDSlite(MethodHolder): def tearDown(self): super(TestDSlite, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show dslite pool")) - self.logger.info( - self.vapi.cli("show dslite aftr-tunnel-endpoint-address")) - self.logger.info(self.vapi.cli("show dslite sessions")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show dslite pool")) + self.logger.info( + self.vapi.cli("show dslite aftr-tunnel-endpoint-address")) + self.logger.info(self.vapi.cli("show dslite sessions")) class TestDSliteCE(MethodHolder): @@ -8828,11 +8836,12 @@ class TestDSliteCE(MethodHolder): def tearDown(self): super(TestDSliteCE, self).tearDown() - if not self.vpp_dead: - self.logger.info( - self.vapi.cli("show dslite aftr-tunnel-endpoint-address")) - self.logger.info( - self.vapi.cli("show dslite b4-tunnel-endpoint-address")) + + def show_commands_at_teardown(self): + self.logger.info( + self.vapi.cli("show dslite aftr-tunnel-endpoint-address")) + self.logger.info( + self.vapi.cli("show dslite b4-tunnel-endpoint-address")) class TestNAT66(MethodHolder): @@ -8977,11 +8986,11 @@ class TestNAT66(MethodHolder): def tearDown(self): super(TestNAT66, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show nat66 interfaces")) - self.logger.info(self.vapi.cli("show nat66 static mappings")) - self.clear_nat66() + self.clear_nat66() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show nat66 interfaces")) + self.logger.info(self.vapi.cli("show nat66 static mappings")) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) diff --git a/test/test_ping.py b/test/test_ping.py index 75c18d46c69..7e5c92f63c6 100644 --- a/test/test_ping.py +++ b/test/test_ping.py @@ -42,8 +42,9 @@ class TestPing(VppTestCase): def tearDown(self): super(TestPing, self).tearDown() - if not self.vpp_dead: - self.vapi.cli("show hardware") + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show hardware")) def test_ping_basic(self): """ basic ping test """ diff --git a/test/test_pppoe.py b/test/test_pppoe.py index 5c8495fed98..54378673eb4 100644 --- a/test/test_pppoe.py +++ b/test/test_pppoe.py @@ -43,16 +43,17 @@ class TestPPPoE(VppTestCase): def tearDown(self): super(TestPPPoE, self).tearDown() + for i in self.pg_interfaces: + i.unconfig_ip4() + i.admin_down() + + def show_commands_at_teardown(self): self.logger.info(self.vapi.cli("show int")) self.logger.info(self.vapi.cli("show pppoe fib")) self.logger.info(self.vapi.cli("show pppoe session")) self.logger.info(self.vapi.cli("show ip fib")) self.logger.info(self.vapi.cli("show trace")) - for i in self.pg_interfaces: - i.unconfig_ip4() - i.admin_down() - def create_stream_pppoe_discovery(self, src_if, dst_if, client_mac, count=1): packets = [] diff --git a/test/test_reassembly.py b/test/test_reassembly.py index 5fa912b631e..8cfb109b0b5 100644 --- a/test/test_reassembly.py +++ b/test/test_reassembly.py @@ -236,6 +236,8 @@ class TestIPv4Reassembly(TestIPReassemblyMixin, VppTestCase): def tearDown(self): super(TestIPv4Reassembly, self).tearDown() + + def show_commands_at_teardown(self): self.logger.debug(self.vapi.ppcli("show ip4-reassembly details")) self.logger.debug(self.vapi.ppcli("show buffers")) @@ -572,6 +574,8 @@ class TestIPv6Reassembly(TestIPReassemblyMixin, VppTestCase): def tearDown(self): super(TestIPv6Reassembly, self).tearDown() + + def show_commands_at_teardown(self): self.logger.debug(self.vapi.ppcli("show ip6-reassembly details")) self.logger.debug(self.vapi.ppcli("show buffers")) @@ -868,6 +872,8 @@ class TestIPv4ReassemblyLocalNode(VppTestCase): def tearDown(self): super(TestIPv4ReassemblyLocalNode, self).tearDown() + + def show_commands_at_teardown(self): self.logger.debug(self.vapi.ppcli("show ip4-reassembly details")) self.logger.debug(self.vapi.ppcli("show buffers")) @@ -1000,10 +1006,12 @@ class TestFIFReassembly(VppTestCase): expire_walk_interval_ms=10000, is_ip6=1) def tearDown(self): + super(TestFIFReassembly, self).tearDown() + + def show_commands_at_teardown(self): self.logger.debug(self.vapi.ppcli("show ip4-reassembly details")) self.logger.debug(self.vapi.ppcli("show ip6-reassembly details")) self.logger.debug(self.vapi.ppcli("show buffers")) - super(TestFIFReassembly, self).tearDown() def verify_capture(self, capture, ip_class, dropped_packet_indexes=[]): """Verify captured packet stream. diff --git a/test/test_span.py b/test/test_span.py index b0ea1e5eb90..78a4f7608ed 100644 --- a/test/test_span.py +++ b/test/test_span.py @@ -61,8 +61,9 @@ class TestSpan(VppTestCase): def tearDown(self): super(TestSpan, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show interface span")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show interface span")) def xconnect(self, a, b, is_add=1): self.vapi.sw_interface_set_l2_xconnect(a, b, enable=is_add) diff --git a/test/test_vcl.py b/test/test_vcl.py index 0ef4b5c079e..e49c9d800e0 100644 --- a/test/test_vcl.py +++ b/test/test_vcl.py @@ -259,10 +259,12 @@ class LDPCutThruTestCase(VCLTestCase): self.server_port] def tearDown(self): - self.logger.debug(self.vapi.cli("show session verbose 2")) self.cut_thru_tear_down() super(LDPCutThruTestCase, self).tearDown() + def show_commands_at_teardown(self): + self.logger.debug(self.vapi.cli("show session verbose 2")) + @unittest.skipUnless(running_extended_tests, "part of extended tests") def test_ldp_cut_thru_echo(self): """ run LDP cut thru echo test """ @@ -396,11 +398,13 @@ class VCLThruHostStackEcho(VCLTestCase): self.server_port] def tearDown(self): - self.logger.debug(self.vapi.cli("show app server")) - self.logger.debug(self.vapi.cli("show session verbose")) self.thru_host_stack_tear_down() super(VCLThruHostStackEcho, self).tearDown() + def show_commands_at_teardown(self): + self.logger.debug(self.vapi.cli("show app server")) + self.logger.debug(self.vapi.cli("show session verbose")) + class VCLThruHostStackTLS(VCLTestCase): """ VCL Thru Host Stack TLS """ @@ -432,11 +436,13 @@ class VCLThruHostStackTLS(VCLTestCase): self.client_uni_dir_tls_test_args) def tearDown(self): - self.logger.debug(self.vapi.cli("show app server")) - self.logger.debug(self.vapi.cli("show session verbose 2")) self.thru_host_stack_tear_down() super(VCLThruHostStackTLS, self).tearDown() + def show_commands_at_teardown(self): + self.logger.debug(self.vapi.cli("show app server")) + self.logger.debug(self.vapi.cli("show session verbose 2")) + class VCLThruHostStackBidirNsock(VCLTestCase): """ VCL Thru Host Stack Bidir Nsock """ @@ -463,10 +469,12 @@ class VCLThruHostStackBidirNsock(VCLTestCase): self.server_port] def tearDown(self): - self.logger.debug(self.vapi.cli("show session verbose 2")) self.thru_host_stack_tear_down() super(VCLThruHostStackBidirNsock, self).tearDown() + def show_commands_at_teardown(self): + self.logger.debug(self.vapi.cli("show session verbose 2")) + def test_vcl_thru_host_stack_bi_dir_nsock(self): """ run VCL thru host stack bi-directional (multiple sockets) test """ @@ -507,10 +515,12 @@ class LDPThruHostStackBidirNsock(VCLTestCase): self.server_port] def tearDown(self): - self.logger.debug(self.vapi.cli("show session verbose 2")) self.thru_host_stack_tear_down() super(LDPThruHostStackBidirNsock, self).tearDown() + def show_commands_at_teardown(self): + self.logger.debug(self.vapi.cli("show session verbose 2")) + def test_ldp_thru_host_stack_bi_dir_nsock(self): """ run LDP thru host stack bi-directional (multiple sockets) test """ @@ -620,10 +630,12 @@ class LDPThruHostStackIperf(VCLTestCase): self.server_iperf3_args = ["-V4d", "-s"] def tearDown(self): - self.logger.debug(self.vapi.cli("show session verbose 2")) self.thru_host_stack_tear_down() super(LDPThruHostStackIperf, self).tearDown() + def show_commands_at_teardown(self): + self.logger.debug(self.vapi.cli("show session verbose 2")) + def test_ldp_thru_host_stack_iperf3(self): """ run LDP thru host stack iperf3 test """ diff --git a/test/test_vtr.py b/test/test_vtr.py index b7e131f005e..a224909d8cb 100644 --- a/test/test_vtr.py +++ b/test/test_vtr.py @@ -83,10 +83,11 @@ class TestVtr(VppTestCase): Show various debug prints after each test. """ super(TestVtr, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2fib verbose")) - self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % - self.bd_id)) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2fib verbose")) + self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % + self.bd_id)) @classmethod def create_hosts_and_learn(cls, count): diff --git a/test/test_vxlan.py b/test/test_vxlan.py index 5ffb2fe371d..aa069dc6e7b 100644 --- a/test/test_vxlan.py +++ b/test/test_vxlan.py @@ -255,11 +255,12 @@ class TestVxlan(BridgeDomain, VppTestCase): # @param self The object pointer. def tearDown(self): super(TestVxlan, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 2 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) - self.logger.info(self.vapi.cli("show vxlan tunnel")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 2 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) + self.logger.info(self.vapi.cli("show vxlan tunnel")) if __name__ == '__main__': diff --git a/test/test_vxlan6.py b/test/test_vxlan6.py index 6f8fee71ec0..4053fadff8b 100644 --- a/test/test_vxlan6.py +++ b/test/test_vxlan6.py @@ -179,11 +179,12 @@ class TestVxlan6(BridgeDomain, VppTestCase): # @param self The object pointer. def tearDown(self): super(TestVxlan6, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 2 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) - self.logger.info(self.vapi.cli("show vxlan tunnel")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 2 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) + self.logger.info(self.vapi.cli("show vxlan tunnel")) if __name__ == '__main__': diff --git a/test/test_vxlan_gbp.py b/test/test_vxlan_gbp.py index b4f86991ff9..b4eb069cc89 100644 --- a/test/test_vxlan_gbp.py +++ b/test/test_vxlan_gbp.py @@ -260,11 +260,12 @@ class TestVxlanGbp(VppTestCase): # @param self The object pointer. def tearDown(self): super(TestVxlanGbp, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) - self.logger.info(self.vapi.cli("show vxlan-gbp tunnel")) - self.logger.info(self.vapi.cli("show error")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show bridge-domain 1 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 3 detail")) + self.logger.info(self.vapi.cli("show vxlan-gbp tunnel")) + self.logger.info(self.vapi.cli("show error")) if __name__ == '__main__': diff --git a/test/test_vxlan_gpe.py b/test/test_vxlan_gpe.py index 36661a9c1fa..7ee1225dd8c 100644 --- a/test/test_vxlan_gpe.py +++ b/test/test_vxlan_gpe.py @@ -243,13 +243,14 @@ class TestVxlanGpe(BridgeDomain, VppTestCase): # @param self The object pointer. def tearDown(self): super(TestVxlanGpe, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show bridge-domain 11 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 12 detail")) - self.logger.info(self.vapi.cli("show bridge-domain 13 detail")) - self.logger.info(self.vapi.cli("show int")) - self.logger.info(self.vapi.cli("show vxlan-gpe")) - self.logger.info(self.vapi.cli("show trace")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show bridge-domain 11 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 12 detail")) + self.logger.info(self.vapi.cli("show bridge-domain 13 detail")) + self.logger.info(self.vapi.cli("show int")) + self.logger.info(self.vapi.cli("show vxlan-gpe")) + self.logger.info(self.vapi.cli("show trace")) if __name__ == '__main__':