def _test(self, tests, batch_size, max_heavy): # Set up a simple processing pipeline: # Loader -> observe results -> sequencer -> execution. loader = LoadProc(iter(tests)) results = FakeResultObserver() sequence_proc = SequenceProc(max_heavy) execution = FakeExecutionProc() loader.connect_to(results) results.connect_to(sequence_proc) sequence_proc.connect_to(execution) # Fill the execution queue (with the number of tests potentially # executed in parallel). loader.load_initial_tests(batch_size) # Simulate the execution test by test. while execution.tests: # Assert the invariant of maximum heavy tests executed simultaneously. self.assertLessEqual( sum(int(test.is_heavy) for test in execution.tests), max_heavy) # As in the real pipeline, running a test and returning its result # will add another test into the pipeline. execution.run() # Ensure that all tests are processed and deliver results. self.assertEqual(set(test.n for test in tests), results.tests)
def _create_sequence_proc(self, options): """Create processor for sequencing heavy tests on swarming.""" return SequenceProc( options.max_heavy_tests) if options.swarming else None
def test_wrong_usage(self): with self.assertRaises(Exception): SequenceProc(0)
def test_wrong_usage(self): self.assertRaises(lambda: SequenceProc(0))
def _do_execute(self, tests, args, options): jobs = options.j print('>>> Running with test processors') loader = LoadProc(tests) results = self._create_result_tracker(options) indicators = self._create_progress_indicators( tests.test_count_estimate, options) outproc_factory = None if self.build_config.predictable: outproc_factory = predictable.get_outproc execproc = ExecutionProc(jobs, outproc_factory) sigproc = self._create_signal_proc() procs = [ loader, NameFilterProc(args) if args else None, StatusFileFilterProc(options.slow_tests, options.pass_fail_tests), VariantProc(self._variants), StatusFileFilterProc(options.slow_tests, options.pass_fail_tests), self._create_predictable_filter(), self._create_shard_proc(options), self._create_seed_proc(options), SequenceProc(options.max_heavy_tests), sigproc, ] + indicators + [ results, self._create_timeout_proc(options), self._create_rerun_proc(options), execproc, ] self._prepare_procs(procs) loader.load_initial_tests(initial_batch_size=options.j * 2) # This starts up worker processes and blocks until all tests are # processed. execproc.run() for indicator in indicators: indicator.finished() if tests.test_count_estimate: percentage = float(results.total) / tests.test_count_estimate * 100 else: percentage = 0 print(('>>> %d base tests produced %d (%d%s)' ' non-filtered tests') % (tests.test_count_estimate, results.total, percentage, '%')) print('>>> %d tests ran' % (results.total - results.remaining)) exit_code = utils.EXIT_CODE_PASS if results.failed: exit_code = utils.EXIT_CODE_FAILURES if not results.total: exit_code = utils.EXIT_CODE_NO_TESTS if options.time: self._print_durations(options) # Indicate if a SIGINT or SIGTERM happened. return max(exit_code, sigproc.exit_code)