def make_broker(manager, worker_model, start_queue=None, stop_queue=None): global starting_queue global stopping_queue starting_queue = start_queue stopping_queue = stop_queue options = get_options(worker_model) return manager_worker_broker.get(port.get("test"), options, manager, _TestWorker)
def make_broker(manager, worker_model, start_queue=None, stop_queue=None): global starting_queue global stopping_queue starting_queue = start_queue stopping_queue = stop_queue options = get_options(worker_model) return manager_worker_broker.get(port.get("test"), options, manager, _TestWorker)
def _run_tests(self, file_list, result_summary): """Runs the tests in the file_list. Return: A tuple (keyboard_interrupted, thread_timings, test_timings, individual_test_timings) keyboard_interrupted is whether someone typed Ctrl^C thread_timings is a list of dicts with the total runtime of each thread with 'name', 'num_tests', 'total_time' properties test_timings is a list of timings for each sharded subdirectory of the form [time, directory_name, num_tests] individual_test_timings is a list of run times for each test in the form {filename:filename, test_run_time:test_run_time} result_summary: summary object to populate with the results """ self._current_result_summary = result_summary self._all_results = [] self._group_stats = {} self._worker_states = {} num_workers = self._num_workers() keyboard_interrupted = False interrupted = False thread_timings = [] self._printer.print_update('Sharding tests ...') test_lists = self._shard_tests(file_list, num_workers > 1 and not self._options.experimental_fully_parallel) _log.debug("Using %d shards" % len(test_lists)) manager_connection = manager_worker_broker.get(self._port, self._options, self, worker.Worker) if self._options.dry_run: return (keyboard_interrupted, interrupted, thread_timings, self._group_stats, self._all_results) self._printer.print_update('Starting %s ...' % grammar.pluralize('worker', num_workers)) for worker_number in xrange(num_workers): worker_connection = manager_connection.start_worker(worker_number) worker_state = _WorkerState(worker_number, worker_connection) self._worker_states[worker_connection.name] = worker_state # FIXME: If we start workers up too quickly, DumpRenderTree appears # to thrash on something and time out its first few tests. Until # we can figure out what's going on, sleep a bit in between # workers. time.sleep(0.1) self._printer.print_update("Starting testing ...") for test_list in test_lists: manager_connection.post_message('test_list', test_list[0], test_list[1]) # We post one 'stop' message for each worker. Because the stop message # are sent after all of the tests, and because each worker will stop # reading messsages after receiving a stop, we can be sure each # worker will get a stop message and hence they will all shut down. for i in xrange(num_workers): manager_connection.post_message('stop') try: while not self.is_done(): # We loop with a timeout in order to be able to detect wedged threads. manager_connection.run_message_loop(delay_secs=1.0) if any(worker_state.wedged for worker_state in self._worker_states.values()): _log.error('') _log.error('Remaining workers are wedged, bailing out.') _log.error('') else: _log.debug('No wedged threads') # Make sure all of the workers have shut down (if possible). for worker_state in self._worker_states.values(): if not worker_state.wedged and worker_state.worker_connection.is_alive(): worker_state.worker_connection.join(0.5) assert not worker_state.worker_connection.is_alive() except KeyboardInterrupt: _log.info("Interrupted, exiting") self._cancel_workers() keyboard_interrupted = True except test_runner.TestRunInterruptedException, e: _log.info(e.reason) self._cancel_workers() interrupted = True
def _run_tests(self, file_list, result_summary): """Runs the tests in the file_list. Return: A tuple (interrupted, keyboard_interrupted, thread_timings, test_timings, individual_test_timings) interrupted is whether the run was interrupted keyboard_interrupted is whether someone typed Ctrl^C thread_timings is a list of dicts with the total runtime of each thread with 'name', 'num_tests', 'total_time' properties test_timings is a list of timings for each sharded subdirectory of the form [time, directory_name, num_tests] individual_test_timings is a list of run times for each test in the form {filename:filename, test_run_time:test_run_time} result_summary: summary object to populate with the results """ self._current_result_summary = result_summary self._all_results = [] self._group_stats = {} self._worker_states = {} num_workers = self._num_workers() keyboard_interrupted = False interrupted = False thread_timings = [] self._printer.print_update('Sharding tests ...') test_lists = self._shard_tests( file_list, num_workers > 1 and not self._options.experimental_fully_parallel) _log.debug("Using %d shards" % len(test_lists)) manager_connection = manager_worker_broker.get(self._port, self._options, self, worker.Worker) if self._options.dry_run: return (keyboard_interrupted, interrupted, thread_timings, self._group_stats, self._all_results) self._printer.print_update('Starting %s ...' % grammar.pluralize('worker', num_workers)) for worker_number in xrange(num_workers): worker_connection = manager_connection.start_worker(worker_number) worker_state = _WorkerState(worker_number, worker_connection) self._worker_states[worker_connection.name] = worker_state # FIXME: If we start workers up too quickly, DumpRenderTree appears # to thrash on something and time out its first few tests. Until # we can figure out what's going on, sleep a bit in between # workers. time.sleep(0.1) self._printer.print_update("Starting testing ...") for test_list in test_lists: manager_connection.post_message('test_list', test_list[0], test_list[1]) # We post one 'stop' message for each worker. Because the stop message # are sent after all of the tests, and because each worker will stop # reading messsages after receiving a stop, we can be sure each # worker will get a stop message and hence they will all shut down. for i in xrange(num_workers): manager_connection.post_message('stop') try: while not self.is_done(): # We loop with a timeout in order to be able to detect wedged threads. manager_connection.run_message_loop(delay_secs=1.0) if any(worker_state.wedged for worker_state in self._worker_states.values()): _log.error('') _log.error('Remaining workers are wedged, bailing out.') _log.error('') else: _log.debug('No wedged threads') # Make sure all of the workers have shut down (if possible). for worker_state in self._worker_states.values(): if not worker_state.wedged and worker_state.worker_connection.is_alive( ): worker_state.worker_connection.join(0.5) assert not worker_state.worker_connection.is_alive() except KeyboardInterrupt: _log.info("Interrupted, exiting") self.cancel_workers() keyboard_interrupted = True except test_runner.TestRunInterruptedException, e: _log.info(e.reason) self.cancel_workers() interrupted = True