- img_flavor_dict = conf_utils.create_tempest_resources(
- use_custom_images=True, use_custom_flavors=True)
- conf_utils.configure_tempest_defcore(
- self.DEPLOYMENT_DIR, img_flavor_dict)
- self.source_venv()
- res = testcase_base.TestcaseBase.EX_OK
- except KeyError as e:
- logger.error("defcore prepare env error with: %s", e)
- res = testcase_base.TestcaseBase.EX_RUN_ERROR
-
- return res
+ with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
+ "refstack.log"), 'r') as logfile:
+ output = logfile.read()
+
+ for match in re.findall("Ran: (\d+) tests in (\d+\.\d{4}) sec.",
+ output):
+ num_tests = match[0]
+ logger.info("Ran: %s tests in %s sec." % (num_tests, match[1]))
+ for match in re.findall("(- Passed: )(\d+)", output):
+ num_success = match[1]
+ logger.info("".join(match))
+ for match in re.findall("(- Skipped: )(\d+)", output):
+ num_skipped = match[1]
+ logger.info("".join(match))
+ for match in re.findall("(- Failed: )(\d+)", output):
+ num_failures = match[1]
+ logger.info("".join(match))
+ success_testcases = ""
+ for match in re.findall(r"\{0\}(.*?)[. ]*ok", output):
+ success_testcases += match + ", "
+ failed_testcases = ""
+ for match in re.findall(r"\{0\}(.*?)[. ]*FAILED", output):
+ failed_testcases += match + ", "
+ skipped_testcases = ""
+ for match in re.findall(r"\{0\}(.*?)[. ]*SKIPPED:", output):
+ skipped_testcases += match + ", "
+
+ num_executed = int(num_tests) - int(num_skipped)
+
+ try:
+ self.result = 100 * int(num_success) / int(num_executed)
+ except ZeroDivisionError:
+ logger.error("No test has been executed")
+
+ self.details = {"tests": int(num_tests),
+ "failures": int(num_failures),
+ "success": success_testcases,
+ "errors": failed_testcases,
+ "skipped": skipped_testcases}
+ except Exception:
+ self.result = 0
+
+ logger.info("Testcase %s success_rate is %s%%"
+ % (self.case_name, self.result))