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

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

Issue 2105553003: Attempt to make probability of test flake in tests/standalone/io/socket_bind_test lower (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Attempt to make probability of test flake in tests/standalone/io/socket_bind_test lower Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/socket_bind_test.dart
diff --git a/tests/standalone/io/socket_bind_test.dart b/tests/standalone/io/socket_bind_test.dart
index 084280db87edbc50c9e92f0b81b94ef14e7bf870..f701f0c806109cad0db7dfbdad65763f8baa8a3a 100644
--- a/tests/standalone/io/socket_bind_test.dart
+++ b/tests/standalone/io/socket_bind_test.dart
@@ -66,22 +66,22 @@ Future testBindDifferentAddresses(InternetAddress addr1,
bool addr2V6Only) async {
int freePort = await freeIPv4AndIPv6Port();
- asyncStart();
- return ServerSocket.bind(
- addr1, freePort, v6Only: addr1V6Only, shared: false).then((socket) {
+ var socket = await ServerSocket.bind(
+ addr1, freePort, v6Only: addr1V6Only, shared: false);
+
+ try {
Expect.isTrue(socket.port > 0);
- asyncStart();
- return ServerSocket.bind(
- addr2, freePort, v6Only: addr2V6Only, shared: false).then((socket2) {
+ var socket2 = await ServerSocket.bind(
+ addr2, freePort, v6Only: addr2V6Only, shared: false);
+ try {
Expect.equals(socket.port, socket2.port);
-
- return Future.wait([
- socket.close().whenComplete(asyncEnd),
- socket2.close().whenComplete(asyncEnd),
- ]);
- });
- });
+ } finally {
+ await socket2.close();
+ }
+ } finally {
+ await socket.close();
+ }
}
testListenCloseListenClose(String host) async {
@@ -120,16 +120,34 @@ Future<int> freeIPv4AndIPv6Port() async {
return port;
}
+Future retry(Future fun(), {int maxCount: 10}) async {
+ for (int i = 0; i < maxCount; i++) {
+ try {
+ // If there is no exception this will simply return, otherwise we keep
+ // trying.
+ return await fun();
+ } catch (_) {}
+ print("Failed to execute test closure in attempt $i "
+ "(${maxCount - i} retries left).");
+ }
+ return await fun();
+}
+
main() async {
asyncStart();
- await testBindDifferentAddresses(InternetAddress.ANY_IP_V6,
- InternetAddress.ANY_IP_V4,
- true,
- false);
- await testBindDifferentAddresses(InternetAddress.ANY_IP_V4,
- InternetAddress.ANY_IP_V6,
- false,
- true);
+
+ await retry(() async {
+ await testBindDifferentAddresses(InternetAddress.ANY_IP_V6,
+ InternetAddress.ANY_IP_V4,
+ true,
+ false);
+ });
+ await retry(() async {
+ await testBindDifferentAddresses(InternetAddress.ANY_IP_V4,
+ InternetAddress.ANY_IP_V6,
+ false,
+ true);
+ });
for (var host in ['127.0.0.1', '::1']) {
testBindShared(host, false);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698