quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.64k stars 2.64k forks source link

DevServices fixed port and continuous test conflicts on port, user experience #43655

Open Perdjesk opened 1 day ago

Perdjesk commented 1 day ago

Description

When a port is fixed for a DevService, testing through Quarkus Dev "Continuous Testing" becomes inoperative as well as running ad-hoc tests from IDE, because a conflict on the port arise.

For example setting up the port for datasource DevService:

quarkus.datasource.devservices.port=55432

See: https://quarkus.io/guides/databases-dev-services

Then the "Continuous Testing" and ad-hoc test from IDE will fail with:

GreetingResourceTest#testHelloEndpoint() java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor#launchDatabases threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image docker.io/postgres:14

[...]

Caused by: com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"driver failed programming external connectivity on endpoint jovial_hellman (c4e602093d70ae3fabcbf99e89d7719617dbd3840ca8ae479a02595374a07ec7): Bind for 0.0.0.0:55432 failed: port is already allocated"}

The "solution" is to split configuration of DevService port between dev and test:

%dev.quarkus.datasource.devservices.port=55432

However this might not be straightforward for new users following Quarkus guides which are only referring to quarkus.datasource.devservices.port.

Note: this will work when testcontainers.reuse.enable is set to true as the same container will be reused between test and dev. However this is not enabled by default.

Implementation ideas

No response

quarkus-bot[bot] commented 1 day ago

/cc @geoand (devservices), @stuartwdouglas (devservices)

geoand commented 5 hours ago

Thanks for reporting.

Perhaps we should add note about this in the documentation, WDYT?