diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-01-19 16:19:25 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-01-20 02:41:47 +0100 |
commit | 068c6100cd7b4181721e1b2009151fe38751f091 (patch) | |
tree | d9d1f27c846a27c0138a8a7c6032d0c528e23291 | |
parent | b8272b61db810b813a5dac0e78f16bdd47d61664 (diff) |
Move logics out of TempestCommon.__init__()
It conforms with best programming practices.
It allows muting console and increasing log level (debug).
Change-Id: I0e0cfef6abe3b354a43817fcb242c71da701e237
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit b482b494ce695e83cca0a10e7750200fd1be42ea)
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 55 | ||||
-rw-r--r-- | functest/tests/unit/openstack/tempest/test_tempest.py | 1 |
2 files changed, 34 insertions, 22 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 4fd466780..9d788de8c 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -59,28 +59,10 @@ class TempestCommon(singlevm.VmReady2): self.orig_cloud.grant_role( self.role_name, user=self.project.user.id, domain=self.project.domain.id) - environ = dict( - os.environ, - OS_USERNAME=self.project.user.name, - OS_PROJECT_NAME=self.project.project.name, - OS_PROJECT_ID=self.project.project.id, - OS_PASSWORD=self.project.password) - try: - del environ['OS_TENANT_NAME'] - del environ['OS_TENANT_ID'] - except Exception: # pylint: disable=broad-except - pass - self.deployment_id = conf_utils.create_rally_deployment( - environ=environ) - if not self.deployment_id: - raise Exception("Deployment create failed") - self.verifier_id = conf_utils.create_verifier() - if not self.verifier_id: - raise Exception("Verifier create failed") - self.verifier_repo_dir = conf_utils.get_verifier_repo_dir( - self.verifier_id) - self.deployment_dir = conf_utils.get_verifier_deployment_dir( - self.verifier_id, self.deployment_id) + self.deployment_id = None + self.verifier_id = None + self.verifier_repo_dir = None + self.deployment_dir = None self.verification_id = None self.res_dir = os.path.join( getattr(config.CONF, 'dir_results'), self.case_name) @@ -347,6 +329,8 @@ class TempestCommon(singlevm.VmReady2): os.makedirs(self.res_dir) rconfig = configparser.RawConfigParser() rconfig.read(rally_conf) + rconfig.set('DEFAULT', 'debug', True) + rconfig.set('DEFAULT', 'use_stderr', False) rconfig.set('DEFAULT', 'log-file', 'rally.log') rconfig.set('DEFAULT', 'log_dir', self.res_dir) with open(rally_conf, 'wb') as config_file: @@ -361,6 +345,10 @@ class TempestCommon(singlevm.VmReady2): rconfig.remove_option('openstack', 'img_name_regex') if rconfig.has_option('openstack', 'swift_operator_role'): rconfig.remove_option('openstack', 'swift_operator_role') + if rconfig.has_option('DEFAULT', 'use_stderr'): + rconfig.remove_option('DEFAULT', 'use_stderr') + if rconfig.has_option('DEFAULT', 'debug'): + rconfig.remove_option('DEFAULT', 'debug') if rconfig.has_option('DEFAULT', 'log-file'): rconfig.remove_option('DEFAULT', 'log-file') if rconfig.has_option('DEFAULT', 'log_dir'): @@ -402,6 +390,29 @@ class TempestCommon(singlevm.VmReady2): """ if not os.path.exists(self.res_dir): os.makedirs(self.res_dir) + environ = dict( + os.environ, + OS_USERNAME=self.project.user.name, + OS_PROJECT_NAME=self.project.project.name, + OS_PROJECT_ID=self.project.project.id, + OS_PASSWORD=self.project.password) + try: + del environ['OS_TENANT_NAME'] + del environ['OS_TENANT_ID'] + except Exception: # pylint: disable=broad-except + pass + self.deployment_id = conf_utils.create_rally_deployment( + environ=environ) + if not self.deployment_id: + raise Exception("Deployment create failed") + self.verifier_id = conf_utils.create_verifier() + if not self.verifier_id: + raise Exception("Verifier create failed") + self.verifier_repo_dir = conf_utils.get_verifier_repo_dir( + self.verifier_id) + self.deployment_dir = conf_utils.get_verifier_deployment_dir( + self.verifier_id, self.deployment_id) + compute_cnt = len(self.orig_cloud.list_hypervisors()) self.image_alt = self.publish_image_alt() diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py index 67e7dd431..c1f245c72 100644 --- a/functest/tests/unit/openstack/tempest/test_tempest.py +++ b/functest/tests/unit/openstack/tempest/test_tempest.py @@ -82,6 +82,7 @@ class OSTempestTesting(unittest.TestCase): else: testr_mode = self.tempestcommon.mode verifier_repo_dir = 'test_verifier_repo_dir' + self.tempestcommon.verifier_repo_dir = verifier_repo_dir cmd = "(cd {0}; stestr list '{1}' >{2} 2>/dev/null)".format( verifier_repo_dir, testr_mode, self.tempestcommon.list) self.tempestcommon.generate_test_list(mode=testr_mode) |