Changeset 84591 in webkit


Ignore:
Timestamp:
Apr 21, 2011 7:48:49 PM (13 years ago)
Author:
dpranke@chromium.org
Message:

2011-04-21 Dirk Pranke <dpranke@chromium.org>

Reviewed by Tony Chang.

new-run-webkit-tests: obsolete old threading code, part 2
https://bugs.webkit.org/show_bug.cgi?id=58753

This merges the test_runner2 code back into test_runner since
there's only a single type of test runner now.

  • Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
  • Scripts/webkitpy/layout_tests/layout_package/test_runner2.py: Removed.
  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:
Location:
trunk/Tools
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r84589 r84591  
     12011-04-21  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        new-run-webkit-tests: obsolete old threading code, part 2
     6        https://bugs.webkit.org/show_bug.cgi?id=58753
     7
     8        This merges the test_runner2 code back into test_runner since
     9        there's only a single type of test runner now.
     10
     11        * Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
     12        * Scripts/webkitpy/layout_tests/layout_package/test_runner2.py: Removed.
     13        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     14
    1152011-04-21  Maciej Stachowiak  <mjs@apple.com>
    216
  • trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py

    r84568 r84591  
    4949from webkitpy.layout_tests.layout_package import json_layout_results_generator
    5050from webkitpy.layout_tests.layout_package import json_results_generator
     51from webkitpy.layout_tests.layout_package import manager_worker_broker
    5152from webkitpy.layout_tests.layout_package import printing
    5253from webkitpy.layout_tests.layout_package import test_expectations
     
    5455from webkitpy.layout_tests.layout_package import test_results
    5556from webkitpy.layout_tests.layout_package import test_results_uploader
     57from webkitpy.layout_tests.layout_package import worker
     58
    5659from webkitpy.layout_tests.layout_package.result_summary import ResultSummary
    5760from webkitpy.layout_tests.layout_package.test_input import TestInput
     
    6063from webkitpy.tool import grammar
    6164
    62 _log = logging.getLogger("webkitpy.layout_tests.run_webkit_tests")
     65_log = logging.getLogger(__name__)
    6366
    6467# Builder base URL where we have the archived test results.
     
    234237        self._retrying = False
    235238        self._results_directory = self._port.results_directory()
     239
     240        self._all_results = []
     241        self._group_stats = {}
     242        self._current_result_summary = None
     243
     244        # This maps worker names to the state we are tracking for each of them.
     245        self._worker_states = {}
     246
    236247
    237248    def collect_tests(self, args, last_unexpected_results):
     
    568579            result_summary: summary object to populate with the results
    569580        """
    570         raise NotImplementedError()
     581        self._current_result_summary = result_summary
     582        self._all_results = []
     583        self._group_stats = {}
     584        self._worker_states = {}
     585
     586        keyboard_interrupted = False
     587        interrupted = False
     588        thread_timings = []
     589
     590        self._printer.print_update('Sharding tests ...')
     591        test_lists = self._shard_tests(file_list,
     592            int(self._options.child_processes) > 1 and not self._options.experimental_fully_parallel)
     593
     594        num_workers = self._num_workers(len(test_lists))
     595        manager_connection = manager_worker_broker.get(self._port, self._options,
     596                                                       self, worker.Worker)
     597
     598        if self._options.dry_run:
     599            return (keyboard_interrupted, interrupted, thread_timings,
     600                    self._group_stats, self._all_results)
     601
     602        self._printer.print_update('Starting %s ...' %
     603                                   grammar.pluralize('worker', num_workers))
     604        for worker_number in xrange(num_workers):
     605            worker_connection = manager_connection.start_worker(worker_number)
     606            worker_state = _WorkerState(worker_number, worker_connection)
     607            self._worker_states[worker_connection.name] = worker_state
     608
     609            # FIXME: If we start workers up too quickly, DumpRenderTree appears
     610            # to thrash on something and time out its first few tests. Until
     611            # we can figure out what's going on, sleep a bit in between
     612            # workers.
     613            time.sleep(0.1)
     614
     615        self._printer.print_update("Starting testing ...")
     616        for test_list in test_lists:
     617            manager_connection.post_message('test_list', test_list[0], test_list[1])
     618
     619        # We post one 'stop' message for each worker. Because the stop message
     620        # are sent after all of the tests, and because each worker will stop
     621        # reading messsages after receiving a stop, we can be sure each
     622        # worker will get a stop message and hence they will all shut down.
     623        for i in xrange(num_workers):
     624            manager_connection.post_message('stop')
     625
     626        try:
     627            while not self.is_done():
     628                # We loop with a timeout in order to be able to detect wedged threads.
     629                manager_connection.run_message_loop(delay_secs=1.0)
     630
     631            if any(worker_state.wedged for worker_state in self._worker_states.values()):
     632                _log.error('')
     633                _log.error('Remaining workers are wedged, bailing out.')
     634                _log.error('')
     635            else:
     636                _log.debug('No wedged threads')
     637
     638            # Make sure all of the workers have shut down (if possible).
     639            for worker_state in self._worker_states.values():
     640                if not worker_state.wedged and worker_state.worker_connection.is_alive():
     641                    worker_state.worker_connection.join(0.5)
     642                    assert not worker_state.worker_connection.is_alive()
     643
     644        except KeyboardInterrupt:
     645            _log.info("Interrupted, exiting")
     646            self.cancel_workers()
     647            keyboard_interrupted = True
     648        except TestRunInterruptedException, e:
     649            _log.info(e.reason)
     650            self.cancel_workers()
     651            interrupted = True
     652        except:
     653            # Unexpected exception; don't try to clean up workers.
     654            _log.info("Exception raised, exiting")
     655            raise
     656
     657        thread_timings = [worker_state.stats for worker_state in self._worker_states.values()]
     658
     659        # FIXME: should this be a class instead of a tuple?
     660        return (interrupted, keyboard_interrupted, thread_timings,
     661                self._group_stats, self._all_results)
    571662
    572663    def update(self):
     
    11371228        results_filename = self._fs.join(self._results_directory, "results.html")
    11381229        self._port.show_results_html_file(results_filename)
     1230
     1231    def name(self):
     1232        return 'TestRunner'
     1233
     1234    def is_done(self):
     1235        worker_states = self._worker_states.values()
     1236        return worker_states and all(self._worker_is_done(worker_state) for worker_state in worker_states)
     1237
     1238    def _worker_is_done(self, worker_state):
     1239        t = time.time()
     1240        if worker_state.done or worker_state.wedged:
     1241            return True
     1242
     1243        next_timeout = worker_state.next_timeout
     1244        WEDGE_PADDING = 40.0
     1245        if next_timeout and t > next_timeout + WEDGE_PADDING:
     1246            _log.error('')
     1247            worker_state.worker_connection.log_wedged_worker(worker_state.current_test_name)
     1248            _log.error('')
     1249            worker_state.wedged = True
     1250            return True
     1251        return False
     1252
     1253    def cancel_workers(self):
     1254        for worker_state in self._worker_states.values():
     1255            worker_state.worker_connection.cancel()
     1256
     1257    def handle_started_test(self, source, test_info, hang_timeout):
     1258        worker_state = self._worker_states[source]
     1259        worker_state.current_test_name = self._port.relative_test_filename(test_info.filename)
     1260        worker_state.next_timeout = time.time() + hang_timeout
     1261
     1262    def handle_done(self, source):
     1263        worker_state = self._worker_states[source]
     1264        worker_state.done = True
     1265
     1266    def handle_exception(self, source, exception_info):
     1267        exception_type, exception_value, exception_traceback = exception_info
     1268        raise exception_type, exception_value, exception_traceback
     1269
     1270    def handle_finished_list(self, source, list_name, num_tests, elapsed_time):
     1271        self._group_stats[list_name] = (num_tests, elapsed_time)
     1272
     1273    def handle_finished_test(self, source, result, elapsed_time):
     1274        worker_state = self._worker_states[source]
     1275        worker_state.next_timeout = None
     1276        worker_state.current_test_name = None
     1277        worker_state.stats['total_time'] += elapsed_time
     1278        worker_state.stats['num_tests'] += 1
     1279
     1280        if worker_state.wedged:
     1281            # This shouldn't happen if we have our timeouts tuned properly.
     1282            _log.error("%s unwedged", source)
     1283
     1284        self._all_results.append(result)
     1285        self._update_summary_with_result(self._current_result_summary, result)
    11391286
    11401287
     
    11541301            raise
    11551302    return tests
     1303
     1304
     1305class _WorkerState(object):
     1306    """A class for the TestRunner/manager to use to track the current state
     1307    of the workers."""
     1308    def __init__(self, number, worker_connection):
     1309        self.worker_connection = worker_connection
     1310        self.number = number
     1311        self.done = False
     1312        self.current_test_name = None
     1313        self.next_timeout = None
     1314        self.wedged = False
     1315        self.stats = {}
     1316        self.stats['name'] = worker_connection.name
     1317        self.stats['num_tests'] = 0
     1318        self.stats['total_time'] = 0
     1319
     1320    def __repr__(self):
     1321        return "_WorkerState(" + str(self.__dict__) + ")"
  • trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r84210 r84591  
    4141from layout_package import printing
    4242from layout_package import test_runner
    43 from layout_package import test_runner2
    4443
    4544from webkitpy.common.system import user
     
    9089    num_unexpected_results = -1
    9190    try:
    92         runner = test_runner2.TestRunner2(port, options, printer)
     91        runner = test_runner.TestRunner(port, options, printer)
    9392        runner._print_config()
    9493
Note: See TracChangeset for help on using the changeset viewer.