summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@vespa.ai>2024-01-04 13:53:23 +0100
committerBjørn Christian Seime <bjorncs@vespa.ai>2024-01-04 13:56:37 +0100
commite3bd3abcf627c70648a8ca224b67961bdf0dde8f (patch)
tree0c0fda2a7bd8eb07ed2ae0adc3bf6f65d02057cd /container-core
parent1f7bfaf60d05e4b55a926b46e10623448ce31308 (diff)
Make test fail faster
Add global timeout. Reduce client timeout. Recreate client on connection failure.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/ProxyProtocolTest.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/ProxyProtocolTest.java b/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/ProxyProtocolTest.java
index eac7b7c5df7..8df20239875 100644
--- a/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/ProxyProtocolTest.java
+++ b/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/ProxyProtocolTest.java
@@ -17,6 +17,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
@@ -40,6 +41,7 @@ import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bjorncs
*/
+@Timeout(value = 60)
class ProxyProtocolTest {
private static final Logger log = Logger.getLogger(ProxyProtocolTest.class.getName());
@@ -155,30 +157,28 @@ class ProxyProtocolTest {
private ContentResponse sendJettyClientRequest(JettyTestDriver testDriver, Path certificateFile, Object tag)
throws Exception {
- HttpClient client = createJettyHttpClient(certificateFile);
ExecutionException cause = null;
- try {
- int maxAttempts = 10;
- 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 has 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);
- cause = e;
- }
+ int maxAttempts = 10;
+ for (int attempt = 0; attempt < maxAttempts; attempt++) {
+ HttpClient client = createJettyHttpClient(certificateFile);
+ 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 has 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);
+ cause = e;
+ } finally {
+ client.stop();
+ client.destroy();
}
- throw cause;
- } finally {
- client.stop();
- client.destroy();
}
+ throw cause;
}
// Using Jetty's http client as Apache httpclient does not support the proxy-protocol v1/v2.
@@ -189,7 +189,7 @@ class ProxyProtocolTest {
var connector = new ClientConnector();
connector.setSslContextFactory(ssl);
HttpClient client = new HttpClient(new HttpClientTransportOverHTTP(connector));
- int timeout = 60 * 1000;
+ int timeout = 20 * 1000;
client.setConnectTimeout(timeout);
client.setIdleTimeout(timeout);
client.start();