From dffbabcdc713640aee37dd7e69ac04e4654b61bf Mon Sep 17 00:00:00 2001 From: Dane LeBlanc Date: Mon, 18 Apr 2016 10:28:36 -0400 Subject: [PATCH] Log copy for failed functional tests cannot be disabled Setting the following in functional_creds.conf doesn't have any effect for failed functional container tests: copy_logs = False Description of changes/issues addressed: - Client functional tests look in functional_creds.conf for the copy_logs setting while tempest/api tests look in tempest.conf. So an accessor method 'get_copy_logs' is added for BaseMagnumTest (for tempest tests), and this gets overridden by BaseMagnumClient. - Call to lamda was missing an argument in copy_logs_handler. - set_copy_logs in config.py was setting cls.copy logs inconsistently (sometimes boolean True, otherwise to a string). - BaseMagnumClient was calling bool() on a string: "bool(copy_logs)". bool() on a string always returns True except for null string. Change-Id: I234fd0433602914fdf03f04f2394f6dc802df4fd Closes-Bug: #1570949 --- magnum/tests/functional/common/base.py | 8 ++++++-- magnum/tests/functional/common/config.py | 2 +- magnum/tests/functional/python_client_base.py | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/magnum/tests/functional/common/base.py b/magnum/tests/functional/common/base.py index 736ac8d124..4747e7c69c 100644 --- a/magnum/tests/functional/common/base.py +++ b/magnum/tests/functional/common/base.py @@ -160,6 +160,10 @@ class BaseMagnumTest(base.BaseTestCase): creds = cls.get_credentials(name, type_of_creds, class_cleanup) return cls.get_clients(creds, type_of_creds, request_type) + @classmethod + def get_copy_logs(cls): + return config.Config.copy_logs + @classmethod def copy_logs_handler(cls, get_nodes_fn, coe, keypair): """Copy logs closure. @@ -172,8 +176,8 @@ class BaseMagnumTest(base.BaseTestCase): :param coe: the COE type of the nodes """ - if not config.Config.copy_logs: - return lambda: None + if not cls.get_copy_logs(): + return lambda exec_info: None def int_copy_logs(exec_info): try: diff --git a/magnum/tests/functional/common/config.py b/magnum/tests/functional/common/config.py index fbafa7d6d2..03a5d1a5ae 100644 --- a/magnum/tests/functional/common/config.py +++ b/magnum/tests/functional/common/config.py @@ -113,7 +113,7 @@ class Config(object): def set_copy_logs(cls, config): if 'copy_logs' not in CONF.magnum: cls.copy_logs = True - cls.copy_logs = CONF.magnum.copy_logs + cls.copy_logs = str(CONF.magnum.copy_logs).lower() == 'true' @classmethod def setUp(cls): diff --git a/magnum/tests/functional/python_client_base.py b/magnum/tests/functional/python_client_base.py index df2164f94f..b7eff47384 100644 --- a/magnum/tests/functional/python_client_base.py +++ b/magnum/tests/functional/python_client_base.py @@ -85,7 +85,7 @@ class BaseMagnumClient(base.BaseMagnumTest): cls.master_flavor_id = master_flavor_id cls.keypair_id = keypair_id cls.dns_nameserver = dns_nameserver - cls.copy_logs = bool(copy_logs) + cls.copy_logs = str(copy_logs).lower() == 'true' cls.cs = v1client.Client(username=user, api_key=passwd, project_id=tenant_id, @@ -178,6 +178,10 @@ class BaseMagnumClient(base.BaseMagnumTest): if cls._show_bay(cls.bay.uuid).status == 'DELETE_FAILED': raise Exception("bay %s delete failed" % cls.bay.uuid) + @classmethod + def get_copy_logs(cls): + return cls.copy_logs + def _wait_for_bay_complete(self, bay): self._wait_on_status( bay,