Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Sep 16, 2024
1 parent 52c922b commit d13b012
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 38 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci-5.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 69 additions & 5 deletions vertx-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@

<profiles>

<!-- Run tests with native transport -->
<profile>
<id>NativeEpoll</id>
<properties>
Expand All @@ -652,17 +651,15 @@
</properties>
</profile>

<!-- Run tests with native transport -->
<profile>
<id>IoUring</id>
<id>NativeIoUring</id>
<properties>
<vertx.testTransport>io_uring</vertx.testTransport>
<vertx.testDomainSockets>false</vertx.testDomainSockets>
<vertx.testUseModulePath>false</vertx.testUseModulePath>
</properties>
</profile>

<!-- Run tests with native transport and domain sockets -->
<profile>
<id>NativeEpoll+DomainSockets</id>
<properties>
Expand All @@ -672,6 +669,24 @@
</properties>
</profile>

<profile>
<id>NativeKQueue</id>
<properties>
<vertx.testTransport>kqueue</vertx.testTransport>
<vertx.testDomainSockets>false</vertx.testDomainSockets>
<vertx.testUseModulePath>false</vertx.testUseModulePath>
</properties>
</profile>

<profile>
<id>NativeKQueue+DomainSockets</id>
<properties>
<vertx.testTransport>kqueue</vertx.testTransport>
<vertx.testDomainSockets>true</vertx.testDomainSockets>
<vertx.testUseModulePath>false</vertx.testUseModulePath>
</properties>
</profile>

<profile>
<id>benchmarks</id>
<build>
Expand Down Expand Up @@ -747,10 +762,35 @@
</profile>

<profile>
<id>linux</id>
<id>linux-x86_64</id>
<activation>
<os>
<family>linux</family>
<arch>x86_64</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-x86_64</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-io_uring</artifactId>
<classifier>linux-x86_64</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>linux-amd64</id>
<activation>
<os>
<family>linux</family>
<arch>amd64</arch>
</os>
</activation>
<dependencies>
Expand All @@ -769,6 +809,30 @@
</dependencies>
</profile>

<profile>
<id>linux-aarch64</id>
<activation>
<os>
<family>linux</family>
<arch>aarch64</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-io_uring</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>osx-x86_64</id>
<activation>
Expand Down
1 change: 1 addition & 0 deletions vertx-core/src/main/java/io/vertx/core/VertxBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ private Future<HttpClientRequest> 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<Lease<HttpClientConnectionInternal>> fut = endpoint.requestConnection(streamCtx, connectTimeout);
if (fut == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions vertx-core/src/test/java/io/vertx/test/proxy/HttpProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
60 changes: 35 additions & 25 deletions vertx-core/src/test/java/io/vertx/tests/http/Http1xProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void testHttpProxyPooling2() throws Exception {
.setHost("localhost")
.setPort(proxy.port());
List<String> res = testPooling(req, req, proxy);
assertEquals(proxy.localAddresses(), res);
assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res));
}

@Test
Expand Down Expand Up @@ -359,7 +359,7 @@ public void testHttpProxyAuthPooling2() throws Exception {
.setPort(proxy.port());
List<String> res = testPooling(req1, req2, proxy);
assertEquals(2, proxy.localAddresses().size());
assertEquals(proxy.localAddresses(), res);
assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res));
}

@Test
Expand All @@ -375,7 +375,7 @@ public void testSocksProxyPooling1() throws Exception {
.setHost("localhost")
.setPort(proxy2.port());
List<String> 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
Expand All @@ -386,7 +386,7 @@ public void testSocksProxyPooling2() throws Exception {
.setHost("localhost")
.setPort(proxy.port());
List<String> res = testPooling(req, req, proxy);
assertEquals(proxy.localAddresses(), res);
assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res));
}

@Test
Expand All @@ -405,7 +405,7 @@ public void testSocksProxyAuthPooling1() throws Exception {
.setHost("localhost")
.setPort(proxy.port());
List<String> res = testPooling(req1, req2, proxy);
assertEquals(proxy.localAddresses(), res);
assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res));
}

@Test
Expand All @@ -425,7 +425,7 @@ public void testSocksProxyAuthPooling2() throws Exception {
.setPort(proxy.port());
List<String> res = testPooling(req1, req2, proxy);
assertEquals(2, proxy.localAddresses().size());
assertEquals(proxy.localAddresses(), res);
assertEquals(new HashSet<>(proxy.localAddresses()), new HashSet<>(res));
}

public List<String> testPooling(ProxyOptions request1, ProxyOptions request2, TestProxyBase... proxies) throws Exception {
Expand All @@ -434,7 +434,7 @@ public List<String> 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<List<String>> ret = new CompletableFuture<>();

Expand All @@ -448,24 +448,34 @@ public List<String> 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<String> 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<Future<HttpClientRequest>> clientRequests = new ArrayList<>();
for (int i = 0;i < 2;i++) {
Future<HttpClientRequest> request = client
.request(new RequestOptions(baseOptions).setProxyOptions(i == 0 ? request1 : request2));
clientRequests.add(request);
// Avoid races with the proxy username provider
request.await();
}
List<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <a href="http://tfox.org">Tim Fox</a>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d13b012

Please sign in to comment.