diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-05-19 15:45:10 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-05-19 15:45:10 +0200 |
commit | acf24799b20f2a5bfabafbc0a1c51b8ae382220c (patch) | |
tree | ca11f8f883ec3bb9e3c0736d46a2efc0ece4693f /jdisc_http_service/src | |
parent | 69b3bbee1cd90ec5836d5ef1fd06e80072acd450 (diff) |
Stabilize HttpServerTest
Retry test requests sent from Jetty client on failure
Diffstat (limited to 'jdisc_http_service/src')
-rw-r--r-- | jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java index 37f717437ee..a67f6919727 100644 --- a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java +++ b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java @@ -758,12 +758,23 @@ public class HttpServerTest { } private ContentResponse sendJettyClientRequest(TestDriver testDriver, HttpClient client, Object tag) - throws InterruptedException, ExecutionException, TimeoutException { - ContentResponse response = client.newRequest(URI.create("https://localhost:" + testDriver.server().getListenPort() + "/")) - .tag(tag) - .send(); - assertEquals(200, response.getStatus()); - return response; + throws InterruptedException, TimeoutException { + int maxAttempts = 3; + for (int attempt = 0; attempt < maxAttempts; attempt++) { + try { + ContentResponse response = client.newRequest(URI.create("https://localhost:" + testDriver.server().getListenPort() + "/")) + .tag(tag) + .send(); + assertEquals(200, response.getStatus()); + return response; + } catch (ExecutionException e) { + // Retry when the server closes the connection before the TLS handshake is completed. This have been observed in CI. + // We have been unable to reproduce this locally. The cause is therefor currently unknown. + log.log(Level.WARNING, String.format("Attempt %d failed: %s", attempt, e.getMessage()), e); + Thread.sleep(10); + } + } + throw new AssertionError("Failed to send request, see log for details"); } // Using Jetty's http client as Apache httpclient does not support the proxy-protocol v1/v2. |