summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryatin <ykarel@redhat.com>2017-07-13 16:02:08 +0530
committerSpyros Trigazis <spyridon.trigazis@cern.ch>2017-07-26 14:57:59 +0200
commitd015b73ec298f817778f31e6a4931358e69e7c57 (patch)
treeb8fc75ecb208f28e4e32fd0613b96bb2581423de
parent34f3011913a4480d935fa7d8755ef1947ad5010c (diff)
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
Notes
Notes (review): Code-Review+2: yatin <ykarel@redhat.com> Workflow+1: Spyros Trigazis (strigazi) <strigazi@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 01 Aug 2017 12:16:40 +0000 Reviewed-on: https://review.openstack.org/487404 Project: openstack/magnum Branch: refs/heads/stable/ocata
-rw-r--r--magnum/tests/functional/api/v1/test_bay.py2
-rw-r--r--magnum/tests/functional/api/v1/test_cluster.py2
-rw-r--r--magnum/tests/functional/common/base.py5
-rw-r--r--magnum/tests/functional/python_client_base.py21
4 files changed, 24 insertions, 6 deletions
diff --git a/magnum/tests/functional/api/v1/test_bay.py b/magnum/tests/functional/api/v1/test_bay.py
index 33cd8a5..cf701cd 100644
--- 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):
107 self.bays.append(model.uuid) 107 self.bays.append(model.uuid)
108 self.bay_uuid = model.uuid 108 self.bay_uuid = model.uuid
109 if config.Config.copy_logs: 109 if config.Config.copy_logs:
110 self.addOnException(self.copy_logs_handler( 110 self.addCleanup(self.copy_logs_handler(
111 lambda: list( 111 lambda: list(
112 [self._get_bay_by_id(self.bay_uuid)[1].master_addresses, 112 [self._get_bay_by_id(self.bay_uuid)[1].master_addresses,
113 self._get_bay_by_id(self.bay_uuid)[1].node_addresses]), 113 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 3a0843e..f6232d9 100644
--- 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):
107 self.clusters.append(model.uuid) 107 self.clusters.append(model.uuid)
108 self.cluster_uuid = model.uuid 108 self.cluster_uuid = model.uuid
109 if config.Config.copy_logs: 109 if config.Config.copy_logs:
110 self.addOnException(self.copy_logs_handler( 110 self.addCleanup(self.copy_logs_handler(
111 lambda: list( 111 lambda: list(
112 [self._get_cluster_by_id(model.uuid)[1].master_addresses, 112 [self._get_cluster_by_id(model.uuid)[1].master_addresses,
113 self._get_cluster_by_id(model.uuid)[1].node_addresses]), 113 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 b9f3dab..d535b05 100644
--- a/magnum/tests/functional/common/base.py
+++ b/magnum/tests/functional/common/base.py
@@ -44,11 +44,10 @@ class BaseMagnumTest(base.BaseTestCase):
44 [[master_nodes], [slave_nodes]]. 44 [[master_nodes], [slave_nodes]].
45 :param coe: the COE type of the nodes 45 :param coe: the COE type of the nodes
46 """ 46 """
47 def int_copy_logs(exec_info): 47 def int_copy_logs():
48 try: 48 try:
49 cls.LOG.info(_LI("Copying logs...")) 49 cls.LOG.info(_LI("Copying logs..."))
50 fn = exec_info[2].tb_frame.f_locals['fn'] 50 func_name = "test"
51 func_name = fn.im_self._get_test_method().__name__
52 msg = (_LE("Failed to copy logs for cluster")) 51 msg = (_LE("Failed to copy logs for cluster"))
53 nodes_addresses = get_nodes_fn() 52 nodes_addresses = get_nodes_fn()
54 53
diff --git a/magnum/tests/functional/python_client_base.py b/magnum/tests/functional/python_client_base.py
index 855d3b6..99083d6 100644
--- a/magnum/tests/functional/python_client_base.py
+++ b/magnum/tests/functional/python_client_base.py
@@ -264,6 +264,24 @@ extendedKeyUsage = clientAuth
264 cls.cluster = cls._create_cluster(cls.__name__, 264 cls.cluster = cls._create_cluster(cls.__name__,
265 cls.cluster_template.uuid) 265 cls.cluster_template.uuid)
266 if not cls.cluster_template_kwargs.get('tls_disabled', False): 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 cls._create_tls_ca_files(cls.config_contents) 285 cls._create_tls_ca_files(cls.config_contents)
268 286
269 @classmethod 287 @classmethod
@@ -290,8 +308,9 @@ extendedKeyUsage = clientAuth
290 308
291 self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) 309 self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
292 310
311 # Copy cluster nodes logs
293 if self.copy_logs: 312 if self.copy_logs:
294 self.addOnException( 313 self.addCleanup(
295 self.copy_logs_handler( 314 self.copy_logs_handler(
296 self._get_nodes, 315 self._get_nodes,
297 self.cluster_template.coe, 316 self.cluster_template.coe,