aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2015-02-09 17:48:27 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-09 17:48:27 +0000
commit74a968d084559e865f62a5a53fb27b5b91ba834d (patch)
treec189cff41eafac1285a03ef41db492d648c07f9c
parent711381f25a8ce4ddbe0ec1fcd63e6759c9dfd438 (diff)
parent75a7afac9b6b5866cde46c3d3158227391175701 (diff)
downloadokhttp-74a968d084559e865f62a5a53fb27b5b91ba834d.tar.gz
am 75a7afac: Reduce flakiness of OkHttp tests
* commit '75a7afac9b6b5866cde46c3d3158227391175701': Reduce flakiness of OkHttp tests
-rw-r--r--okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java
index 330929b..c88ac7c 100644
--- a/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java
+++ b/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java
@@ -424,6 +424,11 @@ public final class URLConnectionTest {
HttpURLConnection connection1 = client.open(server.getUrl("/a"));
connection1.setReadTimeout(100);
assertContent("This connection won't pool properly", connection1);
+
+ // Give the server time to enact the socket policy if it's one that could happen after the
+ // client has received the response.
+ Thread.sleep(500);
+
assertEquals(0, server.takeRequest().getSequenceNumber());
HttpURLConnection connection2 = client.open(server.getUrl("/b"));
connection2.setReadTimeout(100);
@@ -632,6 +637,10 @@ public final class URLConnectionTest {
client.client().setHostnameVerifier(new RecordingHostnameVerifier());
assertContent("abc", client.open(server.getUrl("/")));
+
+ // Give the server time to disconnect.
+ Thread.sleep(500);
+
assertContent("def", client.open(server.getUrl("/")));
Set<TlsVersion> tlsVersions =
@@ -1197,6 +1206,9 @@ public final class URLConnectionTest {
// Seed the pool with a bad connection.
assertContent("a", client.open(server.getUrl("/")));
+ // Give the server time to disconnect.
+ Thread.sleep(500);
+
// This connection will need to be recovered. When it is, transparent gzip should still work!
assertContent("b", client.open(server.getUrl("/")));
@@ -2577,6 +2589,9 @@ public final class URLConnectionTest {
assertContent("A", client.open(server.getUrl("/a")));
+ // Give the server time to disconnect.
+ Thread.sleep(500);
+
// If the request body is larger than OkHttp's replay buffer, the failure may still occur.
byte[] requestBody = new byte[requestSize];
new Random(0).nextBytes(requestBody);