def save_results(self, run_id): status, passed, total = RunDAO.get_overall_run_result(run_id) text_status = HtmlFormatter.PASSED if status else HtmlFormatter.FAILED script_execution_ids = ScriptDAO.get_scripts_execution_ids_for_run( run_id) test_scripts_result = "" for script_execution_id in script_execution_ids: script_execution_details = ScriptDAO.get_script_execution_details( script_execution_id) self.save_script_results(script_execution_id, run_id) overall, passed, total = ScriptDAO.get_script_execution_statistics( script_execution_id) if passed == total: li_style = "success" glyphicon = "ok" elif overall: li_style = "warning" glyphicon = "exclamation-sign" else: li_style = "danger" glyphicon = "remove" test_scripts_result += "<li class='list-group-item list-item-%s'><a class='report' " \ "href='%s_script_report/%s_script_report.html'><span class='report glyphicon " \ "glyphicon-%s'></span> %s</a></li>" % ( li_style, script_execution_details.id, script_execution_details.id, glyphicon, script_execution_details.script_path) result_report = HtmlFormatter.RESULT_RUN_REPORT.format( status=text_status, passed=passed, total=total, test_script_result=test_scripts_result) case_results_dir = '/'.join( (HtmlFormatter.REPORT_FOLDER, "%s_run_report" % run_id)) case_results_html = '/'.join( (case_results_dir, "%s_run_report.html" % run_id)) self._check_and_make_path(case_results_dir) parent_lvl = self._parent_level(1) with open(case_results_html, "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 process_action(self, configuration): test_runs = RunDAO.list_all_runs() print "Run ID\tDate\n" for test_run in test_runs: print "%s\n[%s]\t%s\n\n\t%s\n" % ("-"*89, test_run.id, test_run.run_datetime, to_multiline(test_run.cmd, 80, '\\\n\t')) for script_execution_id in ScriptDAO.get_scripts_execution_ids_for_run(test_run.id): script_execution = ScriptDAO.get_script_execution_details(script_execution_id) cmd = "\t[id=%d]\n\t%s execute %s" % (script_execution_id, script_execution.script_path, script_execution.configuration) print to_multiline(cmd, 80, ' \\\n\t') print '\n\n'
def get_overall_run_result(run_id, database_session): """ :type run_id: int :rtype: bool """ overall_status = True total = 0 passed = 0 for script_id in ScriptDAO.get_scripts_execution_ids_for_run(run_id): total += 1 status, _, _ = ScriptDAO.get_script_execution_statistics(script_id) overall_status = overall_status and status if status: passed += 1 return overall_status, passed, total
def get_overall_run_result(run_id, database_session): """ :type run_id: int :rtype: bool """ overall_status = True total = 0 passed = 0 for script_id in ScriptDAO.get_scripts_execution_ids_for_run(run_id): total += 1 status, _, _ = ScriptDAO.get_script_execution_statistics(script_id) overall_status = overall_status and status if status: passed += 1 return overall_status, passed, total
def print_results(self, run_id): run_details = RunDAO.get_run_details(run_id) results_header = "Test run ID{horizontal_separator} #{run_id}""".format( horizontal_separator=HORIZONTAL_SEPARATOR, run_id=run_details.id) print "CTS version\t%s\n%s%s" % (BuildInformation.BUILD_VERSION, results_header, VERTICAL_SEPARATOR) script_executions_results = (self.format_script_results(script_execution_id) for script_execution_id in ScriptDAO.get_scripts_execution_ids_for_run(run_id)) for script_results in script_executions_results: for line in script_results: # replace comma to dot to avoid conflict in opening CSV format and drop empty line if line is not VERTICAL_SEPARATOR: sys.stdout.write(line.replace(',', '.')) print VERTICAL_SEPARATOR
def process_action(self, configuration): test_runs = RunDAO.list_all_runs() print "Run ID\tDate\n" for test_run in test_runs: print "%s\n[%s]\t%s\n\n\t%s\n" % ( "-" * 89, test_run.id, test_run.run_datetime, to_multiline(test_run.cmd, 80, '\\\n\t')) for script_execution_id in ScriptDAO.get_scripts_execution_ids_for_run( test_run.id): script_execution = ScriptDAO.get_script_execution_details( script_execution_id) cmd = "\t[id=%d]\n\t%s execute %s" % ( script_execution_id, script_execution.script_path, script_execution.configuration) print to_multiline(cmd, 80, ' \\\n\t') print '\n\n'
def save_results(self, run_id): status, passed, total = RunDAO.get_overall_run_result(run_id) text_status = HtmlFormatter.PASSED if status else HtmlFormatter.FAILED script_execution_ids = ScriptDAO.get_scripts_execution_ids_for_run(run_id) test_scripts_result = "" for script_execution_id in script_execution_ids: script_execution_details = ScriptDAO.get_script_execution_details(script_execution_id) self.save_script_results(script_execution_id, run_id) overall, passed, total = ScriptDAO.get_script_execution_statistics(script_execution_id) if passed == total: li_style = "success" glyphicon = "ok" elif overall: li_style = "warning" glyphicon = "exclamation-sign" else: li_style = "danger" glyphicon = "remove" test_scripts_result += "<li class='list-group-item list-item-%s'><a class='report' " \ "href='%s_script_report/%s_script_report.html'><span class='report glyphicon " \ "glyphicon-%s'></span> %s</a></li>" % ( li_style, script_execution_details.id, script_execution_details.id, glyphicon, script_execution_details.script_path) result_report = HtmlFormatter.RESULT_RUN_REPORT.format(status=text_status, passed=passed, total=total, test_script_result=test_scripts_result) case_results_dir = '/'.join((HtmlFormatter.REPORT_FOLDER, "%s_run_report" % run_id)) case_results_html = '/'.join((case_results_dir, "%s_run_report.html" % run_id)) self._check_and_make_path(case_results_dir) parent_lvl = self._parent_level(1) with open(case_results_html, "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 print_results(self, run_id): run_details = RunDAO.get_run_details(run_id) results_header = "Test run ID{horizontal_separator} #{run_id}" "".format( horizontal_separator=HORIZONTAL_SEPARATOR, run_id=run_details.id) print "CTS version\t%s\n%s%s" % (BuildInformation.get_version(), results_header, VERTICAL_SEPARATOR) script_executions_results = ( self.format_script_results(script_execution_id) for script_execution_id in ScriptDAO.get_scripts_execution_ids_for_run(run_id)) for script_results in script_executions_results: for line in script_results: # replace comma to dot to avoid conflict in opening CSV format and drop empty line if line is not VERTICAL_SEPARATOR: sys.stdout.write(line.replace(',', '.')) print VERTICAL_SEPARATOR
def print_results(self, run_id): run_details = RunDAO.get_run_details(run_id) results_header = "Test run ID{horizontal_separator} #{run_id}""".format( horizontal_separator=HORIZONTAL_SEPARATOR, run_id=run_details.id) print "CTS version\t%s\n%s%s" % (BuildInformation.BUILD_VERSION, results_header, VERTICAL_SEPARATOR) script_executions_results = (self.format_script_results(script_execution_id) for script_execution_id in ScriptDAO.get_scripts_execution_ids_for_run(run_id)) lines = [] for script_results in script_executions_results: for line in script_results: sys.stdout.write(line) lines.append(line) print VERTICAL_SEPARATOR lines.append(VERTICAL_SEPARATOR) return lines
def print_results(self, run_id): run_details = RunDAO.get_run_details(run_id) results_header = "Test run ID{horizontal_separator} #{run_id}""".format( horizontal_separator=HORIZONTAL_SEPARATOR, run_id=run_details.id) print "CTS version\t%s\n%s%s" % (BuildInformation.get_version(), results_header, VERTICAL_SEPARATOR) script_executions_results = (self.format_script_results(script_execution_id) for script_execution_id in ScriptDAO.get_scripts_execution_ids_for_run(run_id)) lines = [] for script_results in script_executions_results: for line in script_results: sys.stdout.write(line) lines.append(line) print VERTICAL_SEPARATOR lines.append(VERTICAL_SEPARATOR) return lines
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 _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