From d13b0124435582da7000e8c36ad08fc88d151155 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 16 Sep 2024 11:43:58 +0200 Subject: [PATCH] more --- .github/workflows/ci-5.x.yml | 11 +++ .github/workflows/ci.yml | 12 ++- vertx-core/pom.xml | 74 +++++++++++++++++-- .../main/java/io/vertx/core/VertxBuilder.java | 1 + .../vertx/core/http/impl/HttpClientImpl.java | 1 + .../io/vertx/test/core/VertxTestBase.java | 8 +- .../java/io/vertx/test/proxy/HttpProxy.java | 6 +- .../io/vertx/tests/http/Http1xProxyTest.java | 60 ++++++++------- .../io/vertx/tests/http/WebSocketTest.java | 3 + 9 files changed, 138 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci-5.x.yml b/.github/workflows/ci-5.x.yml index 509fd143259..aef3e8d49ac 100644 --- a/.github/workflows/ci-5.x.yml +++ b/.github/workflows/ci-5.x.yml @@ -15,25 +15,36 @@ jobs: include: - os: ubuntu-latest jdk: 11 + experimental: false - os: ubuntu-latest jdk: 11 profile: '-PNativeEpoll' + experimental: false - os: ubuntu-latest jdk: 11 profile: '-PNativeIoUring' + experimental: false - os: ubuntu-latest jdk: 11 profile: '-PNativeEpoll+DomainSockets' + experimental: false - os: ubuntu-latest jdk: 21 + experimental: false - os: windows-latest jdk: 11 + experimental: false + - os: macos-latest + jdk: 11 + profile: '-PNativeKQueue' + experimental: true uses: ./.github/workflows/ci.yml with: branch: ${{ github.event.pull_request.head.sha || github.ref_name }} jdk: ${{ matrix.jdk }} os: ${{ matrix.os }} profile: ${{ matrix.profile }} + experimental: ${{ matrix.experimental }} secrets: inherit Deploy: if: ${{ github.repository_owner == 'eclipse-vertx' && (github.event_name == 'push' || github.event_name == 'schedule') }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 943a6f9c277..85e89e262b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,20 +4,24 @@ on: inputs: branch: required: true - type: string + type: 'string' jdk: default: 8 - type: string + type: 'string' os: default: ubuntu-latest - type: string + type: 'string' profile: default: '' - type: string + type: 'string' + experimental: + default: false + type: 'boolean' jobs: Test: name: Run tests runs-on: ${{ inputs.os }} + continue-on-error: ${{ inputs.experimental }} steps: - name: Checkout uses: actions/checkout@v2 diff --git a/vertx-core/pom.xml b/vertx-core/pom.xml index 5cdecfb255c..639c185b4b2 100644 --- a/vertx-core/pom.xml +++ b/vertx-core/pom.xml @@ -642,7 +642,6 @@ - NativeEpoll @@ -652,9 +651,8 @@ - - IoUring + NativeIoUring io_uring false @@ -662,7 +660,6 @@ - NativeEpoll+DomainSockets @@ -672,6 +669,24 @@ + + NativeKQueue + + kqueue + false + false + + + + + NativeKQueue+DomainSockets + + kqueue + true + false + + + benchmarks @@ -747,10 +762,35 @@ - linux + linux-x86_64 + + + linux + x86_64 + + + + + io.netty + netty-transport-native-epoll + linux-x86_64 + test + + + io.netty + netty-transport-native-io_uring + linux-x86_64 + test + + + + + + linux-amd64 linux + amd64 @@ -769,6 +809,30 @@ + + linux-aarch64 + + + linux + aarch64 + + + + + io.netty + netty-transport-native-epoll + linux-aarch_64 + test + + + io.netty + netty-transport-native-io_uring + linux-aarch_64 + test + + + + osx-x86_64 diff --git a/vertx-core/src/main/java/io/vertx/core/VertxBuilder.java b/vertx-core/src/main/java/io/vertx/core/VertxBuilder.java index 42c840438bd..7371556caa2 100644 --- a/vertx-core/src/main/java/io/vertx/core/VertxBuilder.java +++ b/vertx-core/src/main/java/io/vertx/core/VertxBuilder.java @@ -72,6 +72,7 @@ public interface VertxBuilder { * @return a reference to this, so the API can be used fluently */ @GenIgnore(GenIgnore.PERMITTED_TYPE) + @Fluent VertxBuilder withTransport(Transport transport); /** diff --git a/vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientImpl.java b/vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientImpl.java index 66291c811f8..62da25d75ca 100644 --- a/vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientImpl.java +++ b/vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientImpl.java @@ -421,6 +421,7 @@ private Future doRequest( } else if (server instanceof SocketAddress) { ProxyOptions proxyOptions = computeProxyOptions(proxyConfig, (SocketAddress) server); EndpointKey key = new EndpointKey(useSSL, sslOptions, proxyOptions, (SocketAddress) server, authority); + System.out.println(key.proxyOptions != null ? key.proxyOptions.toJson() : ""); future = httpCM.withResourceAsync(key, httpEndpointProvider(), (endpoint, created) -> { Future> fut = endpoint.requestConnection(streamCtx, connectTimeout); if (fut == null) { diff --git a/vertx-core/src/test/java/io/vertx/test/core/VertxTestBase.java b/vertx-core/src/test/java/io/vertx/test/core/VertxTestBase.java index 3796a2c407c..5eb92abd831 100644 --- a/vertx-core/src/test/java/io/vertx/test/core/VertxTestBase.java +++ b/vertx-core/src/test/java/io/vertx/test/core/VertxTestBase.java @@ -211,7 +211,13 @@ protected VertxBuilder createVertxBuilder(VertxOptions options) { } protected Vertx createVertx(VertxOptions options) { - return createVertxBuilder(options).build(); + Vertx vertx = createVertxBuilder(options).build(); + if (TRANSPORT != Transport.JDK) { + if (!vertx.isNativeTransportEnabled()) { + fail(vertx.unavailableNativeTransportCause()); + } + } + return vertx; } /** diff --git a/vertx-core/src/test/java/io/vertx/test/proxy/HttpProxy.java b/vertx-core/src/test/java/io/vertx/test/proxy/HttpProxy.java index e1a095c0df6..3cb442cd331 100644 --- a/vertx-core/src/test/java/io/vertx/test/proxy/HttpProxy.java +++ b/vertx-core/src/test/java/io/vertx/test/proxy/HttpProxy.java @@ -84,16 +84,16 @@ public HttpProxy start(Vertx vertx) throws Exception { String auth = request.getHeader("Proxy-Authorization"); String expected = "Basic " + Base64.getEncoder().encodeToString((username + ":" + username).getBytes()); if (auth == null || !auth.equals(expected)) { - request.response().setStatusCode(407).end("proxy authentication failed"); + request.response().setStatusCode(407).end("Proxy authentication failed"); return; } } lastRequestHeaders = HttpHeaders.headers().addAll(request.headers()); if (error != 0) { - request.response().setStatusCode(error).end("proxy request failed"); + request.response().setStatusCode(error).end("Proxy request failed"); } else if (method == HttpMethod.CONNECT) { if (!uri.contains(":")) { - request.response().setStatusCode(403).end("invalid request"); + request.response().setStatusCode(403).end("Invalid request"); } else { lastUri = uri; lastMethod = HttpMethod.CONNECT; diff --git a/vertx-core/src/test/java/io/vertx/tests/http/Http1xProxyTest.java b/vertx-core/src/test/java/io/vertx/tests/http/Http1xProxyTest.java index 9b3add0f99f..9eee2f8d1b2 100644 --- a/vertx-core/src/test/java/io/vertx/tests/http/Http1xProxyTest.java +++ b/vertx-core/src/test/java/io/vertx/tests/http/Http1xProxyTest.java @@ -320,7 +320,7 @@ public void testHttpProxyPooling2() throws Exception { .setHost("localhost") .setPort(proxy.port()); List res = testPooling(req, req, proxy); - assertEquals(proxy.localAddresses(), res); + assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res)); } @Test @@ -359,7 +359,7 @@ public void testHttpProxyAuthPooling2() throws Exception { .setPort(proxy.port()); List res = testPooling(req1, req2, proxy); assertEquals(2, proxy.localAddresses().size()); - assertEquals(proxy.localAddresses(), res); + assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res)); } @Test @@ -375,7 +375,7 @@ public void testSocksProxyPooling1() throws Exception { .setHost("localhost") .setPort(proxy2.port()); List res = testPooling(req1, req2, proxy1, proxy2); - assertEquals(Arrays.asList(proxy1.lastLocalAddress(), proxy2.lastLocalAddress()), res); + assertEquals(Set.of(proxy1.lastLocalAddress(), proxy2.lastLocalAddress()), new HashSet<>(res)); } @Test @@ -386,7 +386,7 @@ public void testSocksProxyPooling2() throws Exception { .setHost("localhost") .setPort(proxy.port()); List res = testPooling(req, req, proxy); - assertEquals(proxy.localAddresses(), res); + assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res)); } @Test @@ -405,7 +405,7 @@ public void testSocksProxyAuthPooling1() throws Exception { .setHost("localhost") .setPort(proxy.port()); List res = testPooling(req1, req2, proxy); - assertEquals(proxy.localAddresses(), res); + assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res)); } @Test @@ -425,7 +425,7 @@ public void testSocksProxyAuthPooling2() throws Exception { .setPort(proxy.port()); List res = testPooling(req1, req2, proxy); assertEquals(2, proxy.localAddresses().size()); - assertEquals(proxy.localAddresses(), res); + assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res)); } public List testPooling(ProxyOptions request1, ProxyOptions request2, TestProxyBase... proxies) throws Exception { @@ -434,7 +434,7 @@ public List testPooling(ProxyOptions request1, ProxyOptions request2, Te } client.close(); - client = vertx.createHttpClient(new HttpClientOptions().setKeepAlive(true), new PoolOptions().setHttp2MaxSize(2)); + client = vertx.createHttpClient(new HttpClientOptions().setKeepAlive(true), new PoolOptions().setHttp1MaxSize(2)); CompletableFuture> ret = new CompletableFuture<>(); @@ -448,24 +448,34 @@ public List testPooling(ProxyOptions request1, ProxyOptions request2, Te request.response().end("" + addr); }); } - }).listen().onComplete(onSuccess(s -> { - RequestOptions baseOptions = new RequestOptions() - .setHost(DEFAULT_HTTP_HOST) - .setPort(DEFAULT_HTTP_PORT) - .setURI("/"); - List responses = new ArrayList<>(); - for (int i = 0;i < 2;i++) { - client.request(new RequestOptions(baseOptions).setProxyOptions(i == 0 ? request1 : request2)) - .compose(HttpClientRequest::send) - .compose(HttpClientResponse::body) - .onComplete(onSuccess(res2 -> { - responses.add(res2.toString()); - if (responses.size() == 2) { - ret.complete(responses); - } - })); - } - })); + }).listen() + .await(); + + RequestOptions baseOptions = new RequestOptions() + .setHost(DEFAULT_HTTP_HOST) + .setPort(DEFAULT_HTTP_PORT) + .setURI("/"); + List> clientRequests = new ArrayList<>(); + for (int i = 0;i < 2;i++) { + Future request = client + .request(new RequestOptions(baseOptions).setProxyOptions(i == 0 ? request1 : request2)); + clientRequests.add(request); + // Avoid races with the proxy username provider + request.await(); + } + List responses = new ArrayList<>(); + for (int i = 0;i < 2;i++) { + clientRequests.get(i) + .compose(HttpClientRequest::send) + .expecting(HttpResponseExpectation.SC_OK) + .compose(HttpClientResponse::body) + .onComplete(onSuccess(res2 -> { + responses.add(res2.toString()); + if (responses.size() == 2) { + ret.complete(responses); + } + })); + } return ret.get(40, TimeUnit.SECONDS); } finally { diff --git a/vertx-core/src/test/java/io/vertx/tests/http/WebSocketTest.java b/vertx-core/src/test/java/io/vertx/tests/http/WebSocketTest.java index 75511bc7144..16da47f8103 100644 --- a/vertx-core/src/test/java/io/vertx/tests/http/WebSocketTest.java +++ b/vertx-core/src/test/java/io/vertx/tests/http/WebSocketTest.java @@ -28,6 +28,7 @@ import io.vertx.core.http.impl.ws.WebSocketFrameImpl; import io.vertx.core.net.*; import io.vertx.core.internal.net.NetSocketInternal; +import io.vertx.core.transport.Transport; import io.vertx.test.core.CheckingSender; import io.vertx.test.core.TestUtils; import io.vertx.test.core.VertxTestBase; @@ -72,6 +73,7 @@ import static io.vertx.test.http.HttpTestBase.*; import static io.vertx.test.core.TestUtils.*; +import static org.junit.Assume.assumeTrue; /** * @author Tim Fox @@ -533,6 +535,7 @@ public void testHandleWSManually() throws Exception { @Test public void testSharedServersRoundRobin() throws Exception { + assumeTrue(TRANSPORT != Transport.IO_URING); int numServers = VertxOptions.DEFAULT_EVENT_LOOP_POOL_SIZE / 2- 1; int numConnections = numServers * 100;