Skip to content

Commit

Permalink
Merge #2899 into 2.0.0-M4
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Sep 13, 2023
2 parents eaf251c + a35ea43 commit fd3050c
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 7 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/check_graalvm.yml
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 }}
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ plugins {
id 'io.spring.javadoc' version '0.0.1' apply false
id 'io.spring.javadoc-aggregate' version '0.0.1' apply false
id 'biz.aQute.bnd.builder' version '6.4.0' apply false
id 'org.graalvm.buildtools.native' version '0.9.26' apply false
}

description = 'Reactive Streams Netty driver'
Expand Down Expand Up @@ -171,9 +172,9 @@ spotless {
format 'gradle', {
target '**/*.gradle'
// find start of gradle files by looking for either `import`, `apply`
// or start of blocks like `javadoc{` or `configure(rootProject) {`...
// or start of blocks like `javadoc {` or `configure(rootProject) {`...
licenseHeaderFile('codequality/spotless/licenseSlashstarStyle.txt',
"^\\w+(\\(\\w+\\))?\\s?\\{\$|import|apply")
"^\\w+(\\(\\w+\\))?\\s?\\{?|import|apply")
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/javadoc.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2020-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.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (project.name == 'reactor-netty5-examples') {
if (project.name == 'reactor-netty5-examples' || project.name == 'reactor-netty5-graalvm-smoke-tests') {
return
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import org.gradle.util.VersionNumber

if (project.name == 'reactor-netty5-examples') {
if (project.name == 'reactor-netty5-examples' || project.name == 'reactor-netty5-graalvm-smoke-tests') {
return
}

Expand Down
70 changes: 70 additions & 0 deletions reactor-netty5-graalvm-smoke-tests/build.gradle
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"
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));
}
}
5 changes: 3 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2022 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2011-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.
Expand All @@ -18,4 +18,5 @@ include 'reactor-netty5-core'
include 'reactor-netty5-http'
//include 'reactor-netty-incubator-quic'
include 'reactor-netty5-examples'
include 'reactor-netty5'
include 'reactor-netty5-graalvm-smoke-tests'
include 'reactor-netty5'

0 comments on commit fd3050c

Please sign in to comment.