diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2017-02-01 09:11:57 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-02-01 09:11:57 +0000 |
commit | 56c3758fbb234d45c70cc5a36aafd8c5f4d02373 (patch) | |
tree | 2eef7657f989d9b4ab7e79b0b72b761e0e8babdd /functest/opnfv_tests | |
parent | d298ec662021a5703907fa6b1a5bf71343b1cccc (diff) | |
parent | 92e7d8cee4addb8ea66516a2d5fd295500dcb132 (diff) |
Merge "Extract util functions from tempest.py to conf_utils"
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/conf_utils.py | 74 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 76 |
2 files changed, 79 insertions, 71 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index 88085d9a..4c5e8663 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -11,10 +11,12 @@ import ConfigParser import os import re import shutil +import subprocess import opnfv.utils.constants as releng_constants from functest.utils.constants import CONST +import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as os_utils @@ -39,8 +41,74 @@ TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt') CI_INSTALLER_TYPE = CONST.INSTALLER_TYPE CI_INSTALLER_IP = CONST.INSTALLER_IP +""" logging configuration """ +logger = ft_logger.Logger("Tempest").getLogger() -def configure_tempest(logger, deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): + +def get_verifier_id(): + """ + Returns verifer id for current Tempest + """ + cmd = ("rally verify list-verifiers | awk '/" + + CONST.tempest_deployment_name + + "/ {print $2}'") + p = subprocess.Popen(cmd, shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + deployment_uuid = p.stdout.readline().rstrip() + if deployment_uuid == "": + logger.error("Tempest verifier not found.") + raise Exception('Error with command:%s' % cmd) + return deployment_uuid + + +def get_verifier_deployment_id(): + """ + Returns deployment id for active Rally deployment + """ + cmd = ("rally deployment list | awk '/" + + CONST.rally_deployment_name + + "/ {print $2}'") + p = subprocess.Popen(cmd, shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + deployment_uuid = p.stdout.readline().rstrip() + if deployment_uuid == "": + logger.error("Rally deployment not found.") + raise Exception('Error with command:%s' % cmd) + return deployment_uuid + + +def get_verifier_repo_dir(verifier_id): + """ + Returns installed verfier repo directory for Tempest + """ + if not verifier_id: + verifier_id = get_verifier_id() + + return os.path.join(CONST.dir_rally_inst, + 'verification', + 'verifier-{}'.format(verifier_id), + 'repo') + + +def get_verifier_deployment_dir(verifier_id, deployment_id): + """ + Returns Rally deployment directory for current verifier + """ + if not verifier_id: + verifier_id = get_verifier_id() + + if not deployment_id: + deployment_id = get_verifier_deployment_id() + + return os.path.join(CONST.dir_rally_inst, + 'verification', + 'verifier-{}'.format(verifier_id), + 'for-deployment-{}'.format(deployment_id)) + + +def configure_tempest(deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): """ Add/update needed parameters into tempest.conf file generated by Rally """ @@ -110,12 +178,12 @@ def configure_tempest(logger, deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): return releng_constants.EXIT_OK -def configure_tempest_multisite(logger, deployment_dir): +def configure_tempest_multisite(deployment_dir): """ Add/update needed parameters into tempest.conf file generated by Rally """ logger.debug("configure the tempest") - configure_tempest(logger, deployment_dir) + configure_tempest(deployment_dir) logger.debug("Finding tempest.conf file...") tempest_conf_old = os.path.join(deployment_dir, 'tempest.conf') diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 39df766e..2bdbe47f 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -35,74 +35,15 @@ class TempestCommon(testcase_base.TestcaseBase): self.OPTION = "" self.FLAVOR_ID = None self.IMAGE_ID = None - self.VERIFIER_ID = self.get_verifier_id() - self.VERIFIER_REPO_DIR = self.get_verifier_repo_dir() - self.DEPLOYMENT_ID = self.get_verifier_deployment_id() - self.DEPLOYMENT_DIR = self.get_verifier_deployment_dir() + self.VERIFIER_ID = conf_utils.get_verifier_id() + self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir( + self.VERIFIER_ID) + self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id() + self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir( + self.VERIFIER_ID, self.DEPLOYMENT_ID) self.VERIFICATION_ID = None @staticmethod - def get_verifier_id(): - """ - Returns verifer id for current Tempest - """ - cmd = ("rally verify list-verifiers | awk '/" + - CONST.tempest_deployment_name + - "/ {print $2}'") - p = subprocess.Popen(cmd, shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - deployment_uuid = p.stdout.readline().rstrip() - if deployment_uuid == "": - logger.error("Tempest verifier not found.") - raise Exception('Error with command:%s' % cmd) - return deployment_uuid - - @staticmethod - def get_verifier_deployment_id(): - """ - Returns deployment id for active Rally deployment - """ - cmd = ("rally deployment list | awk '/" + - CONST.rally_deployment_name + - "/ {print $2}'") - p = subprocess.Popen(cmd, shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - deployment_uuid = p.stdout.readline().rstrip() - if deployment_uuid == "": - logger.error("Rally deployment not found.") - raise Exception('Error with command:%s' % cmd) - return deployment_uuid - - def get_verifier_repo_dir(self): - """ - Returns installed verfier repo directory for Tempest - """ - if not self.VERIFIER_ID: - self.VERIFIER_ID = self.get_verifier_id() - - return os.path.join(CONST.dir_rally_inst, - 'verification', - 'verifier-{}'.format(self.VERIFIER_ID), - 'repo') - - def get_verifier_deployment_dir(self): - """ - Returns Rally deployment directory for current verifier - """ - if not self.VERIFIER_ID: - self.VERIFIER_ID = self.get_verifier_id() - - if not self.DEPLOYMENT_ID: - self.DEPLOYMENT_ID = self.get_verifier_deployment_id() - - return os.path.join(CONST.dir_rally_inst, - 'verification', - 'verifier-{}'.format(self.VERIFIER_ID), - 'for-deployment-{}'.format(self.DEPLOYMENT_ID)) - - @staticmethod def read_file(filename): with open(filename) as src: return [line.strip() for line in src.readlines()] @@ -321,8 +262,7 @@ class TempestCommon(testcase_base.TestcaseBase): if res != testcase_base.TestcaseBase.EX_OK: return res - res = conf_utils.configure_tempest(logger, - self.DEPLOYMENT_DIR, + res = conf_utils.configure_tempest(self.DEPLOYMENT_DIR, self.IMAGE_ID, self.FLAVOR_ID) if res != testcase_base.TestcaseBase.EX_OK: @@ -375,7 +315,7 @@ class TempestMultisite(TempestCommon): self.case_name = "multisite" self.MODE = "feature_multisite" self.OPTION = "--concurrency 1" - conf_utils.configure_tempest_multisite(logger, self.DEPLOYMENT_DIR) + conf_utils.configure_tempest_multisite(self.DEPLOYMENT_DIR) class TempestCustom(TempestCommon): |