tests: framework gracefully handle 'VppTransportShmemIOError' 41/18341/9
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Fri, 15 Mar 2019 16:39:19 +0000 (09:39 -0700)
committerOle Trøan <otroan@employees.org>
Fri, 7 Jun 2019 09:48:05 +0000 (09:48 +0000)
Catches:
----
Traceback (most recent call last):
  File "/vpp/test/framework.py", line 593, in tearDown
    self.logger.info(self.vapi.ppcli("api trace save %s" % api_trace))
  File "/vpp/test/vpp_papi_provider.py", line 413, in ppcli
    return cli + "\n" + str(self.cli(cli))
  File "/vpp/test/vpp_papi_provider.py", line 402, in cli
    r = self.papi.cli_inband(cmd=cli)
  File "/vpp/src/vpp-api/python/vpp_papi/vpp_papi.py", line 100, in __call__
    return self._func(**kwargs)
  File "/vpp/src/vpp-api/python/vpp_papi/vpp_papi.py", line 414, in f
    return self._call_vpp(i, msg, multipart, **kwargs)
  File "/vpp/src/vpp-api/python/vpp_papi/vpp_papi.py", line 634, in _call_vpp
    msg = self.transport.read()
  File "/vpp/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py", line 120, in read
    raise VppTransportShmemIOError(rv, 'vac_read failed')
VppTransportShmemIOError: [Errno -1] vac_read failed
----

Change-Id: I767e48c4d03081eb5df6a8aa67da7e192d25e4cc
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
test/framework.py
test/test_acl_plugin_macip.py

index efb1e6b..fd91d4c 100644 (file)
@@ -28,6 +28,7 @@ from vpp_lo_interface import VppLoInterface
 from vpp_bvi_interface import VppBviInterface
 from vpp_papi_provider import VppPapiProvider
 from vpp_papi.vpp_stats import VPPStats
+from vpp_papi.vpp_transport_shmem import VppTransportShmemIOError
 from log import RED, GREEN, YELLOW, double_line_delim, single_line_delim, \
     get_logger, colorize
 from vpp_object import VppObjectRegistry
@@ -616,18 +617,18 @@ class VppTestCase(unittest.TestCase):
         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)
+
+        try:
+            if not self.vpp_dead:
+                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
             tmp_api_trace = "/tmp/%s" % api_trace
@@ -638,6 +639,10 @@ class VppTestCase(unittest.TestCase):
             os.rename(tmp_api_trace, vpp_api_trace_log)
             self.logger.info(self.vapi.ppcli("api trace custom-dump %s" %
                                              vpp_api_trace_log))
+        except VppTransportShmemIOError:
+            self.logger.debug("VppTransportShmemIOError: Vpp dead. "
+                              "Cannot log show commands.")
+            self.vpp_dead = True
         else:
             self.registry.unregister_all(self.logger)
 
index fa05109..4173525 100644 (file)
@@ -161,10 +161,8 @@ class MethodHolder(VppTestCase):
         del self.ACLS[:]
 
     def tearDown(self):
-        """
-        Show various debug prints after each test.
-        """
         super(MethodHolder, self).tearDown()
+        self.delete_acls()
 
     def show_commands_at_teardown(self):
         self.logger.info(self.vapi.ppcli("show interface address"))
@@ -179,7 +177,6 @@ class MethodHolder(VppTestCase):
         # 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):
         acls = self.vapi.macip_acl_dump()