Skip to content

Commit cc5f351

Browse files
liamappelbeCommit Queue
authored andcommitted
Revert "[test_runner] Improve timeout deflaking"
This reverts commit f95a84d. Reason for revert: Testing if CL caused increased meta-flakiness of non-timeout failures. Bug: #55044 Original change's description: > [test_runner] Improve timeout deflaking > > The usual deflaking logic is to simply rerun the test 5 times, but if the failure was a timeout this can be very expensive. Instead, only rerun timeout failures twice, and use the last successful run time to set a tighter timeout. > > Repeat counts and timeouts are now per-test. The name, repeat count, and timeout make a `DeflakeInfo`. This object is constructed in compare_results.dart, and passed to test.py's `--tests` flag. The recipe was already passing the output of compare_results directly to that flag, so no change is needed to the recipies. > > Backwards compatibility: > > If you want the old behavior of compare_results.dart, use the `--name-only` flag. > > test.py only uses this new logic if it detects that the `--tests` flag is JSON (if it starts with a `{`). > > Change-Id: I4113b68c54bfb7fd9a5e8fc9dab7a265807f3e77 > Bug: #55044 > Fixes: #55044 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435760 > Commit-Queue: Liam Appelbe <[email protected]> > Reviewed-by: Alexander Thomas <[email protected]> Bug: #55044 Change-Id: I68268dcaffbe857ccec20e211c34325c03643b37 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439180 Commit-Queue: Liam Appelbe <[email protected]> Reviewed-by: Siva Annamalai <[email protected]>
1 parent 2242b2b commit cc5f351

File tree

9 files changed

+15
-99
lines changed

9 files changed

+15
-99
lines changed

pkg/test_runner/bin/compare_results.dart

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// readable mode that explains the results and how they changed.
99

1010
import 'dart:collection';
11-
import 'dart:convert';
1211
import 'dart:io';
1312

1413
import 'package:args/args.dart';
1514
import 'package:test_runner/bot_results.dart';
16-
import 'package:test_runner/src/deflake_info.dart';
1715

1816
class Event {
1917
final Result? before;
@@ -52,18 +50,6 @@ class Event {
5250
throw Exception("Unreachable");
5351
}
5452
}
55-
56-
String deflakeInfo(String name) {
57-
final isTimeout = after.outcome == 'Timeout';
58-
final lastTimeMs = before?.timeMs;
59-
return jsonEncode(DeflakeInfo(
60-
name: name,
61-
repeat: isTimeout ? 2 : 5,
62-
timeout: isTimeout && lastTimeMs != null
63-
? ((2 * lastTimeMs) / 1000).ceil()
64-
: -1,
65-
).toJson());
66-
}
6753
}
6854

6955
class Options {
@@ -84,7 +70,6 @@ class Options {
8470
Iterable<String> get statusFilter => ["passing", "flaky", "failing"]
8571
.where((option) => _options[option] as bool);
8672
bool get unchanged => _options["unchanged"] as bool;
87-
bool get nameOnly => _options["name-only"] as bool;
8873
bool get verbose => _options["verbose"] as bool;
8974
List<String> get rest => _options.rest;
9075
}
@@ -163,10 +148,8 @@ bool search(
163148
"${before?.matches} ${after.matches} "
164149
"${before?.flaked} ${after.flaked}";
165150
}
166-
} else if (options.nameOnly) {
167-
output = name;
168151
} else {
169-
output = event.deflakeInfo(name);
152+
output = name;
170153
}
171154
final log = logs[event.after.key];
172155
final bar = '=' * (output.length + 2);
@@ -208,8 +191,6 @@ void main(List<String> args) async {
208191
abbr: 'u',
209192
negatable: false,
210193
help: "Show only tests with unchanged results.");
211-
parser.addFlag("name-only",
212-
help: "Only show the test names.", negatable: false);
213194
parser.addFlag("verbose",
214195
abbr: "v",
215196
help: "Show the old and new result for each test",

pkg/test_runner/lib/bot_results.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Result {
3030
final bool flaked; // From optional flakiness_data argument to constructor.
3131
final bool? isFlaky; // From results.json after it is extended.
3232
final String? previousOutcome;
33-
final int? timeMs;
3433

3534
Result(
3635
this.configuration,
@@ -41,8 +40,7 @@ class Result {
4140
this.changed,
4241
this.commitHash,
4342
this.isFlaky,
44-
this.previousOutcome,
45-
this.timeMs, {
43+
this.previousOutcome, {
4644
this.flaked = false,
4745
});
4846

@@ -58,7 +56,6 @@ class Result {
5856
commitHash = map["commit_hash"] as String?,
5957
isFlaky = map["flaky"] as bool?,
6058
previousOutcome = map["previous_result"] as String?,
61-
timeMs = map["timeMs"] as int?,
6259
flaked = flakinessData != null &&
6360
(flakinessData["active"] ?? true) == true &&
6461
(flakinessData["outcomes"] as List).contains(map["result"]);

pkg/test_runner/lib/src/configuration.dart

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:smith/configuration.dart';
1111
import 'package:smith/smith.dart';
1212

1313
import 'compiler_configuration.dart';
14-
import 'deflake_info.dart';
1514
import 'feature.dart';
1615
import 'path.dart';
1716
import 'repository.dart';
@@ -32,8 +31,7 @@ class TestConfiguration {
3231
this.selectors = const {},
3332
this.build = false,
3433
this.testList = const [],
35-
this.deflakeInfoMap = const {},
36-
int repeat = 1,
34+
this.repeat = 1,
3735
this.batch = false,
3836
this.copyCoreDumps = false,
3937
this.rr = false,
@@ -76,8 +74,7 @@ class TestConfiguration {
7674
: packages = packages ??
7775
Repository.uri
7876
.resolve('.dart_tool/package_config.json')
79-
.toFilePath(),
80-
_repeat = repeat;
77+
.toFilePath();
8178

8279
final Map<String, RegExp?> selectors;
8380
final Progress progress;
@@ -139,12 +136,11 @@ class TestConfiguration {
139136
final String? dartPrecompiledPath;
140137
final String? genSnapshotPath;
141138
final List<String>? testList;
142-
final Map<String, DeflakeInfo> deflakeInfoMap;
143139

144140
final int taskCount;
145141
final int shardCount;
146142
final int shard;
147-
final int _repeat;
143+
final int repeat;
148144

149145
final int testServerPort;
150146
final int testServerCrossOriginPort;
@@ -225,15 +221,15 @@ class TestConfiguration {
225221
/// build/ReleaseX64
226222
String get buildDirectory => system.outputDirectory + configurationDirectory;
227223

228-
int? _defaultTimeout;
224+
int? _timeout;
229225

230226
// TODO(whesse): Put non-default timeouts explicitly in configs, not this.
231227
/// Calculates a default timeout based on the compiler and runtime used,
232228
/// and the mode, architecture, etc.
233-
int get defaultTimeout {
234-
if (_defaultTimeout == null) {
229+
int get timeout {
230+
if (_timeout == null) {
235231
if (configuration.timeout > 0) {
236-
_defaultTimeout = configuration.timeout;
232+
_timeout = configuration.timeout;
237233
} else {
238234
var isReload = hotReload || hotReloadRollback;
239235

@@ -245,22 +241,13 @@ class TestConfiguration {
245241
arch: architecture,
246242
system: system);
247243

248-
_defaultTimeout = 30 * compilerMultiplier * runtimeMultiplier;
244+
_timeout = 30 * compilerMultiplier * runtimeMultiplier;
249245
}
250246
}
251247

252-
return _defaultTimeout!;
248+
return _timeout!;
253249
}
254250

255-
/// Returns the timeout for the given test name.
256-
int timeout(String name) {
257-
final t = deflakeInfoMap[name]?.timeout ?? -1;
258-
return t >= 0 ? t : defaultTimeout;
259-
}
260-
261-
/// Returns the repeat count for the given test name.
262-
int repeat(String name) => deflakeInfoMap[name]?.repeat ?? _repeat;
263-
264251
List<String> get standardOptions {
265252
if (compiler != Compiler.dart2js) {
266253
return const ["--ignore-unrecognized-flags"];

pkg/test_runner/lib/src/deflake_info.dart

Lines changed: 0 additions & 25 deletions
This file was deleted.

pkg/test_runner/lib/src/options.dart

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:args/args.dart';
1111
import 'package:path/path.dart' as path;
1212

1313
import 'configuration.dart';
14-
import 'deflake_info.dart';
1514
import 'path.dart';
1615
import 'repository.dart';
1716
import 'test_configurations.dart';
@@ -627,17 +626,12 @@ has been specified on the command line.''')
627626

628627
void addConfiguration(Configuration innerConfiguration,
629628
[String? namedConfiguration]) {
630-
631-
final (testList, deflakeInfoMap) = parseTestList(
632-
data["test-list-contents"] as List<String>?);
633-
634629
var configuration = TestConfiguration(
635630
configuration: innerConfiguration,
636631
progress: progress,
637632
selectors: _expandSelectors(data),
638633
build: data["build"] as bool,
639-
testList: testList,
640-
deflakeInfoMap: deflakeInfoMap ?? const {},
634+
testList: data["test-list-contents"] as List<String>?,
641635
repeat: int.parse(data["repeat"] as String),
642636
batch: !(data["no-batch"] as bool),
643637
copyCoreDumps: data["copy-coredumps"] as bool,
@@ -1015,16 +1009,3 @@ final Map<String, String> sanitizerEnvironmentVariables = (() {
10151009

10161010
return environment;
10171011
})();
1018-
1019-
(List<String>?, Map<String, DeflakeInfo>?) parseTestList(List<String>? raw) {
1020-
final isJson = raw != null && raw.isNotEmpty && raw[0].startsWith('{');
1021-
if (!isJson) return (raw, null);
1022-
final deflakes = <DeflakeInfo>[
1023-
for (var line in raw)
1024-
DeflakeInfo.fromJson(jsonDecode(line) as Map<dynamic, dynamic>),
1025-
];
1026-
return (
1027-
[ for (var i in deflakes) i.name ],
1028-
{ for (var i in deflakes) i.name: i },
1029-
);
1030-
}

pkg/test_runner/lib/src/process_queue.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class TestCaseEnqueuer {
253253
/// test completing successfully, just on it completing.
254254
void _add(TestCase testCase) {
255255
Node<Command>? lastNode;
256-
for (var i = 0; i < testCase.repeat; ++i) {
256+
for (var i = 0; i < testCase.configuration.repeat; ++i) {
257257
if (i > 0) {
258258
testCase = testCase.indexedCopy(i);
259259
}

pkg/test_runner/lib/src/test_case.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class TestCase {
133133
}
134134

135135
int get timeout {
136-
var result = configuration.timeout(displayName);
136+
var result = configuration.timeout;
137137
if (expectedOutcomes.contains(Expectation.slow)) {
138138
result *= _slowTimeoutMultiplier;
139139
} else if (expectedOutcomes.contains(Expectation.extraSlow)) {
@@ -142,8 +142,6 @@ class TestCase {
142142
return result;
143143
}
144144

145-
int get repeat => configuration.repeat(displayName);
146-
147145
String get configurationString {
148146
var compiler = configuration.compiler.name;
149147
var runtime = configuration.runtime.name;

pkg/test_runner/lib/test_runner.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ Future<void> deflake(Directory outDirectory, List<String> configurations,
577577
// Find the list of tests to deflake.
578578
var deflakeListOutput = await runProcess(Platform.resolvedExecutable, [
579579
"tools/bots/compare_results.dart",
580-
"--name-only",
581580
"--changed",
582581
"--failing",
583582
"--passing",

pkg/test_runner/test/compare_results/compare_results_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ Result _result(
197197
String commitHash = 'abcdabcd',
198198
bool flaked = false,
199199
bool isFlaky = false,
200-
String previousOutcome = 'Pass',
201-
int timeMs = -1}) {
200+
String previousOutcome = 'Pass'}) {
202201
return Result(
203202
configuration,
204203
name,
@@ -209,7 +208,6 @@ Result _result(
209208
commitHash,
210209
isFlaky,
211210
previousOutcome,
212-
timeMs,
213211
flaked: flaked,
214212
);
215213
}

0 commit comments

Comments
 (0)