From 6fbe79af461bd24a3fb1700879284088d0467c0e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 29 Oct 2021 09:50:47 +0200 Subject: [PATCH] Issue #6728 - QUIC and HTTP/3 - Fixed UNIX_DOMAIN tests. Signed-off-by: Simone Bordet --- .../client/HttpChannelAssociationTest.java | 29 ++++++++++++++++++- .../http/client/HttpClientTimeoutTest.java | 13 ++++++++- .../client/RoundRobinConnectionPoolTest.java | 5 ++-- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpChannelAssociationTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpChannelAssociationTest.java index 23439aab1d0..f5efacaf39b 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpChannelAssociationTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpChannelAssociationTest.java @@ -121,7 +121,6 @@ public class HttpChannelAssociationTest extends AbstractTest { case HTTP: case HTTPS: - case UNIX_DOMAIN: { ClientConnector clientConnector = new ClientConnector(); clientConnector.setSelectors(1); @@ -236,6 +235,34 @@ public class HttpChannelAssociationTest extends AbstractTest } }; } + case UNIX_DOMAIN: + { + ClientConnector clientConnector = ClientConnector.forUnixDomain(scenario.unixDomainPath); + clientConnector.setSelectors(1); + clientConnector.setSslContextFactory(scenario.newClientSslContextFactory()); + return new HttpClientTransportOverHTTP(clientConnector) + { + @Override + public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) + { + return new HttpConnectionOverHTTP(endPoint, context) + { + @Override + protected HttpChannelOverHTTP newHttpChannel() + { + return new HttpChannelOverHTTP(this) + { + @Override + public boolean associate(HttpExchange exchange) + { + return code.test(exchange) && super.associate(exchange); + } + }; + } + }; + } + }; + } default: { throw new IllegalArgumentException(); diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTimeoutTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTimeoutTest.java index 6de7d1c9288..0294e779ead 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTimeoutTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTimeoutTest.java @@ -50,6 +50,7 @@ import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; import org.opentest4j.TestAbortedException; @@ -283,6 +284,8 @@ public class HttpClientTimeoutTest extends AbstractTest @ArgumentsSource(TransportProvider.class) public void testBlockingConnectTimeoutFailsRequest(Transport transport) throws Exception { + // Failure to connect is based on InetSocket address failure, which Unix-Domain does not use. + Assumptions.assumeTrue(transport != Transport.UNIX_DOMAIN); init(transport); testConnectTimeoutFailsRequest(true); } @@ -291,6 +294,8 @@ public class HttpClientTimeoutTest extends AbstractTest @ArgumentsSource(TransportProvider.class) public void testNonBlockingConnectTimeoutFailsRequest(Transport transport) throws Exception { + // Failure to connect is based on InetSocket address failure, which Unix-Domain does not use. + Assumptions.assumeTrue(transport != Transport.UNIX_DOMAIN); init(transport); testConnectTimeoutFailsRequest(false); } @@ -326,6 +331,9 @@ public class HttpClientTimeoutTest extends AbstractTest @ArgumentsSource(TransportProvider.class) public void testConnectTimeoutIsCancelledByShorterRequestTimeout(Transport transport) throws Exception { + // Failure to connect is based on InetSocket address failure, which Unix-Domain does not use. + Assumptions.assumeTrue(transport != Transport.UNIX_DOMAIN); + init(transport); String host = "10.255.255.1"; @@ -357,8 +365,11 @@ public class HttpClientTimeoutTest extends AbstractTest @ParameterizedTest @ArgumentsSource(TransportProvider.class) - public void retryAfterConnectTimeout(Transport transport) throws Exception + public void testRetryAfterConnectTimeout(Transport transport) throws Exception { + // Failure to connect is based on InetSocket address failure, which Unix-Domain does not use. + Assumptions.assumeTrue(transport != Transport.UNIX_DOMAIN); + init(transport); final String host = "10.255.255.1"; diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/RoundRobinConnectionPoolTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/RoundRobinConnectionPoolTest.java index 943a8cc6615..b802977b7d3 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/RoundRobinConnectionPoolTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/RoundRobinConnectionPoolTest.java @@ -194,7 +194,7 @@ public class RoundRobinConnectionPoolTest extends AbstractTest 0) assertThat(remotePorts.get(i - 1), Matchers.not(Matchers.equalTo(candidate))); } @@ -254,6 +254,7 @@ public class RoundRobinConnectionPoolTest extends AbstractTest