-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Mutiny 2.6.0 and Reactive Messaging 4.20.0
This also fixes the native compilation of JCTools which is now used in Mutiny, and adds some related tests for native compilation.
- Loading branch information
Showing
12 changed files
with
300 additions
and
9 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
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
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,10 @@ | ||
# Quarkus - Integration Tests - Mutiny native JCTools support | ||
|
||
This integration test checks that the Mutiny extension provides support for the native compilation of JCTools, which is now used internally in Mutiny instead of old custom data structures. | ||
|
||
This is important as JCTools makes use of `sun.misc.Unsafe` in some places. | ||
|
||
The tests do the following: | ||
|
||
- create all kinds of queues behind the factory `io.smallrye.mutiny.helpers.queues.Queues` interface, and | ||
- expose a few Mutiny pipelines where queues may be needed: overflow, custom emitters, etc. |
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,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-integration-test-mutiny-native-jctools</artifactId> | ||
|
||
<name>Quarkus - Integration Tests - Mutiny native JCTools support</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-mutiny</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-client-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-mutiny-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
85 changes: 85 additions & 0 deletions
85
...ts/mutiny-native-jctools/src/main/java/io/quarkus/it/mutiny/nativejctools/MyResource.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,85 @@ | ||
package io.quarkus.it.mutiny.nativejctools; | ||
|
||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.stream.Collectors; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.jboss.resteasy.reactive.RestStreamElementType; | ||
|
||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.helpers.queues.Queues; | ||
import io.smallrye.mutiny.infrastructure.Infrastructure; | ||
import io.smallrye.mutiny.subscription.MultiEmitter; | ||
|
||
@Path("/tests") | ||
public class MyResource { | ||
|
||
@GET | ||
@Path("create-queues") | ||
public String createQueues() { | ||
ArrayList<Long> sums = new ArrayList<>(); | ||
List.of( | ||
Queues.createMpscQueue(), | ||
Queues.createMpscArrayQueue(2048), | ||
Queues.createSpscArrayQueue(2048), | ||
Queues.createSpscUnboundedQueue(2048), | ||
Queues.createSpscUnboundedArrayQueue(2048), | ||
Queues.createSpscChunkedArrayQueue(2048)).forEach(queue -> { | ||
for (int i = 0; i < 1024; i++) { | ||
queue.offer(i); | ||
} | ||
long sum = 0L; | ||
for (Integer n = (Integer) queue.poll(); n != null; n = (Integer) queue.poll()) { | ||
sum = sum + n; | ||
} | ||
sums.add(sum); | ||
}); | ||
return "Ok :: " + sums.stream() | ||
.map(Objects::toString) | ||
.collect(Collectors.joining("/")); | ||
} | ||
|
||
@GET | ||
@Path("ticks-overflow") | ||
public String ticksWithOverflow() { | ||
List<String> ticks = Multi.createFrom().ticks().every(Duration.ofMillis(10)) | ||
.onOverflow().bufferUnconditionally() | ||
.onItem().transform(tick -> ":") | ||
.select().first(10) | ||
.collect().asList().await().atMost(Duration.ofSeconds(5)); | ||
return String.join("", ticks); | ||
} | ||
|
||
@GET | ||
@RestStreamElementType(MediaType.TEXT_PLAIN) | ||
@Path("emitter") | ||
public Multi<String> emitter() { | ||
AtomicInteger counter = new AtomicInteger(); | ||
return Multi.createFrom().emitter(emitter -> { | ||
ScheduledExecutorService scheduler = Infrastructure.getDefaultWorkerPool(); | ||
scheduler.schedule(() -> emitAndSchedule(counter, emitter), 100, TimeUnit.MILLISECONDS); | ||
}); | ||
} | ||
|
||
private void emitAndSchedule(AtomicInteger counter, MultiEmitter<? super String> emitter) { | ||
ScheduledExecutorService scheduler = Infrastructure.getDefaultWorkerPool(); | ||
int n = counter.getAndIncrement(); | ||
if (n < 5) { | ||
for (int i = 0; i < n * 10; i++) { | ||
emitter.emit(String.valueOf(i)); | ||
} | ||
scheduler.schedule(() -> emitAndSchedule(counter, emitter), 125, TimeUnit.MILLISECONDS); | ||
} else { | ||
emitter.complete(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/mutiny-native-jctools/src/main/resources/application.properties
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 @@ | ||
|
7 changes: 7 additions & 0 deletions
7
.../mutiny-native-jctools/src/test/java/io/quarkus/it/mutiny/nativejctools/MyResourceIT.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,7 @@ | ||
package io.quarkus.it.mutiny.nativejctools; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class MyResourceIT extends MyResourceTest { | ||
} |
73 changes: 73 additions & 0 deletions
73
...utiny-native-jctools/src/test/java/io/quarkus/it/mutiny/nativejctools/MyResourceTest.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,73 @@ | ||
package io.quarkus.it.mutiny.nativejctools; | ||
|
||
import static io.restassured.RestAssured.get; | ||
import static org.awaitility.Awaitility.await; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.jupiter.api.Assertions.assertIterableEquals; | ||
|
||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import jakarta.ws.rs.client.Client; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import jakarta.ws.rs.client.WebTarget; | ||
import jakarta.ws.rs.sse.SseEventSource; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTest | ||
public class MyResourceTest { | ||
|
||
@Test | ||
public void testCreateQueues() { | ||
get("/tests/create-queues") | ||
.then() | ||
.body(is("Ok :: 523776/523776/523776/523776/523776/523776")) | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
public void testTicksWithOverflow() { | ||
get("/tests/ticks-overflow") | ||
.then() | ||
.body(is("::::::::::")) | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
public void testEmitter() throws Throwable { | ||
Client client = ClientBuilder.newClient(); | ||
WebTarget target = client.target("http://localhost:" + RestAssured.port + "/tests/emitter"); | ||
SseEventSource eventSource = SseEventSource.target(target).build(); | ||
|
||
AtomicBoolean done = new AtomicBoolean(); | ||
AtomicReference<Throwable> failure = new AtomicReference<>(); | ||
ArrayList<String> events = new ArrayList<>(); | ||
|
||
eventSource.register( | ||
event -> events.add(event.readData()), | ||
failure::set, | ||
() -> done.set(true)); | ||
eventSource.open(); | ||
|
||
await().atMost(Duration.ofSeconds(10)) | ||
.until(() -> done.get() || failure.get() != null); | ||
|
||
if (failure.get() != null) { | ||
throw failure.get(); | ||
} | ||
|
||
ArrayList<String> expected = new ArrayList<>(); | ||
for (int i = 0; i < 5; i++) { | ||
for (int j = 0; j < i * 10; j++) { | ||
expected.add(String.valueOf(j)); | ||
} | ||
} | ||
assertIterableEquals(expected, events); | ||
} | ||
} |
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