Skip to content

Commit 0d3e20c

Browse files
author
Mark Pollack
committed
Quarkus tests: a random port instead of the fixed 8081
Parallel builds collided on Quarkus's default test port. The deployment tests run with quarkus.http.test-port=0; the integration tests take a free port from a global test resource, since the client bean's URI is resolved before a random port is bound.
1 parent a687d37 commit 0d3e20c

5 files changed

Lines changed: 52 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,13 @@ Found by measuring coverage with JaCoCo; each has a test.
16631663

16641664
### Build
16651665

1666+
- **The Quarkus tests no longer bind the fixed port 8081.** Quarkus serves `@QuarkusTest` and
1667+
`QuarkusUnitTest` applications on `quarkus.http.test-port`, 8081 by default, so two builds on one
1668+
machine (or anything else on 8081) failed with "Port already bound: 8081". The deployment
1669+
module's tests now run with `quarkus.http.test-port=0`, a random port, and the integration tests
1670+
on a free port a test resource picks (the client bean's URI is read at startup, before a random
1671+
port is known). The tests read the bound port through `@TestHTTPResource`.
1672+
16661673
- **Spring Boot's configuration metadata is written on JDK 21 and later too.** The `errorprone`
16671674
profile (JDK 21+) sets the compiler's processor path to Error Prone and NullAway, which turns off
16681675
discovering processors on the classpath, so `acp-spring-boot-autoconfigure` built on JDK 21 had

‎acp-quarkus-deployment/pom.xml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
<configuration>
113113
<systemPropertyVariables>
114114
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
115+
<!-- A random port, not Quarkus's fixed test port 8081, so that parallel
116+
builds on one machine do not collide; the tests read the port the
117+
server bound (@TestHTTPResource). -->
118+
<quarkus.http.test-port>0</quarkus.http.test-port>
115119
</systemPropertyVariables>
116120
</configuration>
117121
</plugin>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
greeting.prefix=Hello from Quarkus
22
# The packaged application (prod) is a stdio agent; @QuarkusTest serves the same agent over HTTP.
33
%test.quarkus.acp.agent.transport.type=http
4-
# The client bean, in tests: a Quarkus ACP client of the same application's agent.
4+
# The client bean, in tests: a Quarkus ACP client of the same application's agent. The test port
5+
# is a free one FreeTestPort picks, not Quarkus's fixed 8081, so that parallel builds do not collide.
56
%test.quarkus.acp.client.transport.http.uri=http://localhost:${quarkus.http.test-port}/acp

‎acp-quarkus-integration-tests/src/test/java/com/agentclientprotocol/sdk/quarkus/it/ClientBeanTest.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.agentclientprotocol.sdk.client.AcpSyncClient;
1010
import com.agentclientprotocol.sdk.spec.AcpSchema;
11+
import io.quarkus.test.common.TestResourceScope;
12+
import io.quarkus.test.common.WithTestResource;
1113
import io.quarkus.test.junit.QuarkusTest;
1214
import jakarta.inject.Inject;
1315
import org.junit.jupiter.api.Test;
@@ -19,6 +21,7 @@
1921
* and customized by a bean, against the application's own agent over Streamable HTTP.
2022
*/
2123
@QuarkusTest
24+
@WithTestResource(value = FreeTestPort.class, scope = TestResourceScope.GLOBAL)
2225
class ClientBeanTest {
2326

2427
@Inject
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2025-2026 the original author or authors.
3+
*/
4+
5+
package com.agentclientprotocol.sdk.quarkus.it;
6+
7+
import java.io.IOException;
8+
import java.io.UncheckedIOException;
9+
import java.net.ServerSocket;
10+
import java.util.Map;
11+
12+
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
13+
14+
/**
15+
* Serves the tests on a free port instead of Quarkus's fixed test port 8081, so that two builds on
16+
* one machine do not collide. Not {@code quarkus.http.test-port=0}: the client bean's URI,
17+
* {@code quarkus.acp.client.transport.http.uri}, is read when the application starts, before the
18+
* server has bound a random port, so it would name port 0. A port picked here is known to both.
19+
*/
20+
public class FreeTestPort implements QuarkusTestResourceLifecycleManager {
21+
22+
@Override
23+
public Map<String, String> start() {
24+
try (ServerSocket socket = new ServerSocket(0)) {
25+
return Map.of("quarkus.http.test-port", String.valueOf(socket.getLocalPort()));
26+
}
27+
catch (IOException ex) {
28+
throw new UncheckedIOException(ex);
29+
}
30+
}
31+
32+
@Override
33+
public void stop() {
34+
}
35+
36+
}

0 commit comments

Comments
 (0)