-
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.
Enable native tests in CI for virtual thread tests
Move JVM 19 tests to 20
- Loading branch information
1 parent
d0e3122
commit 6ab68f5
Showing
20 changed files
with
370 additions
and
44 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
1 change: 0 additions & 1 deletion
1
integration-tests/virtual-threads/amqp-virtual-threads/disable-native-profile
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
...reads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/NoPinningVerify.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 @@ | ||
package io.quarkus.it.vthreads.amqp; | ||
|
||
import java.io.File; | ||
import java.io.FilenameFilter; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Node; | ||
import org.w3c.dom.NodeList; | ||
import org.xml.sax.SAXException; | ||
|
||
/** | ||
* An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. | ||
* It reads the reports generated by surefire. | ||
*/ | ||
public class NoPinningVerify { | ||
|
||
@Test | ||
void verify() throws IOException, ParserConfigurationException, SAXException { | ||
var reports = new File("target", "surefire-reports"); | ||
Assertions.assertTrue(reports.isDirectory(), | ||
"Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); | ||
var list = reports.listFiles(new FilenameFilter() { | ||
@Override | ||
public boolean accept(File dir, String name) { | ||
return name.startsWith("TEST") && name.endsWith("Test.xml"); | ||
} | ||
}); | ||
Assertions.assertNotNull(list, | ||
"Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); | ||
|
||
for (File report : list) { | ||
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); | ||
var suite = document.getFirstChild(); | ||
var cases = getChildren(suite.getChildNodes(), "testcase"); | ||
for (Node c : cases) { | ||
verify(report, c); | ||
} | ||
} | ||
|
||
} | ||
|
||
private void verify(File file, Node ca) { | ||
var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." | ||
+ ca.getAttributes().getNamedItem("name").getTextContent(); | ||
var output = getChildren(ca.getChildNodes(), "system-out"); | ||
if (output.isEmpty()) { | ||
return; | ||
} | ||
var sout = output.get(0).getTextContent(); | ||
if (sout.contains("VThreadContinuation.onPinned")) { | ||
throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() | ||
+ " for details (or the log of the test)"); | ||
} | ||
|
||
} | ||
|
||
private List<Node> getChildren(NodeList nodes, String name) { | ||
List<Node> list = new ArrayList<>(); | ||
for (int i = 0; i < nodes.getLength(); i++) { | ||
var node = nodes.item(i); | ||
if (node.getNodeName().equalsIgnoreCase(name)) { | ||
list.add(node); | ||
} | ||
} | ||
return list; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...s/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/VirtualThreadITCase.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.vthreads.amqp; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class VirtualThreadITCase extends VirtualThreadTest { | ||
} |
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
1 change: 0 additions & 1 deletion
1
integration-tests/virtual-threads/jms-virtual-threads/disable-native-profile
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
...threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/NoPinningVerify.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 @@ | ||
package io.quarkus.it.vthreads.jms; | ||
|
||
import java.io.File; | ||
import java.io.FilenameFilter; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Node; | ||
import org.w3c.dom.NodeList; | ||
import org.xml.sax.SAXException; | ||
|
||
/** | ||
* An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. | ||
* It reads the reports generated by surefire. | ||
*/ | ||
public class NoPinningVerify { | ||
|
||
@Test | ||
void verify() throws IOException, ParserConfigurationException, SAXException { | ||
var reports = new File("target", "surefire-reports"); | ||
Assertions.assertTrue(reports.isDirectory(), | ||
"Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); | ||
var list = reports.listFiles(new FilenameFilter() { | ||
@Override | ||
public boolean accept(File dir, String name) { | ||
return name.startsWith("TEST") && name.endsWith("Test.xml"); | ||
} | ||
}); | ||
Assertions.assertNotNull(list, | ||
"Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); | ||
|
||
for (File report : list) { | ||
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); | ||
var suite = document.getFirstChild(); | ||
var cases = getChildren(suite.getChildNodes(), "testcase"); | ||
for (Node c : cases) { | ||
verify(report, c); | ||
} | ||
} | ||
|
||
} | ||
|
||
private void verify(File file, Node ca) { | ||
var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." | ||
+ ca.getAttributes().getNamedItem("name").getTextContent(); | ||
var output = getChildren(ca.getChildNodes(), "system-out"); | ||
if (output.isEmpty()) { | ||
return; | ||
} | ||
var sout = output.get(0).getTextContent(); | ||
if (sout.contains("VThreadContinuation.onPinned")) { | ||
throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() | ||
+ " for details (or the log of the test)"); | ||
} | ||
|
||
} | ||
|
||
private List<Node> getChildren(NodeList nodes, String name) { | ||
List<Node> list = new ArrayList<>(); | ||
for (int i = 0; i < nodes.getLength(); i++) { | ||
var node = nodes.item(i); | ||
if (node.getNodeName().equalsIgnoreCase(name)) { | ||
list.add(node); | ||
} | ||
} | ||
return list; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...ads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/VirtualThreadITCase.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.vthreads.jms; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class VirtualThreadITCase extends VirtualThreadTest { | ||
} |
1 change: 0 additions & 1 deletion
1
integration-tests/virtual-threads/kafka-virtual-threads/disable-native-profile
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.