-
Notifications
You must be signed in to change notification settings - Fork 646
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
194 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: GraalVM smoke tests | ||
|
||
on: | ||
pull_request: {} | ||
permissions: read-all | ||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-20.04, macos-11] | ||
transport: [native, nio] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '8' | ||
- name: Download GraalVM 17 | ||
run: | | ||
if [ "$RUNNER_OS" == "Linux" ]; then | ||
download_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.8/graalvm-community-jdk-17.0.8_linux-x64_bin.tar.gz" | ||
else | ||
download_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.8/graalvm-community-jdk-17.0.8_macos-x64_bin.tar.gz" | ||
fi | ||
curl -L $download_url --output $RUNNER_TEMP/java_package.tar.gz | ||
shell: bash | ||
- name: Set up GraalVM 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'jdkfile' | ||
jdkFile: ${{ runner.temp }}/java_package.tar.gz | ||
java-version: '17' | ||
- name: Build with Gradle | ||
run: ./gradlew :reactor-netty5-graalvm-smoke-tests:nativeTest --no-daemon -PforceTransport=${{ matrix.transport }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2023 VMware, Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
apply plugin: 'org.graalvm.buildtools.native' | ||
|
||
dependencies { | ||
// MacOS binaries are not available for Netty SNAPSHOT version | ||
if (!"$nettyVersion".endsWithAny("SNAPSHOT")) { | ||
if (osdetector.classifier == "osx-x86_64" || osdetector.classifier == "osx-aarch_64") { | ||
testImplementation "io.netty:netty5-resolver-dns-native-macos:$nettyVersion$os_suffix" | ||
} | ||
else { | ||
testImplementation "io.netty:netty5-resolver-dns-classes-macos:$nettyVersion" | ||
} | ||
} | ||
else { | ||
// MacOS binaries are not available for Netty SNAPSHOT version | ||
testImplementation "io.netty:netty5-resolver-dns-classes-macos:$nettyVersion" | ||
} | ||
|
||
testImplementation "io.netty:netty5-transport-classes-epoll:$nettyVersion" | ||
testImplementation "io.netty:netty5-transport-classes-kqueue:$nettyVersion" | ||
testImplementation "io.netty:netty5-transport-classes-io_uring:$nettyVersion" | ||
if (project.hasProperty("forceTransport")) { | ||
//now we explicitly add correctly qualified native, or do nothing if we want to test NIO | ||
if (forceTransport == "native") { | ||
if (osdetector.os == "osx") { | ||
testRuntimeOnly "io.netty:netty5-transport-native-kqueue:$nettyVersion$os_suffix" | ||
} else if (osdetector.os == "linux") { | ||
testRuntimeOnly "io.netty:netty5-transport-native-epoll:$nettyVersion$os_suffix" | ||
} | ||
} else if (forceTransport == "io_uring" && osdetector.os == "linux") { | ||
testRuntimeOnly "io.netty:netty5-transport-native-io_uring:$nettyVersion$os_suffix" | ||
} else if (forceTransport != "nio") { | ||
throw new InvalidUserDataException("invalid -PforceTranport option " + forceTransport + ", should be native|nio") | ||
} | ||
} | ||
|
||
testImplementation project(':reactor-netty5-http') | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" | ||
testImplementation "io.projectreactor:reactor-test:$testAddonVersion" | ||
testImplementation "org.assertj:assertj-core:$assertJVersion" | ||
} | ||
|
||
graalvmNative { | ||
binaries { | ||
test { | ||
if (project.hasProperty("forceTransport")) { | ||
runtimeArgs.add("-DforceTransport=$forceTransport") | ||
} | ||
} | ||
} | ||
metadataRepository { | ||
enabled = true | ||
} | ||
} | ||
|
||
description = "GraalVM smoke tests for the Reactor Netty library" |
76 changes: 76 additions & 0 deletions
76
reactor-netty5-graalvm-smoke-tests/src/test/java/reactor/netty5/http/HttpTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2023 VMware, Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package reactor.netty5.http; | ||
|
||
import io.netty5.channel.epoll.Epoll; | ||
import io.netty5.channel.kqueue.KQueue; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import reactor.core.publisher.Mono; | ||
import reactor.netty5.DisposableServer; | ||
import reactor.netty5.http.client.HttpClient; | ||
import reactor.netty5.http.server.HttpServer; | ||
import reactor.test.StepVerifier; | ||
|
||
import java.time.Duration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class HttpTests { | ||
DisposableServer disposableServer; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
if (disposableServer != null) { | ||
disposableServer.disposeNow(); | ||
} | ||
} | ||
|
||
@Test | ||
void smokeTest() { | ||
String transport = System.getProperty("forceTransport"); | ||
String osName = System.getProperty("os.name"); | ||
if ("native".equals(transport)) { | ||
if ("Linux".equals(osName)) { | ||
assertThat(Epoll.isAvailable()).isTrue(); | ||
} | ||
else if ("Mac OS X".equals(osName)) { | ||
assertThat(KQueue.isAvailable()).isTrue(); | ||
} | ||
} | ||
else { | ||
assertThat(Epoll.isAvailable()).isFalse(); | ||
assertThat(KQueue.isAvailable()).isFalse(); | ||
} | ||
|
||
disposableServer = | ||
HttpServer.create() | ||
.handle((req, res) -> res.sendString(Mono.just("Hello World!"))) | ||
.bindNow(); | ||
|
||
HttpClient.create() | ||
.port(disposableServer.port()) | ||
.get() | ||
.uri("/") | ||
.responseContent() | ||
.aggregate() | ||
.asString() | ||
.as(StepVerifier::create) | ||
.expectNext("Hello World!") | ||
.expectComplete() | ||
.verify(Duration.ofSeconds(5)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters