Skip to content

Commit 095b025

Browse files
authored
Build, test, and tooling improvements (#52)
1 parent 9ccb5a2 commit 095b025

File tree

6 files changed

+128
-10
lines changed

6 files changed

+128
-10
lines changed

.github/workflows/experimental.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
distribution: [ 'temurin' ]
14-
java: [ '23', '24-ea', '25-ea' ]
14+
java: [ '25' ]
1515
os: [ubuntu-latest, macos-latest, windows-latest]
1616
steps:
1717
- name: Checkout Sources
@@ -22,7 +22,7 @@ jobs:
2222
distribution: ${{ matrix.distribution }}
2323
java-version: ${{ matrix.java }}
2424
- name: Build with Maven
25-
run: mvn -B -ntp -T 1 install
25+
run: mvn -B -ntp -T 1 -Denforced.java.version=[21,26) install
2626
result:
2727
if: ${{ always() }} && github.repository == 'eclipse-ee4j/piranha'
2828
runs-on: ubuntu-latest

.github/workflows/tck-coreprofile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ jobs:
5757
mvn -B -fae -ntp install
5858
- name: Test Summary
5959
uses: test-summary/action@v2
60+
id: test_summary
6061
with:
6162
paths: |
6263
test/tck/coreprofile/cdi/runner/core/target/surefire-reports/junitreports/TEST-*.xml
6364
test/tck/coreprofile/cdi/runner/model/target/surefire-reports/TEST-*.xml
65+
output: test-summary.md
66+
if: always()
67+
- name: Job Summary
68+
run: |
69+
echo "${{ steps.test_summary.outputs.passed }} out of ${{ steps.test_summary.outputs.total }} tests passed" >> $GITHUB_STEP_SUMMARY
6470
if: always()
6571
coreprofile:
6672
if: github.repository == 'eclipse-ee4j/piranha'

docker/coreprofile/src/test/java/cloud/piranha/docker/coreprofile/CoreProfileIT.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import org.junit.jupiter.api.Test;
44
import org.testcontainers.containers.GenericContainer;
5+
import org.testcontainers.containers.wait.strategy.Wait;
56
import org.testcontainers.utility.DockerImageName;
67

7-
import java.io.IOException;
88
import java.net.URI;
99
import java.net.http.HttpClient;
1010
import java.net.http.HttpRequest;
@@ -17,16 +17,19 @@ public class CoreProfileIT {
1717

1818
/**
1919
* Test to verify that the Docker container for Piranha Core Profile starts correctly,
20-
* maps port 8080, and responds with a status code 200 when accessed via HTTP.
21-
*
20+
* maps port 8080, and responds with a status code 404 when accessed via HTTP.
21+
* A 404 is expected because no application is deployed; it confirms the server
22+
* started and is accepting connections.
23+
*
2224
* @throws Exception when a serious error occurs.
2325
*/
2426
@Test
2527
public void testBasicFunctionality() throws Exception {
2628
try (GenericContainer<?> container = new GenericContainer<>(
2729
DockerImageName.parse("ghcr.io/piranhacloud/coreprofile:latest"))
28-
.withExposedPorts(8080)) {
29-
30+
.withExposedPorts(8080)
31+
.waitingFor(Wait.forHttp("/").forStatusCode(404))) {
32+
3033
container.start();
3134

3235
Integer mappedPort = container.getMappedPort(8080);
@@ -37,7 +40,7 @@ public void testBasicFunctionality() throws Exception {
3740
.uri(URI.create("http://localhost:" + mappedPort))
3841
.build();
3942
HttpResponse<Void> response = client.send(request, HttpResponse.BodyHandlers.discarding());
40-
assertEquals(200, response.statusCode(), "Response code should be 200");
43+
assertEquals(404, response.statusCode(), "Response code should be 404");
4144
}
4245
}
4346
}

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<shrinkwrap-resolver.version>3.3.3</shrinkwrap-resolver.version>
127127
<soteria.version>4.0.2</soteria.version>
128128
<spring-boot.version>3.5.7</spring-boot.version>
129-
<testcontainers.version>2.0.1</testcontainers.version>
129+
<testcontainers.version>2.0.3</testcontainers.version>
130130
<transact-cdi-beans.version>1.0.1</transact-cdi-beans.version>
131131
<tyrus.version>2.2.0</tyrus.version>
132132
<undertow.version>2.3.21.Final</undertow.version>
@@ -172,6 +172,7 @@
172172
<versions-maven-plugin.version>2.20.1</versions-maven-plugin.version>
173173
<!-- other -->
174174
<java.version>21</java.version>
175+
<enforced.java.version>[21,22)</enforced.java.version>
175176
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
176177
</properties>
177178
<dependencyManagement>
@@ -884,7 +885,7 @@
884885
<version>3.8.7</version>
885886
</requireMavenVersion>
886887
<requireJavaVersion>
887-
<version>${java.version}</version>
888+
<version>${enforced.java.version}</version>
888889
</requireJavaVersion>
889890
</rules>
890891
</configuration>

scripts/coreprofile_rest_tck.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env bash
2+
# Runs the Core Profile REST TCK runner with a 30-minute timeout, then parses
3+
# the failsafe XML reports and writes all failing test identifiers to
4+
# failing_test_coreprofile_rest_tck.txt in the workspace root.
5+
#
6+
# Usage:
7+
# ./scripts/coreprofile_rest_tck.sh [timeout_seconds]
8+
#
9+
# Examples:
10+
# ./scripts/coreprofile_rest_tck.sh # default 3-hour timeout
11+
# ./scripts/coreprofile_rest_tck.sh 3600 # 1-hour timeout
12+
#
13+
# To re-run a single failing test afterwards:
14+
# cd test/tck/coreprofile/rest/runner
15+
# mvn verify -Dit.test="ClassName#methodName"
16+
17+
set -uo pipefail
18+
19+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
20+
RUNNER_DIR="$SCRIPT_DIR/../test/tck/coreprofile/rest/runner"
21+
REPORTS_DIR="$RUNNER_DIR/target/failsafe-reports"
22+
OUTPUT_FILE="$SCRIPT_DIR/coreprofile_rest_tck.txt"
23+
TIMEOUT_SECONDS="${1:-10800}" # default: 3 hours
24+
25+
echo "========================================="
26+
echo " Core Profile REST TCK Runner"
27+
echo " Timeout: ${TIMEOUT_SECONDS}s (3 hours)"
28+
echo "========================================="
29+
echo ""
30+
31+
# Run Maven with a timeout; -fae keeps going after failures so all reports
32+
# are generated even when individual tests fail.
33+
echo "Starting: mvn verify -fae"
34+
echo ""
35+
36+
# Use a background process + timeout guard so we can kill the whole Maven
37+
# process tree if the deadline is reached.
38+
mvn verify -fae -f "$RUNNER_DIR/pom.xml" &
39+
MVN_PID=$!
40+
41+
# Wait up to TIMEOUT_SECONDS for Maven to finish naturally.
42+
ELAPSED=0
43+
INTERVAL=5
44+
TIMED_OUT=0
45+
46+
while kill -0 "$MVN_PID" 2>/dev/null; do
47+
sleep $INTERVAL
48+
ELAPSED=$((ELAPSED + INTERVAL))
49+
if (( ELAPSED >= TIMEOUT_SECONDS )); then
50+
echo ""
51+
echo "WARN: Timeout of ${TIMEOUT_SECONDS}s reached — killing Maven process tree..."
52+
# Kill the entire process group so forked JVMs are also terminated.
53+
kill -- -"$MVN_PID" 2>/dev/null || kill "$MVN_PID" 2>/dev/null || true
54+
TIMED_OUT=1
55+
break
56+
fi
57+
done
58+
59+
# Reap the background process (ignore its exit code; we care about reports).
60+
wait "$MVN_PID" 2>/dev/null || true
61+
62+
echo ""
63+
if (( TIMED_OUT )); then
64+
echo "NOTE: TCK was stopped after ${TIMEOUT_SECONDS}s. Parsing partial results."
65+
else
66+
echo "TCK run finished after ${ELAPSED}s. Parsing results."
67+
fi
68+
echo ""
69+
70+
# ---- Parse failsafe XML reports ----------------------------------------
71+
if [[ ! -d "$REPORTS_DIR" ]]; then
72+
echo "ERROR: No failsafe reports found at $REPORTS_DIR"
73+
exit 1
74+
fi
75+
76+
python3 - "$REPORTS_DIR" "$OUTPUT_FILE" <<'PYEOF'
77+
import sys
78+
import os
79+
import xml.etree.ElementTree as ET
80+
81+
reports_dir = sys.argv[1]
82+
output_file = sys.argv[2]
83+
84+
failing = []
85+
86+
for fname in sorted(os.listdir(reports_dir)):
87+
if not (fname.startswith("TEST-") and fname.endswith(".xml")):
88+
continue
89+
path = os.path.join(reports_dir, fname)
90+
try:
91+
tree = ET.parse(path)
92+
except ET.ParseError as e:
93+
print(f" WARN: could not parse {fname}: {e}", file=sys.stderr)
94+
continue
95+
root = tree.getroot()
96+
for tc in root.findall("testcase"):
97+
if tc.find("failure") is not None or tc.find("error") is not None:
98+
classname = tc.get("classname", "")
99+
name = tc.get("name", "")
100+
failing.append(f"{classname}#{name}")
101+
102+
with open(output_file, "w") as f:
103+
for t in failing:
104+
f.write(t + "\n")
105+
106+
print(f"Found {len(failing)} failing test(s). Written to {output_file}")
107+
PYEOF

scripts/coreprofile_rest_tck.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file will be filled in by its sibling script

0 commit comments

Comments
 (0)