Tests: Refactor tearDown show command logging, add lifecycle markers. 69/18269/6
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Wed, 13 Mar 2019 16:23:05 +0000 (09:23 -0700)
committerOle Trøan <otroan@employees.org>
Thu, 11 Apr 2019 07:23:11 +0000 (07:23 +0000)
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 <pvinci@vinciconsulting.com>
35 files changed:
test/framework.py
test/template_ipsec.py
test/test_acl_plugin.py
test/test_acl_plugin_conns.py
test/test_acl_plugin_l2l3.py
test/test_acl_plugin_macip.py
test/test_bond.py
test/test_classifier.py
test/test_classifier_ip6.py
test/test_classify_l2_acl.py
test/test_container.py
test/test_geneve.py
test/test_gtpu.py
test/test_ip4.py
test/test_ip4_irb.py
test/test_ip4_vrf_multi_instance.py
test/test_ip6_vrf_multi_instance.py
test/test_ip_ecmp.py
test/test_ipsec_esp.py
test/test_l2_fib.py
test/test_l2bd_arp_term.py
test/test_l2xc.py
test/test_l2xc_multi_instance.py
test/test_lb.py
test/test_nat.py
test/test_ping.py
test/test_pppoe.py
test/test_reassembly.py
test/test_span.py
test/test_vcl.py
test/test_vtr.py
test/test_vxlan.py
test/test_vxlan6.py
test/test_vxlan_gbp.py
test/test_vxlan_gpe.py

index 22a4dd8..8a92229 100644 (file)
@@ -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")
index de77964..6854a35 100644 (file)
@@ -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):
index 772b5bb..1ca74d1 100644 (file)
@@ -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',
index b6c4737..58c44e6 100644 (file)
@@ -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 """
index 7f54b05..6b4ea47 100644 (file)
@@ -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,
index fe34cd0..fa05109 100644 (file)
@@ -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):
index a888993..03f0eea 100644 (file)
@@ -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 """
index 5144901..5b0eddb 100644 (file)
@@ -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
 
index 6725f61..ea6adcb 100644 (file)
@@ -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.
index fb9e03b..8ba7181 100644 (file)
@@ -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
index 56644bc..139dfcf 100644 (file)
@@ -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 """
index 4d6e3f5..86515f4 100644 (file)
@@ -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__':
index 0d764f5..199bd7d 100644 (file)
@@ -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__':
index 7ed6580..ed7a565 100644 (file)
@@ -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
index f4f2b61..df66355 100644 (file)
@@ -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 = []
index ff6a722..38604a5 100644 (file)
@@ -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):
         """
index 45c192d..c4b057b 100644 (file)
@@ -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):
         """
index c6a33c8..e3ceb59 100644 (file)
@@ -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):
         """
index a8b28c5..e5db0a6 100644 (file)
@@ -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):
index a75672a..4a5cb56 100644 (file)
@@ -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
index 9a14d1d..a3feb99 100644 (file)
@@ -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:
index 845579b..1e786e4 100644 (file)
@@ -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):
index 0fb080a..f7cffa3 100644 (file)
@@ -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):
index 4c0bfad..93b389a 100644 (file)
@@ -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),
index 5cd0ad9..29d747d 100644 (file)
@@ -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)
index 75c18d4..7e5c92f 100644 (file)
@@ -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 """
index 5c8495f..5437867 100644 (file)
@@ -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 = []
index 5fa912b..8cfb109 100644 (file)
@@ -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.
index b0ea1e5..78a4f76 100644 (file)
@@ -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)
index 0ef4b5c..e49c9d8 100644 (file)
@@ -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 """
 
index b7e131f..a224909 100644 (file)
@@ -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):
index 5ffb2fe..aa069dc 100644 (file)
@@ -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__':
index 6f8fee7..4053fad 100644 (file)
@@ -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__':
index b4f8699..b4eb069 100644 (file)
@@ -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__':
index 36661a9..7ee1225 100644 (file)
@@ -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__':