-
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.
Merge pull request #35018 from ozangunalp/virtual-threads-rm-tests
- Loading branch information
Showing
38 changed files
with
1,487 additions
and
50 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,51 @@ | ||
#!/bin/bash | ||
|
||
# Purpose: Prints a filtered version of virtual-threads-tests.json, with "test-modules" reduced to the ones passed in as the first argument. | ||
# This first argument is expected to the define one module per line. | ||
# "include" elements that (after filtering) have no "test-modules" anymore are deleted entirely! | ||
# Note: This script is only for CI and does therefore not aim to be compatible with BSD/macOS. | ||
|
||
set -e -u -o pipefail | ||
shopt -s failglob | ||
|
||
# path of this shell script | ||
PRG_PATH=$( cd "$(dirname "$0")" ; pwd -P ) | ||
|
||
JSON=$(cat ${PRG_PATH}/virtual-threads-tests.json) | ||
|
||
# Step 0: print unfiltered json and exit in case the parameter is empty (assumption: full build) | ||
if [ -z "$1" ] | ||
then | ||
echo "${JSON}" | ||
exit 0 | ||
fi | ||
|
||
# Step 1: build an expression for grep that will only extract the given modules from each "test-modules" list, | ||
# including a trailing comma (if exists). Note: mvn doesn't mind something like -pl 'foo,'. | ||
EXPR='((?:(?<=^)|(?<=,)|(?<=, ))(' | ||
while read -r impacted | ||
do | ||
EXPR+="${impacted}|" | ||
done < <(echo -n "$1" | ggrep -Po '(?<=integration-tests/virtual-threads/).+') | ||
EXPR+=')(,|$))+' | ||
|
||
# Step 2: apply the filter expression via grep to each "test-modules" list and replace each original list with the filtered one | ||
while read -r modules | ||
do | ||
# Notes: | ||
# - trailing "|" (after EXPR) avoids grep return code > 0 if nothing matches (which is a valid case) | ||
# - "paste" joins all matches to get a single line | ||
FILTERED=$(echo -n "${modules}" | ggrep -Po "${EXPR}|" | paste -sd " " -) | ||
JSON=$(echo -n "${JSON}" | sed "s|${modules}|${FILTERED}|") | ||
done < <(echo -n "${JSON}" | jq -r '.include[] | ."test-modules"') | ||
|
||
# Step 3: delete entire elements from "include" array that now have an empty "test-modules" list | ||
JSON=$(echo "${JSON}" | jq 'del(.include[] | select(."test-modules" == ""))') | ||
|
||
# Step 4: echo final result, printing only {} in case _all_ elements were removed from "include" array | ||
if [ -z "$(echo "${JSON}" | jq '.include[]')" ] | ||
then | ||
echo -n '{}' | ||
else | ||
echo -n "${JSON}" | ||
fi |
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,16 @@ | ||
{ | ||
"include": [ | ||
{ | ||
"category": "Main", | ||
"timeout": 45, | ||
"test-modules": "grpc-virtual-threads, mailer-virtual-threads, redis-virtual-threads, rest-client-reactive-virtual-threads, resteasy-reactive-virtual-threads", | ||
"os-name": "ubuntu-latest" | ||
}, | ||
{ | ||
"category": "Messaging", | ||
"timeout": 45, | ||
"test-modules": "amqp-virtual-threads, jms-virtual-threads, kafka-virtual-threads", | ||
"os-name": "ubuntu-latest" | ||
} | ||
] | ||
} |
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
126 changes: 126 additions & 0 deletions
126
integration-tests/virtual-threads/amqp-virtual-threads/pom.xml
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,126 @@ | ||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>quarkus-virtual-threads-integration-tests-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-integration-test-virtual-threads-amqp</artifactId> | ||
<name>Quarkus - Integration Tests - Virtual Threads - AMQP 1.0 </name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-client-reactive</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> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-test-vertx</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-mockito</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.tomakehurst</groupId> | ||
<artifactId>wiremock-jre8-standalone</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-test-common</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-reactive-messaging-amqp-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-reactive-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-resteasy-reactive-jackson-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> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
68 changes: 68 additions & 0 deletions
68
...-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/AssertHelper.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,68 @@ | ||
package io.quarkus.it.vthreads.amqp; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.smallrye.common.vertx.VertxContext; | ||
import io.vertx.core.Vertx; | ||
|
||
public class AssertHelper { | ||
|
||
/** | ||
* Asserts that the current method: | ||
* - runs on a duplicated context | ||
* - runs on a virtual thread | ||
* - has the request scope activated | ||
*/ | ||
public static void assertEverything() { | ||
assertThatTheRequestScopeIsActive(); | ||
assertThatItRunsOnVirtualThread(); | ||
assertThatItRunsOnADuplicatedContext(); | ||
} | ||
|
||
public static void assertThatTheRequestScopeIsActive() { | ||
if (!Arc.container().requestContext().isActive()) { | ||
throw new AssertionError(("Expected the request scope to be active")); | ||
} | ||
} | ||
|
||
public static void assertThatItRunsOnADuplicatedContext() { | ||
var context = Vertx.currentContext(); | ||
if (context == null) { | ||
throw new AssertionError("The method does not run on a Vert.x context"); | ||
} | ||
if (!VertxContext.isOnDuplicatedContext()) { | ||
throw new AssertionError("The method does not run on a Vert.x **duplicated** context"); | ||
} | ||
} | ||
|
||
public static void assertThatItRunsOnVirtualThread() { | ||
// We cannot depend on a Java 20. | ||
try { | ||
Method isVirtual = Thread.class.getMethod("isVirtual"); | ||
isVirtual.setAccessible(true); | ||
boolean virtual = (Boolean) isVirtual.invoke(Thread.currentThread()); | ||
if (!virtual) { | ||
throw new AssertionError("Thread " + Thread.currentThread() + " is not a virtual thread"); | ||
} | ||
} catch (Exception e) { | ||
throw new AssertionError( | ||
"Thread " + Thread.currentThread() + " is not a virtual thread - cannot invoke Thread.isVirtual()", e); | ||
} | ||
} | ||
|
||
public static void assertThatItDoesNotRunOnVirtualThread() { | ||
// We cannot depend on a Java 20. | ||
try { | ||
Method isVirtual = Thread.class.getMethod("isVirtual"); | ||
isVirtual.setAccessible(true); | ||
boolean virtual = (Boolean) isVirtual.invoke(Thread.currentThread()); | ||
if (virtual) { | ||
throw new AssertionError("Thread " + Thread.currentThread() + " is a virtual thread"); | ||
} | ||
} catch (Exception e) { | ||
throw new AssertionError( | ||
"Thread " + Thread.currentThread() + " is a virtual thread - but cannot invoke Thread.isVirtual()", e); | ||
} | ||
} | ||
} |
Oops, something went wrong.