def setup(self): self._print_step_title('Start opereto test listener..') if not os.path.exists(self.input['test_results_path']): make_directory(self.input['test_results_path']) self.op_state = { 'test_suite_final_status': 'success', 'test_results_path': self.input['test_results_path'], 'test_data': {}, 'suite_links': [] } self._save_state(self.op_state)
def parser_suite(suite): if int(suite.errors) > 0 or int(suite.failures) > 0: self.suite_status = 'failure' for case in suite: summary = '' status = None result = case.result if not result: status = 'success' elif result._tag in ['failure', 'error']: status = result._tag summary = result.message if status: testname = case.name testcase_dict = { 'testname': testname, 'title': testname, 'status': status } stdout = case.system_out stderr = case.system_err # classname = case.classname #duration = case.time self.tests['test_records'].append(testcase_dict) def _modify_output_file(file, data): with open(file, 'w') as of: of.write(data) ## create directory structure if summary or stdout or stderr: make_directory(self.dest_path) make_directory( os.path.join(self.dest_path, testname)) if summary: summary_file = os.path.join( self.dest_path, testname, 'summary.txt') _modify_output_file(summary_file, summary) if stdout: stdout_file = os.path.join( self.dest_path, testname, 'stdout.log') _modify_output_file(stdout_file, stdout) if stderr: stderr_file = os.path.join( self.dest_path, testname, 'stderr.log') _modify_output_file(stderr_file, stderr)
def setup(self): self.parent_pid = self.input['opereto_parent_flow_id'] or self.input[ 'pid'] self.debug_mode = self.input['debug_mode'] self.listener_pid = None self.parser_pid = None self.listener_results_dir = os.path.join( self.input['opereto_workspace'], 'opereto_listener_results') self.host_test_result_directory = os.path.join( self.input['opereto_workspace'], 'opereto_parser_results') if self.input['test_parser_config']: make_directory(self.host_test_result_directory) self.valid_exit_codes = [0] if self.client.input['valid_exit_codes']: codes = self.client.input['valid_exit_codes'].split(',') self.valid_exit_codes = [] for code in codes: self.valid_exit_codes.append(int(code)) self._setup() self._run_service_set(self.input['pre_task_services'])
def setup(self): make_directory(self.parser_results_directory) make_directory(self.listener_results_dir) self._setup() self._run_service_set(self.input['pre_task_services'])
def setup(self): if not os.path.exists(self.input['test_results_path']): make_directory(self.input['test_results_path']) self.remove_test_results_dir = True
def __init__(self, source_path, dest_path): self.source_path = source_path self.dest_path = dest_path self.tests = {'test_records': []} make_directory(self.dest_path)
def parser_suite(suite): def _modify_output_file(file, data): with open(file, 'w') as of: of.write(data) test_records = collections.OrderedDict() if debug_mode: props = { "name": suite.name, "time": suite.time, "timestamp": suite.timestamp, "tests": suite.tests, "failures": suite.failures, "errors": suite.errors, "skipped": suite.skipped } print('DEBUG: {}'.format(props)) if int(suite.tests) > 0: self.suite_status = 'success' if int(suite.failures) > 0: self.suite_status = 'failure' if int(suite.errors) > 0: self.suite_status = 'error' def _escape_name(name): return re.sub('[^0-9A-Za-z-_]+', '-', name).lower() for case in suite: if case.classname: testname = _escape_name(case.classname) else: testname = _escape_name(case.name) summary = '' result = case.result status = 'success' if result: status = result._tag if status in ['failure', 'error']: status = result._tag else: status = 'warning' try: summary = '{}<BR>{}'.format( result.message, result._elem.text) except: try: summary = '{}'.format(result.message) except: summary = '' stdout = case.system_out stderr = case.system_err if testname not in test_records: test_dict = { 'testname': testname, 'title': testname, 'status': status } test_records[testname] = test_dict if testname not in self.tests_data: self.tests_data[testname] = [] if summary or stdout or stderr: make_directory(os.path.join(self.dest_path, testname)) self.tests_data[testname].append({ 'name': case.name, 'stdout': stdout, 'stderr': stderr, 'summary': summary, 'duration': str(case.time), 'status': status }) self.tests['test_records'] = list(test_records.values()) for tn, cases in self.tests_data.items(): tn_summary = '' tn_log_data = '' for case in cases: if case['summary']: tn_summary += '<b>{}</b><BR>{}<BR>'.format( case['name'], case['summary']) if case['stdout'] or case['stderr']: if case['status'] == 'success': tn_log_data += self._print_testcase( case['name'], '#0075EA') elif case['status'] in ['failure', 'error']: tn_log_data += self._print_testcase( case['name'], '#EF5000') else: tn_log_data += self._print_testcase( case['name'], '#333333') if case['stdout']: tn_log_data += '{}\n'.format(case['stdout']) if case['stderr']: tn_log_data += '{}\n'.format(case['stderr']) if case['status'] == 'failure' and test_records[tn][ 'status'] != 'error': test_records[tn]['status'] = 'failure' if case['status'] == 'error': test_records[tn]['status'] = 'error' if tn_summary: summary_file = os.path.join(self.dest_path, tn, 'summary.txt') _modify_output_file(summary_file, tn_summary) if tn_log_data: stdout_file = os.path.join(self.dest_path, tn, 'stdout.log') _modify_output_file(stdout_file, tn_log_data)