Browse Source

Copy cluster nodes logs always whether tests pass or fail

- Use addOnCleanup instead of addOnException. This will make copy
  logs to run  whether tests pass or fail.
- Also try to copy logs if setupClass Fails.

Change-Id: I76b135ade4c1ed4987f9bcbe1d5ded09ad57deb9
yatin 1 year ago
parent
commit
d015b73ec2

+ 1
- 1
magnum/tests/functional/api/v1/test_bay.py View File

@@ -107,7 +107,7 @@ class BayTest(base.BaseTempestTest):
107 107
         self.bays.append(model.uuid)
108 108
         self.bay_uuid = model.uuid
109 109
         if config.Config.copy_logs:
110
-            self.addOnException(self.copy_logs_handler(
110
+            self.addCleanup(self.copy_logs_handler(
111 111
                 lambda: list(
112 112
                     [self._get_bay_by_id(self.bay_uuid)[1].master_addresses,
113 113
                      self._get_bay_by_id(self.bay_uuid)[1].node_addresses]),

+ 1
- 1
magnum/tests/functional/api/v1/test_cluster.py View File

@@ -107,7 +107,7 @@ class ClusterTest(base.BaseTempestTest):
107 107
         self.clusters.append(model.uuid)
108 108
         self.cluster_uuid = model.uuid
109 109
         if config.Config.copy_logs:
110
-            self.addOnException(self.copy_logs_handler(
110
+            self.addCleanup(self.copy_logs_handler(
111 111
                 lambda: list(
112 112
                     [self._get_cluster_by_id(model.uuid)[1].master_addresses,
113 113
                      self._get_cluster_by_id(model.uuid)[1].node_addresses]),

+ 2
- 3
magnum/tests/functional/common/base.py View File

@@ -44,11 +44,10 @@ class BaseMagnumTest(base.BaseTestCase):
44 44
                 [[master_nodes], [slave_nodes]].
45 45
         :param coe: the COE type of the nodes
46 46
         """
47
-        def int_copy_logs(exec_info):
47
+        def int_copy_logs():
48 48
             try:
49 49
                 cls.LOG.info(_LI("Copying logs..."))
50
-                fn = exec_info[2].tb_frame.f_locals['fn']
51
-                func_name = fn.im_self._get_test_method().__name__
50
+                func_name = "test"
52 51
                 msg = (_LE("Failed to copy logs for cluster"))
53 52
                 nodes_addresses = get_nodes_fn()
54 53
 

+ 20
- 1
magnum/tests/functional/python_client_base.py View File

@@ -264,6 +264,24 @@ extendedKeyUsage = clientAuth
264 264
         cls.cluster = cls._create_cluster(cls.__name__,
265 265
                                           cls.cluster_template.uuid)
266 266
         if not cls.cluster_template_kwargs.get('tls_disabled', False):
267
+            # NOTE (wangbo) with multiple mangum-conductor processes, client
268
+            # ca files should be created after completion of cluster ca_cert
269
+            try:
270
+                cls._wait_on_status(
271
+                    cls.cluster,
272
+                    [None, "CREATE_IN_PROGRESS"],
273
+                    ["CREATE_FAILED", "CREATE_COMPLETE"],
274
+                    timeout=cls.cluster_complete_timeout
275
+                )
276
+            except Exception:
277
+                # copy logs if setUpClass fails, may be this will not work
278
+                # as master_address, node_address would not be available, if
279
+                # not we can get that from nova
280
+                if cls.copy_logs:
281
+                    cls.copy_logs_handler(
282
+                        cls._get_nodes,
283
+                        cls.cluster_template.coe,
284
+                        'default')
267 285
             cls._create_tls_ca_files(cls.config_contents)
268 286
 
269 287
     @classmethod
@@ -290,8 +308,9 @@ extendedKeyUsage = clientAuth
290 308
 
291 309
         self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
292 310
 
311
+        # Copy cluster nodes logs
293 312
         if self.copy_logs:
294
-            self.addOnException(
313
+            self.addCleanup(
295 314
                 self.copy_logs_handler(
296 315
                     self._get_nodes,
297 316
                     self.cluster_template.coe,

Loading…
Cancel
Save