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

Unified Diff: tests/standalone/io/web_socket_test.dart

Issue 11946042: Speed up web_socket_test by running subtests in parallel. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove pipelining and Futures. Created 7 years, 11 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 | « tests/standalone/io/web_socket_no_secure_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_test.dart
diff --git a/tests/standalone/io/web_socket_test.dart b/tests/standalone/io/web_socket_test.dart
index f53f18f2a2ce3deff0f62b3e49ea08e7329c77cd..6f9a0236471dcce17cd55727fb1527ae8b225641 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -15,9 +15,9 @@ const HOST_NAME = "localhost";
// We will run the tests once over HTTP and once over HTTPS.
bool secure = false;
-Future testRequestResponseClientCloses(
+void testRequestResponseClientCloses(
int totalConnections, int closeStatus, String closeReason) {
- Completer done = new Completer();
+ ReceivePort keepAlive = new ReceivePort();
Anders Johnsen 2013/01/17 14:17:33 The ReceivePorts are redundant in some of these te
HttpServer server = secure ? new HttpsServer() : new HttpServer();
Anders Johnsen 2013/01/17 14:17:33 Move all of this out to a createServer(); ditto
HttpClient client = new HttpClient();
@@ -66,17 +66,16 @@ Future testRequestResponseClientCloses(
if (closeCount == totalConnections) {
client.shutdown();
server.close();
- done.complete(null);
+ keepAlive.close();
}
};
}
- return done.future;
}
-Future testRequestResponseServerCloses(
+void testRequestResponseServerCloses(
int totalConnections, int closeStatus, String closeReason) {
- Completer done = new Completer();
+ ReceivePort keepAlive = new ReceivePort();
HttpServer server = secure ? new HttpsServer() : new HttpServer();
HttpClient client = new HttpClient();
@@ -110,7 +109,7 @@ Future testRequestResponseServerCloses(
if (closeCount == totalConnections) {
client.shutdown();
server.close();
- done.complete(null);
+ keepAlive.close();
}
};
conn.send(messageText);
@@ -129,12 +128,11 @@ Future testRequestResponseServerCloses(
Expect.equals(closeReason == null ? "" : closeReason, reason);
};
}
- return done.future;
}
-Future testMessageLength(int messageLength) {
- Completer done = new Completer();
+void testMessageLength(int messageLength) {
+ ReceivePort keepAlive = new ReceivePort();
HttpServer server = secure ? new HttpsServer() : new HttpServer();
HttpClient client = new HttpClient();
bool serverReceivedMessage = false;
@@ -173,17 +171,16 @@ Future testMessageLength(int messageLength) {
Expect.isTrue(clientReceivedMessage);
client.shutdown();
server.close();
- done.complete(null);
+ keepAlive.close();
};
wsconn.onOpen = () {
wsconn.send(originalMessage);
};
- return done.future;
}
-Future testNoUpgrade() {
- Completer done = new Completer();
+void testNoUpgrade() {
+ ReceivePort keepAlive = new ReceivePort();
HttpServer server = secure ? new HttpsServer() : new HttpServer();
HttpClient client = new HttpClient();
@@ -206,14 +203,13 @@ Future testNoUpgrade() {
Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode);
client.shutdown();
server.close();
- done.complete(null);
+ keepAlive.close();
};
- return done.future;
}
-Future testUsePOST() {
- Completer done = new Completer();
+void testUsePOST() {
+ ReceivePort keepAlive = new ReceivePort();
HttpServer server = secure ? new HttpsServer() : new HttpServer();
HttpClient client = new HttpClient();
@@ -238,9 +234,8 @@ Future testUsePOST() {
Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode);
client.shutdown();
server.close();
- done.complete(null);
+ keepAlive.close();
};
- return done.future;
}
@@ -249,8 +244,8 @@ class WebSocketInfo {
}
-Future testHashCode(int totalConnections) {
- Completer done = new Completer();
+void testHashCode(int totalConnections) {
+ ReceivePort keepAlive = new ReceivePort();
HttpServer server = secure ? new HttpsServer() : new HttpServer();
HttpClient client = new HttpClient();
Map connections = new Map();
@@ -288,7 +283,7 @@ Future testHashCode(int totalConnections) {
if (closeCount == totalConnections) {
client.shutdown();
server.close();
- done.complete();
+ keepAlive.close();
}
};
conn.send(messageText);
@@ -301,12 +296,12 @@ Future testHashCode(int totalConnections) {
WebSocketClientConnection wsconn = new WebSocketClientConnection(conn);
wsconn.onMessage = (message) => wsconn.send(message);
}
- return done.future;
}
-Future testW3CInterface(
+void testW3CInterface(
int totalConnections, int closeStatus, String closeReason) {
+ ReceivePort keepAlive = new ReceivePort();
List<Future> tasks = [];
HttpServer server = secure ? new HttpsServer() : new HttpServer();
@@ -386,7 +381,9 @@ Future testW3CInterface(
for (int i = 0; i < totalConnections; i++) {
webSocketConnection();
}
- return Future.wait(tasks);
+ Future.wait(tasks).then((_) {
+ keepAlive.close();
+ });
}
@@ -398,31 +395,31 @@ void InitializeSSL() {
}
-Future runTests() =>
- testRequestResponseClientCloses(2, null, null).then((_) =>
- testRequestResponseClientCloses(2, 3001, null)).then((_) =>
- testRequestResponseClientCloses(2, 3002, "Got tired")).then((_) =>
- testRequestResponseServerCloses(2, null, null)).then((_) =>
- testRequestResponseServerCloses(2, 3001, null)).then((_) =>
- testRequestResponseServerCloses(2, 3002, "Got tired")).then((_) =>
- testMessageLength(125)).then((_) =>
- testMessageLength(126)).then((_) =>
- testMessageLength(127)).then((_) =>
- testMessageLength(65535)).then((_) =>
- testMessageLength(65536)).then((_) =>
- testNoUpgrade()).then((_) =>
- testUsePOST()).then((_) =>
- testHashCode(2)).then((_) =>
- testW3CInterface(2, 3002, "Got tired"));
+/**
+ * Run all the tests in parallel, complete when the last one finishes.
+ */
+runTests() {
+ testRequestResponseClientCloses(2, null, null);
+ testRequestResponseClientCloses(2, 3001, null);
+ testRequestResponseClientCloses(2, 3002, "Got tired");
+ testRequestResponseServerCloses(2, null, null);
+ testRequestResponseServerCloses(2, 3001, null);
+ testRequestResponseServerCloses(2, 3002, "Got tired");
+ testMessageLength(125);
+ testMessageLength(126);
+ testMessageLength(127);
+ testMessageLength(65535);
+ testMessageLength(65536);
+ testNoUpgrade();
+ testUsePOST();
+ testHashCode(2);
+ testW3CInterface(2, 3002, "Got tired");
+}
main() {
- ReceivePort keepAlive = new ReceivePort();
- runTests().then((_) {
- InitializeSSL();
- secure = true;
- }).then((_) =>
- runTests()).then((_) {
- keepAlive.close();
- });
+ runTests();
+ InitializeSSL();
Anders Johnsen 2013/01/17 14:17:33 initializeSSL
+ secure = true;
+ runTests();
Anders Johnsen 2013/01/17 14:17:33 Put in secure == null below, so we can check that
}
« no previous file with comments | « tests/standalone/io/web_socket_no_secure_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698