def save_artifacts(self): if not self.failed_workers: return vardir = Options().args.vardir artifacts_dir = os.path.join(vardir, 'artifacts') artifacts_log_dir = os.path.join(artifacts_dir, 'log') artifacts_reproduce_dir = os.path.join(artifacts_dir, 'reproduce') safe_makedirs(artifacts_dir) safe_makedirs(artifacts_log_dir) safe_makedirs(artifacts_reproduce_dir) for worker_name in self.failed_workers: logfile = self.get_logfile(worker_name) reproduce_file_path = get_reproduce_file(worker_name) shutil.copy( logfile, os.path.join(artifacts_log_dir, os.path.basename(logfile))) shutil.copy( reproduce_file_path, os.path.join(artifacts_reproduce_dir, os.path.basename(reproduce_file_path))) shutil.copytree(os.path.join(vardir, worker_name), os.path.join(artifacts_dir, worker_name), ignore=shutil.ignore_patterns( '*.socket-iproto', '*.socket-admin', '*.sock', '*.control')) shutil.copytree(os.path.join(vardir, 'statistics'), os.path.join(artifacts_dir, 'statistics'))
def print_statistics(self): """Print statistics and results of testing.""" # Prepare standalone subpath '<vardir>/statistics' for statistics files. stats_dir = os.path.join(Options().args.vardir, 'statistics') safe_makedirs(stats_dir) self.print_rss_summary(stats_dir) self.print_duration(stats_dir) if self.stats: color_stdout('Statistics:\n', schema='test_var') for short_status, cnt in self.stats.items(): color_stdout('* %s: %d\n' % (short_status, cnt), schema='test_var') if not self.failed_tasks: return False color_stdout('Failed tasks:\n', schema='test_var') for task_id, worker_name, result_checksum, show_reproduce_content in self.failed_tasks: logfile = self.get_logfile(worker_name) task_id_str = yaml.safe_dump(task_id, default_flow_style=True) color_stdout('- %s' % task_id_str, schema='test_var') color_stdout('# results file checksum: %s\n' % result_checksum) color_stdout('# logfile: %s\n' % logfile) reproduce_file_path = get_reproduce_file(worker_name) color_stdout('# reproduce file: %s\n' % reproduce_file_path) if show_reproduce_content: color_stdout("---\n", schema='separator') print_tail_n(reproduce_file_path) color_stdout("...\n", schema='separator') return True
def print_statistics(self): """Returns are there failed tasks.""" if self.stats: color_stdout('Statistics:\n', schema='test_var') for short_status, cnt in self.stats.items(): color_stdout('* %s: %d\n' % (short_status, cnt), schema='test_var') if not self.failed_tasks: return False color_stdout('Failed tasks:\n', schema='test_var') for task_id, worker_name in self.failed_tasks: logfile = self.get_logfile(worker_name) reproduce_file = get_reproduce_file(worker_name) color_stdout('- %s' % yaml.safe_dump(task_id), schema='test_var') color_stdout('# logfile: %s\n' % logfile) color_stdout('# reproduce file: %s\n' % reproduce_file) return True
def main_loop_consistent(failed_test_ids): # find and prepare all tasks/groups, print information task_groups = get_task_groups().items() print_greetings() for name, task_group in task_groups: # print information about current test suite color_stdout("\n", '=' * 80, "\n", schema='separator') color_stdout("TEST".ljust(48), schema='t_name') color_stdout("PARAMS".ljust(16), schema='test_var') color_stdout("RESULT\n", schema='test_pass') color_stdout('-' * 75, "\n", schema='separator') task_ids = task_group['task_ids'] show_reproduce_content = task_group['show_reproduce_content'] if not task_ids: continue worker_id = 1 worker = task_group['gen_worker'](worker_id) for task_id in task_ids: short_status = worker.run_task(task_id) if short_status == 'fail': reproduce_file_path = \ get_reproduce_file(worker.name) color_stdout('Reproduce file %s\n' % reproduce_file_path, schema='error') if show_reproduce_content: color_stdout("---\n", schema='separator') print_tail_n(reproduce_file_path) color_stdout("...\n", schema='separator') failed_test_ids.append(task_id) if not Options().args.is_force: worker.stop_server(cleanup=False) return color_stdout('-' * 75, "\n", schema='separator') worker.stop_server(silent=False) color_stdout()
def print_statistics(self): """Returns are there failed tasks.""" if self.stats: color_stdout('Statistics:\n', schema='test_var') for short_status, cnt in self.stats.items(): color_stdout('* %s: %d\n' % (short_status, cnt), schema='test_var') if not self.failed_tasks: return False color_stdout('Failed tasks:\n', schema='test_var') for task_id, worker_name, show_reproduce_content in self.failed_tasks: logfile = self.get_logfile(worker_name) color_stdout('- %s' % yaml.safe_dump(task_id), schema='test_var') color_stdout('# logfile: %s\n' % logfile) reproduce_file_path = get_reproduce_file(worker_name) color_stdout('# reproduce file: %s\n' % reproduce_file_path) if show_reproduce_content: color_stdout("---\n", schema='separator') lib.utils.print_tail_n(reproduce_file_path) color_stdout("...\n", schema='separator') return True