def set_case_status(self, status): if self.active_case is None: self.set_active_case("Initialization") self.active_case_execution_status = status CaseDAO.set_case_execution_status(self.active_case_execution_id, status)
def save_script_results(self, script_execution_id, run_id): cases_execution_ids = CaseDAO.get_cases_execution_ids_for_script_execution( script_execution_id) status, passed, total = ScriptDAO.get_script_execution_statistics( script_execution_id) text_status = HtmlFormatter.PASSED if status else HtmlFormatter.FAILED test_script_result = "" for case_execution_id in cases_execution_ids: case_execution_details = CaseDAO.get_case_execution_details( case_execution_id) if case_execution_details.status == ResultStatus.PASSED: li_style = "success" glyphicon = "ok" elif case_execution_details.status in [ ResultStatus.FAILED, ResultStatus.TIMEOUT ]: li_style = "warning" glyphicon = "exclamation-sign" elif case_execution_details.status in [ ResultStatus.BLOCKED, ResultStatus.UNKNOWN ]: li_style = "danger" glyphicon = "remove" else: li_style = "neutral" glyphicon = "minus" test_script_result += "<li class='list-group-item list-item-%s'><a class='report' " \ "href='case_results/%s_case_results.html'><span class='report glyphicon " \ "glyphicon-%s'></span> %s</a></li>" % (li_style, case_execution_details.id, glyphicon, case_execution_details.name) self.save_case_result(case_execution_id, script_execution_id, run_id) result_report = HtmlFormatter.RESULT_SCRIPT_REPORT.format( status=text_status, passed=passed, total=total, test_script_result=test_script_result) script_path = '/'.join( (HtmlFormatter.REPORT_FOLDER, "%s_run_report" % run_id, "%s_script_report" % script_execution_id)) script_html_path = '/'.join( (script_path, "%s_script_report.html" % script_execution_id)) self._check_and_make_path(script_path) parent_lvl = self._parent_level(2) with open(script_html_path, "w") as report: report.write("{header}{resultRunReport}{footer}".format( header=HtmlFormatter.HEADER.format(parent_level=parent_lvl), resultRunReport=result_report, footer=HtmlFormatter.FOOTER.format( version=BuildInformation.BUILD_VERSION, parent_level=parent_lvl)))
def save_script_results(self, script_execution_id, run_id): cases_execution_ids = CaseDAO.get_cases_execution_ids_for_script_execution(script_execution_id) status, passed, total = ScriptDAO.get_script_execution_statistics(script_execution_id) text_status = HtmlFormatter.PASSED if status else HtmlFormatter.FAILED test_script_result = "" for case_execution_id in cases_execution_ids: case_execution_details = CaseDAO.get_case_execution_details(case_execution_id) if case_execution_details.status == ResultStatus.PASSED: li_style = "success" glyphicon = "ok" elif case_execution_details.status in [ResultStatus.FAILED, ResultStatus.TIMEOUT]: li_style = "warning" glyphicon = "exclamation-sign" elif case_execution_details.status in [ResultStatus.BLOCKED, ResultStatus.UNKNOWN]: li_style = "danger" glyphicon = "remove" else: li_style = "neutral" glyphicon = "minus" test_script_result += "<li class='list-group-item list-item-%s'><a class='report' " \ "href='case_results/%s_case_results.html'><span class='report glyphicon " \ "glyphicon-%s'></span> %s</a></li>" % (li_style, case_execution_details.id, glyphicon, case_execution_details.name) self.save_case_result(case_execution_id, script_execution_id, run_id) result_report = HtmlFormatter.RESULT_SCRIPT_REPORT.format(status=text_status, passed=passed, total=total, test_script_result=test_script_result) script_path = '/'.join((HtmlFormatter.REPORT_FOLDER, "%s_run_report" % run_id, "%s_script_report" % script_execution_id)) script_html_path = '/'.join((script_path, "%s_script_report.html" % script_execution_id)) self._check_and_make_path(script_path) parent_lvl = self._parent_level(2) with open(script_html_path, "w") as report: report.write( "{header}{resultRunReport}{footer}".format(header=HtmlFormatter.HEADER.format(parent_level=parent_lvl), resultRunReport=result_report, footer=HtmlFormatter.FOOTER.format( version=BuildInformation.BUILD_VERSION, parent_level=parent_lvl)))
def set_active_case(self, case_name): if self.active_case_execution_id and self.active_case_execution_status in [None, ResultStatus.WAITING, ResultStatus.RUNNING]: self.set_case_status(ResultStatus.UNKNOWN) if self.active_case_execution_id and self.active_case_execution_status in [ResultStatus.TIMEOUT, ResultStatus.FAILED]: self.overall_status = False self.save_current_message() self.active_case = case_name self.active_case_execution_id = CaseDAO.register_case_execution(case_name, self.script_execution_id)
def format_script_results(self, script_execution_id): script_execution = ScriptDAO.get_script_execution_details(script_execution_id) status, passed, total = ScriptDAO.get_script_execution_statistics(script_execution_id) overall_status = ResultStatus.PASSED if status else ResultStatus.FAILED results_header = "Test script{horizontal_separator}{test_script_path}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, test_script_path=script_execution.script_path, vertical_separator=VERTICAL_SEPARATOR) results_header += "Overall status{horizontal_separator}{overall_status}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, overall_status=ColorPrinter.format_status(overall_status), vertical_separator=VERTICAL_SEPARATOR) results_header += "Pass rate{horizontal_separator}{passed}/{total}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, passed=passed, total=total, vertical_separator=VERTICAL_SEPARATOR) results_header += "configuration:{vertical_separator}".format(vertical_separator=VERTICAL_SEPARATOR) for param in script_execution.configuration.split("--"): if not param: continue param_name = param.split(" ")[0] if param_name in [PARAM_USER, PARAM_PASSWORD]: param_value = "**********" else: param_value = "".join(param.split(" ")[1:]) results_header += \ "{horizontal_separator}" \ "{param_name:10}{horizontal_separator}" \ "{param_value}{vertical_separator}" \ .format(vertical_separator=VERTICAL_SEPARATOR, param_name=param_name, param_value=param_value, horizontal_separator=HORIZONTAL_SEPARATOR) results_header += "Level of details -d{level}\n".format(level=self.message_level) results_header += "Reported cases" yield results_header cases_results = (self.format_case_results(case_execution_id) for case_execution_id in CaseDAO.get_cases_execution_ids_for_script_execution(script_execution_id)) yield VERTICAL_SEPARATOR for case_result in cases_results: for line in case_result: yield line yield VERTICAL_SEPARATOR
def format_case_results(self, case_execution_id): case_execution_details = CaseDAO.get_case_execution_details(case_execution_id) results_header = "{horizontal_separator}{horizontal_separator}{horizontal_separator}" \ "{status}{horizontal_separator}" \ "{horizontal_separator}{case_name}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, case_name=case_execution_details.name, status=case_execution_details.status, vertical_separator=VERTICAL_SEPARATOR) yield results_header for messages in self.format_case_messages(case_execution_id): yield messages yield VERTICAL_SEPARATOR
def format_case_results(self, case_execution_id): case_execution_details = CaseDAO.get_case_execution_details( case_execution_id) results_header = "{horizontal_separator}{horizontal_separator}{horizontal_separator}" \ "{status}{horizontal_separator}" \ "{horizontal_separator}{case_name}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, case_name=case_execution_details.name, status=case_execution_details.status, vertical_separator=VERTICAL_SEPARATOR) yield results_header for messages in self.format_case_messages(case_execution_id): yield messages yield VERTICAL_SEPARATOR
def _prepare_test_case_list(self, configuration, run_id, test_case_list): for script in ScriptDAO.get_scripts_execution_ids_for_run(run_id): Case = collections.namedtuple('Case', 'status message response') cases_execution_ids = CaseDAO.get_cases_execution_ids_for_script_execution(script) status, _, _ = ScriptDAO.get_script_execution_statistics(script) configuration = MetadataReportAction.get_configuration_for_test_case(run_id) if 'RedfishMetadata' not in configuration: print('Test report {} is not compatible with Interoperability Report operation.\n' 'You can only include a test case done with Redfish Metadata {}' .format(run_id, MetadataReportAction.REDFISH_CHOICES)) continue self.__get_messages_for_case_execution(Case, cases_execution_ids, self.__get_raw_responses_from_db(), status, test_case_list) return configuration
def format_case_results(self, case_execution_id): case_execution_details = CaseDAO.get_case_execution_details(case_execution_id) results_header = "Test Case: {case_name}{vertical_separator}{vertical_separator}".format( case_name=case_execution_details.name, vertical_separator=VERTICAL_SEPARATOR) results_footer = "{vertical_separator}{horizontal_separator}[{status}]\t{case_name}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, case_name=case_execution_details.name, status=ColorPrinter.format_status(case_execution_details.status), vertical_separator=VERTICAL_SEPARATOR) yield VERTICAL_SEPARATOR yield results_header for messages in self.format_case_messages(case_execution_id): yield messages yield VERTICAL_SEPARATOR yield results_footer yield VERTICAL_SEPARATOR yield CASE_SEPARATOR