diff options
Diffstat (limited to 'functest/opnfv_tests/openstack/tempest/tempest.py')
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 96 |
1 files changed, 24 insertions, 72 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 0014b718..9c19a147 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()] @@ -297,10 +238,23 @@ class TempestCommon(testcase_base.TestcaseBase): num_success = new_line[2] elif 'Skipped' in new_line: num_skipped = new_line[2] + elif 'Failures' in new_line: + num_failures = new_line[2] try: num_executed = int(num_tests) - int(num_skipped) success_rate = 100 * int(num_success) / int(num_executed) + with open(os.path.join(conf_utils.TEMPEST_RESULTS_DIR, + "tempest.log"), 'r') as logfile: + output = logfile.read() + + error_logs = "" + for match in re.findall('(.*?)[. ]*FAILED', output): + error_logs += match + + self.details = {"tests": int(num_tests), + "failures": int(num_failures), + "errors": error_logs} except Exception: success_rate = 0 @@ -321,8 +275,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: @@ -341,10 +294,9 @@ class TempestCommon(testcase_base.TestcaseBase): self.stop_time = time.time() - if self.criteria == "PASS": - return testcase_base.TestcaseBase.EX_OK - else: - return testcase_base.TestcaseBase.EX_TESTCASE_FAILED + # If we are here, it means that the test case was successfully executed + # criteria is managed by the criteria Field + return testcase_base.TestcaseBase.EX_OK class TempestSmokeSerial(TempestCommon): @@ -380,7 +332,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): |