Skip to content

Commit cf30568

Browse files
committed
fix: use system-assigned port for mockserver tests
1 parent 614f691 commit cf30568

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/it/java/io/weaviate/integration/AuthorizationITest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ public class AuthorizationITest extends ConcurrentTest {
1919
private ClientAndServer mockServer;
2020

2121
@Before
22-
public void startMockServer() {
23-
mockServer = ClientAndServer.startClientAndServer(8080);
22+
public void startMockServer() throws IOException {
23+
// MockServer does not verify exclusive ownership of the port
24+
// and using any well-known port like 8080 will produce flaky
25+
// test results with fairly confusing errors, like:
26+
//
27+
// path /mockserver/verifySequence was not found
28+
//
29+
// if another webserver is listening to that port.
30+
// We use 0 to let the underlying system find an available port.
31+
mockServer = ClientAndServer.startClientAndServer(0);
2432
}
2533

2634
@Test
2735
public void testAuthorization_apiKey() throws IOException {
2836
var transportOptions = new RestTransportOptions(
29-
"http", "localhost", 8080,
37+
"http", "localhost", mockServer.getLocalPort(),
3038
Collections.emptyMap(), Authorization.apiKey("my-api-key"));
3139

3240
try (final var restClient = new DefaultRestTransport(transportOptions)) {

0 commit comments

Comments
 (0)