Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 | 8 |
| 9 // NOTE: This test tries to ensure that an HttpClient will close it's | 9 // NOTE: This test tries to ensure that an HttpClient will close it's |
| 10 // underlying idle connections after [HttpClient.idleTimeout]. | 10 // underlying idle connections after [HttpClient.idleTimeout]. |
| 11 // | 11 // |
| 12 // The main script spawns a server and a subprocess which does a connection back | 12 // The main script spawns a server and a subprocess which does a connection back |
| 13 // to it. | 13 // to it. |
| 14 // The subprocess is expected to shut down it's idle sockets after | 14 // The subprocess is expected to shut down it's idle sockets after |
| 15 // [HttpClient.idleTimeout] and the main script will assert that this happens | 15 // [HttpClient.idleTimeout] and the main script will assert that this happens |
| 16 // within +/- 2 <= seconds. | 16 // within +/- 2 <= seconds. |
| 17 | 17 |
| 18 const SECONDS = 4; | 18 const SECONDS = 4; |
| 19 | 19 |
| 20 void runServerProcess() { | 20 void runServerProcess() { |
| 21 asyncStart(); | 21 asyncStart(); |
| 22 HttpServer.bind('127.0.0.1', 0).then((server) { | 22 HttpServer.bind('127.0.0.1', 0).then((server) async { |
| 23 var url = 'http://127.0.0.1:${server.port}/'; | 23 var url = 'http://127.0.0.1:${server.port}/'; |
| 24 | 24 |
| 25 server.idleTimeout = const Duration(hours: 1); | 25 server.idleTimeout = const Duration(hours: 1); |
| 26 | 26 |
| 27 var subscription = server.listen((HttpRequest request) { | 27 var subscription = server.listen((HttpRequest request) { |
| 28 return request.response..write('hello world')..close(); | 28 return request.response..write('hello world')..close(); |
| 29 }); | 29 }); |
| 30 | 30 |
| 31 var sw = new Stopwatch()..start(); | 31 var sw = new Stopwatch()..start(); |
| 32 var arguments = ['--package-root=${Platform.packageRoot}', | 32 var arguments = ['--package-root=${(await Platform.packageRoot).toFilePath() }', |
|
Lasse Reichstein Nielsen
2015/09/22 09:48:25
Long line.
.toFilePath() -> ?.toFilePath()
| |
| 33 '${Platform.script}', | 33 '${Platform.script}', |
| 34 url]; | 34 url]; |
| 35 Process.run(Platform.executable, arguments).then((res) { | 35 Process.run(Platform.executable, arguments).then((res) { |
| 36 subscription.cancel(); | 36 subscription.cancel(); |
| 37 if (res.exitCode != 0) { | 37 if (res.exitCode != 0) { |
| 38 throw "Child exited with ${res.exitCode} instead of 0. " | 38 throw "Child exited with ${res.exitCode} instead of 0. " |
| 39 "(stdout: ${res.stdout}, stderr: ${res.stderr})"; | 39 "(stdout: ${res.stdout}, stderr: ${res.stderr})"; |
| 40 } | 40 } |
| 41 var seconds = sw.elapsed.inSeconds; | 41 var seconds = sw.elapsed.inSeconds; |
| 42 // NOTE: There is a slight chance this will cause flakiness, but there is | 42 // NOTE: There is a slight chance this will cause flakiness, but there is |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 66 .then((_) => print('drained client request')); | 66 .then((_) => print('drained client request')); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void main(List<String> args) { | 69 void main(List<String> args) { |
| 70 if (args.length == 1) { | 70 if (args.length == 1) { |
| 71 runClientProcess(args.first); | 71 runClientProcess(args.first); |
| 72 } else { | 72 } else { |
| 73 runServerProcess(); | 73 runServerProcess(); |
| 74 } | 74 } |
| 75 } | 75 } |
| OLD | NEW |