From 6fb2741a957259cbcf60a770fbc3367f8a0abb96 Mon Sep 17 00:00:00 2001 From: yatin Date: Thu, 13 Jul 2017 16:02:08 +0530 Subject: [PATCH] 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 --- magnum/tests/functional/api/v1/test_bay.py | 2 +- magnum/tests/functional/api/v1/test_cluster.py | 2 +- magnum/tests/functional/common/base.py | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/magnum/tests/functional/api/v1/test_bay.py b/magnum/tests/functional/api/v1/test_bay.py index 00f734b..c8f5586 100755 --- a/magnum/tests/functional/api/v1/test_bay.py +++ b/magnum/tests/functional/api/v1/test_bay.py @@ -107,7 +107,7 @@ class BayTest(base.BaseTempestTest): self.bays.append(model.uuid) self.bay_uuid = model.uuid if config.Config.copy_logs: - self.addOnException(self.copy_logs_handler( + self.addCleanup(self.copy_logs_handler( lambda: list( [self._get_bay_by_id(self.bay_uuid)[1].master_addresses, self._get_bay_by_id(self.bay_uuid)[1].node_addresses]), diff --git a/magnum/tests/functional/api/v1/test_cluster.py b/magnum/tests/functional/api/v1/test_cluster.py index 990cc41..fc2a148 100755 --- a/magnum/tests/functional/api/v1/test_cluster.py +++ b/magnum/tests/functional/api/v1/test_cluster.py @@ -107,7 +107,7 @@ class ClusterTest(base.BaseTempestTest): self.clusters.append(model.uuid) self.cluster_uuid = model.uuid if config.Config.copy_logs: - self.addOnException(self.copy_logs_handler( + self.addCleanup(self.copy_logs_handler( lambda: list( [self._get_cluster_by_id(model.uuid)[1].master_addresses, self._get_cluster_by_id(model.uuid)[1].node_addresses]), diff --git a/magnum/tests/functional/common/base.py b/magnum/tests/functional/common/base.py index f29720e..f568cfb 100755 --- a/magnum/tests/functional/common/base.py +++ b/magnum/tests/functional/common/base.py @@ -42,11 +42,10 @@ class BaseMagnumTest(base.BaseTestCase): [[master_nodes], [slave_nodes]]. :param coe: the COE type of the nodes """ - def int_copy_logs(exec_info): + def int_copy_logs(): try: cls.LOG.info("Copying logs...") - fn = exec_info[2].tb_frame.f_locals['fn'] - func_name = fn.im_self._get_test_method().__name__ + func_name = "test" msg = ("Failed to copy logs for cluster") nodes_addresses = get_nodes_fn()