def run_all(self): """For each file in the test suite, run client program assuming each file represents an individual test.""" if not self.tests: # noting to test, exit return [] self.server.deploy(silent=False) if self.args.start_and_exit: color_stdout(" Start and exit requested, exiting...\n", schema='info') exit(0) longsep = '=' * 70 shortsep = '-' * 60 color_stdout(longsep, "\n", schema='separator') color_stdout("TEST".ljust(48), schema='t_name') color_stdout("RESULT\n", schema='test_pass') color_stdout(shortsep, "\n", schema='separator') failed_tests = [] try: for test in self.tests: color_stdout(test.name.ljust(48), schema='t_name') # for better diagnostics in case of a long-running test test_name = os.path.basename(test.name) if (test_name in self.ini["disabled"] or not self.server.debug and test_name in self.ini["release_disabled"] or self.args.valgrind and test_name in self.ini["valgrind_disabled"]): color_stdout("[ disabled ]\n", schema='t_name') else: test.run(self.server) if not test.passed(): failed_tests.append(test.name) color_stdout(shortsep, "\n", schema='separator') self.server.stop(silent=False) except (KeyboardInterrupt) as e: color_stdout("\n%s\n" % shortsep, schema='separator') self.server.stop(silent=False) raise finally: self.server.cleanup() if failed_tests: color_stdout("Failed {0} tests: {1}.\n".format( len(failed_tests), ", ".join(failed_tests)), schema='error') if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): color_stdout(shortsep, "\n", schema='separator') color_stdout( " Error! There were warnings/errors in valgrind log file:\n", schema='error') print_tail_n(self.server.valgrind_log, 20) color_stdout(shortsep, "\n", schema='separator') return ['valgrind error in ' + self.suite_path] return failed_tests
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 run_all(self): """For each file in the test suite, run client program assuming each file represents an individual test.""" if not self.tests: # noting to test, exit return [] self.server.deploy(silent=False) if self.args.start_and_exit: color_stdout(" Start and exit requested, exiting...\n", schema='info') exit(0) longsep = '='*70 shortsep = '-'*60 color_stdout(longsep, "\n", schema='separator') color_stdout("TEST".ljust(48), schema='t_name') color_stdout("RESULT\n", schema='test_pass') color_stdout(shortsep, "\n", schema='separator') failed_tests = [] try: for test in self.tests: color_stdout(test.name.ljust(48), schema='t_name') # for better diagnostics in case of a long-running test test_name = os.path.basename(test.name) if (test_name in self.ini["disabled"] or not self.server.debug and test_name in self.ini["release_disabled"] or self.args.valgrind and test_name in self.ini["valgrind_disabled"]): color_stdout("[ disabled ]\n", schema='t_name') else: test.run(self.server) if not test.passed(): failed_tests.append(test.name) color_stdout(shortsep, "\n", schema='separator') self.server.stop(silent=False) self.server.cleanup() except (KeyboardInterrupt) as e: color_stdout('\n') color_stdout(shortsep, "\n", schema='separator') self.server.stop(silent=False) self.server.cleanup() raise if failed_tests: color_stdout("Failed {0} tests: {1}.\n".format(len(failed_tests), ", ".join(failed_tests)), schema='error') if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): color_stdout(shortsep, "\n", schema='separator') color_stdout(" Error! There were warnings/errors in valgrind log file:\n", schema='error') print_tail_n(self.server.valgrind_log, 20) color_stdout(shortsep, "\n", schema='separator') return ['valgrind error in ' + self.suite_path] return failed_tests
def print_log(self, lines=None): msg = '\n{prefix} of Tarantool Log file [Instance "{instance}"][{logfile}]:\n'.format( prefix="Last {0} lines".format(lines) if lines else "Output", instance=self.name, logfile=self.logfile or 'null') color_stdout(msg, schema='error') if os.path.exists(self.logfile): print_tail_n(self.logfile, lines) else: color_stdout(" Can't find log:\n", schema='error')
def print_log(self, lines=None): msg = ('\n{prefix} of Tarantool Log file [Instance "{instance}"]' + '[{logfile}]:\n').format(prefix="Last {0} lines".format(lines) if lines else "Output", instance=self.name, logfile=self.logfile or 'null') color_stdout(msg, schema='error') if os.path.exists(self.logfile): print_tail_n(self.logfile, lines) else: color_stdout(" Can't find log:\n", schema='error')
def crash_grep(self): if self.process.returncode < 0 or \ not non_empty_valgrind_logs([self.valgrind_log]): super(ValgrindMixin, self).crash_grep() return lines_cnt = 50 color_stdout('\n\nValgrind for [Instance "%s"] returns non-zero exit code: %d\n' % ( self.name, self.process.returncode), schema='error') color_stdout("It's known that it can be valgrind's \"the 'impossible' happened\" error\n", schema='error') color_stdout('Last %d lines of valgring log file [%s]:\n' % ( lines_cnt, self.valgrind_log), schema='error') print_tail_n(self.valgrind_log, 50)
def crash_grep(self): if self.process.returncode < 0 or \ not non_empty_valgrind_logs([self.valgrind_log]): super(ValgrindMixin, self).crash_grep() return lines_cnt = 50 color_stdout('\n\nValgrind for [Instance "%s"] returns non-zero exit code: %d\n' % ( self.name, self.process.returncode), schema='error') color_stdout("It's known that it can be valgrind's \"the 'impossible' happened\" error\n", schema='error') color_stdout('Last %d lines of valgring log file [%s]:\n' % ( lines_cnt, self.valgrind_log), schema='error') print_tail_n(self.valgrind_log, lines_cnt)
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_diagnostics(self, logfile, message): """Print 10 lines of client program output leading to test failure. Used to diagnose a failure of the client program""" color_stdout(message, schema='error') print_tail_n(logfile, 10)
def run_all(self): """For each file in the test suite, run client program assuming each file represents an individual test.""" if not self.tests: # noting to test, exit return [] # fixme: remove this string if we fix all legacy tests self.server.cls = self.tests[0].__class__ # create inspectpor daemon for cluster tests inspector = TarantoolInspector('localhost', self.server.inspector_port) inspector.start() self.server.deploy(silent=False) longsep = '=' * 80 shortsep = '-' * 75 color_stdout(longsep, "\n", schema='separator') color_stdout("TEST".ljust(48), schema='t_name') color_stdout("PARAMS\t\t", schema='test_var') color_stdout("RESULT\n", schema='test_pass') color_stdout(shortsep, "\n", schema='separator') failed_tests = [] try: for test in self.tests: test.inspector = inspector color_stdout(os.path.join(self.ini['suite'], os.path.basename( test.name)).ljust(48), schema='t_name') # for better diagnostics in case of a long-running test conf = '' if test.run_params: conf = test.conf_name color_stdout("%s" % conf.ljust(16), schema='test_var') test_name = os.path.basename(test.name) if (test_name in self.ini["disabled"] or not self.server.debug and test_name in self.ini["release_disabled"] or self.args.valgrind and test_name in self.ini["valgrind_disabled"] or not self.args.long and test_name in self.ini.get("long_run", [])): color_stdout("[ disabled ]\n", schema='t_name') else: test.run(self.server) if not test.passed(): failed_tests.append(test.name) color_stdout(shortsep, "\n", schema='separator') self.server.stop(silent=False) # don't delete core files or state of the data dir # in case of exception, which is raised when the # server crashes inspector.stop() self.server.cleanup() except KeyboardInterrupt: color_stdout("\n%s\n" % shortsep, schema='separator') self.server.stop(silent=False) raise if failed_tests: color_stdout("Failed {0} tests: {1}.\n".format( len(failed_tests), ", ".join(failed_tests)), schema='error') if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): color_stdout(shortsep, "\n", schema='separator') color_stdout( " Error! There were warnings/errors in valgrind log file:\n", schema='error') print_tail_n(self.server.valgrind_log, 20) color_stdout(shortsep, "\n", schema='separator') return ['valgrind error in ' + self.suite_path] return failed_tests