Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: lib/src/runner/configuration.dart

Issue 1890853003: Add support for sharding test runs. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/runner.dart ('k') | lib/src/runner/configuration/args.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/configuration.dart
diff --git a/lib/src/runner/configuration.dart b/lib/src/runner/configuration.dart
index bf21b0932a4f8888e37fd34ecb344bc013958e47..5f9689a8ebdb37d609bfbc431d670ef4ef5ede3c 100644
--- a/lib/src/runner/configuration.dart
+++ b/lib/src/runner/configuration.dart
@@ -92,6 +92,27 @@ class Configuration {
pauseAfterLoad ? 1 : (_concurrency ?? defaultConcurrency);
final int _concurrency;
+ /// The index of the current shard, if sharding is in use, or `null` if it's
+ /// not.
+ ///
+ /// Sharding is a technique that allows the Google internal test framework to
+ /// easily split a test run across multiple workers without requiring the
+ /// tests to be modified by the user. When sharding is in use, the runner gets
+ /// a shard index (this field) and a total number of shards, and is expected
+ /// to provide the following guarantees:
+ ///
+ /// * Running the same invocation of the runner, with the same shard index and
+ /// total shards, will run the same set of tests.
+ /// * Across all shards, each test must be run exactly once.
+ ///
+ /// In addition, tests should be balanced across shards as much as possible.
+ final int shardIndex;
+
+ /// The total number of shards, if sharding is in use, or `null` if it's not.
+ ///
+ /// See [shardIndex] for details.
+ final int totalShards;
+
/// The paths from which to load tests.
List<String> get paths => _paths ?? ["test"];
final List<String> _paths;
@@ -249,6 +270,8 @@ class Configuration {
String reporter,
int pubServePort,
int concurrency,
+ int shardIndex,
+ int totalShards,
Timeout timeout,
Iterable<Pattern> patterns,
Iterable<TestPlatform> platforms,
@@ -275,6 +298,8 @@ class Configuration {
reporter: reporter,
pubServePort: pubServePort,
concurrency: concurrency,
+ shardIndex: shardIndex,
+ totalShards: totalShards,
timeout: timeout,
patterns: patterns,
platforms: platforms,
@@ -339,6 +364,8 @@ class Configuration {
String reporter,
int pubServePort,
int concurrency,
+ this.shardIndex,
+ this.totalShards,
Timeout timeout,
Iterable<Pattern> patterns,
Iterable<TestPlatform> platforms,
@@ -385,6 +412,14 @@ class Configuration {
"filename's context must match the current operating system, was "
"${_filename.context.style}.");
}
+
+ if ((shardIndex == null) != (totalShards == null)) {
+ throw new ArgumentError(
+ "shardIndex and totalShards may only be passed together.");
+ } else if (shardIndex != null) {
+ RangeError.checkValueInInterval(
+ shardIndex, 0, totalShards - 1, "shardIndex");
+ }
}
/// Returns a [input] as an unmodifiable list or `null`.
@@ -427,6 +462,8 @@ class Configuration {
reporter: other._reporter ?? _reporter,
pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port,
concurrency: other._concurrency ?? _concurrency,
+ shardIndex: other.shardIndex ?? shardIndex,
+ totalShards: other.totalShards ?? totalShards,
timeout: timeout.merge(other.timeout),
patterns: patterns.union(other.patterns),
platforms: other._platforms ?? _platforms,
@@ -464,6 +501,8 @@ class Configuration {
String reporter,
int pubServePort,
int concurrency,
+ int shardIndex,
+ int totalShards,
Timeout timeout,
Iterable<Pattern> patterns,
Iterable<TestPlatform> platforms,
@@ -490,6 +529,8 @@ class Configuration {
reporter: reporter ?? _reporter,
pubServePort: pubServePort ?? pubServeUrl?.port,
concurrency: concurrency ?? _concurrency,
+ shardIndex: shardIndex ?? this.shardIndex,
+ totalShards: totalShards ?? this.totalShards,
timeout: timeout ?? this.timeout,
patterns: patterns ?? this.patterns,
platforms: platforms ?? _platforms,
« no previous file with comments | « lib/src/runner.dart ('k') | lib/src/runner/configuration/args.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698