Commit 307af4ab authored by David Grogan's avatar David Grogan Committed by Commit Bot

[run_web_tests] Add option to run virtual tests in parallel

This reduced the local runtime of virtual/layout_ng_flex_box from 2m22s
down to 0m18s. I had previously been jumping through hoops locally to
not run the virtual suite at all.

Change-Id: Idf4ba1c6cf6d7fc43d5873b873c7eb8be313e474
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1999185
Commit-Queue: David Grogan <dgrogan@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731765}
parent 533f9128
...@@ -105,6 +105,7 @@ class WebTestRunner(object): ...@@ -105,6 +105,7 @@ class WebTestRunner(object):
test_inputs, test_inputs,
int(self._options.child_processes), int(self._options.child_processes),
self._options.fully_parallel, self._options.fully_parallel,
self._options.virtual_parallel,
batch_size == 1) batch_size == 1)
self._reorder_tests_by_args(locked_shards) self._reorder_tests_by_args(locked_shards)
...@@ -376,7 +377,7 @@ class Sharder(object): ...@@ -376,7 +377,7 @@ class Sharder(object):
self._split = test_split_fn self._split = test_split_fn
self._max_locked_shards = max_locked_shards self._max_locked_shards = max_locked_shards
def shard_tests(self, test_inputs, num_workers, fully_parallel, run_singly): def shard_tests(self, test_inputs, num_workers, fully_parallel, parallel_includes_virtual, run_singly):
"""Groups tests into batches. """Groups tests into batches.
This helps ensure that tests that depend on each other (aka bad tests!) This helps ensure that tests that depend on each other (aka bad tests!)
continue to run together as most cross-tests dependencies tend to continue to run together as most cross-tests dependencies tend to
...@@ -392,7 +393,7 @@ class Sharder(object): ...@@ -392,7 +393,7 @@ class Sharder(object):
if num_workers == 1: if num_workers == 1:
return self._shard_in_two(test_inputs) return self._shard_in_two(test_inputs)
elif fully_parallel: elif fully_parallel:
return self._shard_every_file(test_inputs, run_singly) return self._shard_every_file(test_inputs, run_singly, parallel_includes_virtual)
return self._shard_by_directory(test_inputs) return self._shard_by_directory(test_inputs)
def _shard_in_two(self, test_inputs): def _shard_in_two(self, test_inputs):
...@@ -417,7 +418,7 @@ class Sharder(object): ...@@ -417,7 +418,7 @@ class Sharder(object):
return locked_shards, unlocked_shards return locked_shards, unlocked_shards
def _shard_every_file(self, test_inputs, run_singly): def _shard_every_file(self, test_inputs, run_singly, virtual_is_unlocked):
"""Returns two lists of shards, each shard containing a single test file. """Returns two lists of shards, each shard containing a single test file.
This mode gets maximal parallelism at the cost of much higher flakiness. This mode gets maximal parallelism at the cost of much higher flakiness.
...@@ -432,7 +433,7 @@ class Sharder(object): ...@@ -432,7 +433,7 @@ class Sharder(object):
# which would be really redundant. # which would be really redundant.
if test_input.requires_lock: if test_input.requires_lock:
locked_shards.append(TestShard('.', [test_input])) locked_shards.append(TestShard('.', [test_input]))
elif test_input.test_name.startswith('virtual') and not run_singly: elif test_input.test_name.startswith('virtual') and not run_singly and not virtual_is_unlocked:
# This violates the spirit of sharding every file, but in practice, since the # This violates the spirit of sharding every file, but in practice, since the
# virtual test suites require a different commandline flag and thus a restart # virtual test suites require a different commandline flag and thus a restart
# of content_shell, it's too slow to shard them fully. # of content_shell, it's too slow to shard them fully.
......
...@@ -185,7 +185,7 @@ class SharderTests(unittest.TestCase): ...@@ -185,7 +185,7 @@ class SharderTests(unittest.TestCase):
self.sharder = Sharder(port.split_test, max_locked_shards) self.sharder = Sharder(port.split_test, max_locked_shards)
test_list = test_list or self.test_list test_list = test_list or self.test_list
return self.sharder.shard_tests([self.get_test_input(test) for test in test_list], return self.sharder.shard_tests([self.get_test_input(test) for test in test_list],
num_workers, fully_parallel, run_singly) num_workers, fully_parallel, False, run_singly)
def assert_shards(self, actual_shards, expected_shard_names): def assert_shards(self, actual_shards, expected_shard_names):
self.assertEqual(len(actual_shards), len(expected_shard_names)) self.assertEqual(len(actual_shards), len(expected_shard_names))
......
...@@ -480,6 +480,11 @@ def parse_args(args): ...@@ -480,6 +480,11 @@ def parse_args(args):
'-f', '--fully-parallel', '-f', '--fully-parallel',
action='store_true', action='store_true',
help='run all tests in parallel'), help='run all tests in parallel'),
optparse.make_option(
'--virtual-parallel',
action='store_true',
help='When running in parallel, include virtual tests. Useful for running a single '
'virtual test suite, but will be slower in other cases.'),
optparse.make_option( optparse.make_option(
'-i', '--ignore-tests', '-i', '--ignore-tests',
action='append', action='append',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment