Unverified Commit c3a47b34 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Remove more timeouts (#63433)

parent a2e5e074
...@@ -30,30 +30,6 @@ import 'test_compiler.dart'; ...@@ -30,30 +30,6 @@ import 'test_compiler.dart';
import 'test_config.dart'; import 'test_config.dart';
import 'watcher.dart'; import 'watcher.dart';
/// The timeout we give the test process to connect to the test harness
/// once the process has entered its main method.
///
/// We time out test execution because we expect some tests to hang and we want
/// to know which test hung, rather than have the entire test harness just do
/// nothing for a few hours until the user (or CI environment) gets bored.
const Duration _kTestStartupTimeout = Duration(minutes: 5);
/// The timeout we give the test process to start executing Dart code. When the
/// CPU is under severe load, this can take a while, but it's not indicative of
/// any problem with Flutter, so we give it a large timeout.
///
/// See comment under [_kTestStartupTimeout] regarding timeouts.
const Duration _kTestProcessTimeout = Duration(minutes: 5);
/// Message logged by the test process to signal that its main method has begun
/// execution.
///
/// The test harness responds by starting the [_kTestStartupTimeout] countdown.
/// The CPU may be throttled, which can cause a long delay in between when the
/// process is spawned and when dart code execution begins; we don't want to
/// hold that against the test.
const String _kStartTimeoutTimerMessage = 'sky_shell test process has entered main method';
/// The address at which our WebSocket server resides and at which the sky_shell /// The address at which our WebSocket server resides and at which the sky_shell
/// processes will host the Observatory server. /// processes will host the Observatory server.
final Map<InternetAddressType, InternetAddress> _kHosts = <InternetAddressType, InternetAddress>{ final Map<InternetAddressType, InternetAddress> _kHosts = <InternetAddressType, InternetAddress>{
...@@ -213,7 +189,6 @@ void catchIsolateErrors() { ...@@ -213,7 +189,6 @@ void catchIsolateErrors() {
void main() { void main() {
print('$_kStartTimeoutTimerMessage');
String serverPort = Platform.environment['SERVER_PORT'] ?? ''; String serverPort = Platform.environment['SERVER_PORT'] ?? '';
String server = Uri.decodeComponent('$encodedWebsocketUrl:\$serverPort'); String server = Uri.decodeComponent('$encodedWebsocketUrl:\$serverPort');
StreamChannel<dynamic> channel = serializeSuite(() { StreamChannel<dynamic> channel = serializeSuite(() {
...@@ -243,7 +218,7 @@ void main() { ...@@ -243,7 +218,7 @@ void main() {
return buffer.toString(); return buffer.toString();
} }
enum InitialResult { crashed, timedOut, connected } enum InitialResult { crashed, connected }
enum TestResult { crashed, harnessBailed, testBailed } enum TestResult { crashed, harnessBailed, testBailed }
...@@ -507,7 +482,6 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -507,7 +482,6 @@ class FlutterPlatform extends PlatformPlugin {
} }
}); });
final Completer<void> timeout = Completer<void>();
final Completer<void> gotProcessObservatoryUri = Completer<void>(); final Completer<void> gotProcessObservatoryUri = Completer<void>();
if (!enableObservatory) { if (!enableObservatory) {
gotProcessObservatoryUri.complete(); gotProcessObservatoryUri.complete();
...@@ -543,10 +517,6 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -543,10 +517,6 @@ class FlutterPlatform extends PlatformPlugin {
watcher?.handleStartedProcess( watcher?.handleStartedProcess(
ProcessEvent(ourTestCount, process, processObservatoryUri)); ProcessEvent(ourTestCount, process, processObservatoryUri));
}, },
startTimeoutTimer: () {
Future<InitialResult>.delayed(_kTestStartupTimeout)
.then<void>((_) => timeout.complete());
},
); );
// At this point, three things can happen next: // At this point, three things can happen next:
...@@ -556,8 +526,6 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -556,8 +526,6 @@ class FlutterPlatform extends PlatformPlugin {
globals.printTrace('test $ourTestCount: awaiting initial result for pid ${process.pid}'); globals.printTrace('test $ourTestCount: awaiting initial result for pid ${process.pid}');
final InitialResult initialResult = await Future.any<InitialResult>(<Future<InitialResult>>[ final InitialResult initialResult = await Future.any<InitialResult>(<Future<InitialResult>>[
process.exitCode.then<InitialResult>((int exitCode) => InitialResult.crashed), process.exitCode.then<InitialResult>((int exitCode) => InitialResult.crashed),
timeout.future.then<InitialResult>((void value) => InitialResult.timedOut),
Future<InitialResult>.delayed(_kTestProcessTimeout, () => InitialResult.timedOut),
gotProcessObservatoryUri.future.then<InitialResult>((void value) { gotProcessObservatoryUri.future.then<InitialResult>((void value) {
return webSocket.future.then<InitialResult>( return webSocket.future.then<InitialResult>(
(WebSocket webSocket) => InitialResult.connected, (WebSocket webSocket) => InitialResult.connected,
...@@ -582,20 +550,6 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -582,20 +550,6 @@ class FlutterPlatform extends PlatformPlugin {
await controller.sink.done; await controller.sink.done;
await watcher?.handleTestCrashed(ProcessEvent(ourTestCount, process)); await watcher?.handleTestCrashed(ProcessEvent(ourTestCount, process));
break; break;
case InitialResult.timedOut:
// Could happen either if the process takes a long time starting
// (_kTestProcessTimeout), or if once Dart code starts running, it takes a
// long time to open the WebSocket connection (_kTestStartupTimeout).
globals.printTrace('test $ourTestCount: timed out waiting for process with pid ${process.pid} to connect to test harness');
final String message = _getErrorMessage('Test never connected to test harness.', testPath, shellPath);
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
unawaited(controller.sink.close());
globals.printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
await watcher
?.handleTestTimedOut(ProcessEvent(ourTestCount, process));
break;
case InitialResult.connected: case InitialResult.connected:
globals.printTrace('test $ourTestCount: process with pid ${process.pid} connected to test harness'); globals.printTrace('test $ourTestCount: process with pid ${process.pid} connected to test harness');
final WebSocket testSocket = await webSocket.future; final WebSocket testSocket = await webSocket.future;
...@@ -875,7 +829,6 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -875,7 +829,6 @@ class FlutterPlatform extends PlatformPlugin {
void _pipeStandardStreamsToConsole( void _pipeStandardStreamsToConsole(
Process process, { Process process, {
void startTimeoutTimer(),
Future<void> reportObservatoryUri(Uri uri), Future<void> reportObservatoryUri(Uri uri),
}) { }) {
...@@ -889,11 +842,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -889,11 +842,7 @@ class FlutterPlatform extends PlatformPlugin {
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen( .listen(
(String line) async { (String line) async {
if (line == _kStartTimeoutTimerMessage) { if (line.startsWith("error: Unable to read Dart source 'package:test/")) {
if (startTimeoutTimer != null) {
startTimeoutTimer();
}
} else if (line.startsWith("error: Unable to read Dart source 'package:test/")) {
globals.printTrace('Shell: $line'); globals.printTrace('Shell: $line');
globals.printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n'); globals.printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n');
} else if (line.startsWith(observatoryString)) { } else if (line.startsWith(observatoryString)) {
......
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