quarkusio / quarkus

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

Integration test fails when using mongo as custom test resource instead of Dev Service #36300

Closed iompo closed 1 year ago

iompo commented 1 year ago

Describe the bug

I defined a QuarkusTestResourceLifecycleManager that start a mongo instance and set the quarkus.mongodb.devservices.enabled to false. The test fails without even trying to start the mongo container.

Expected behavior

Test run should start the mongo container first and then run the test

Actual behavior

Test fails without trying to start the mongo container

How to Reproduce?

https://github.com/iompo/mongo-custom-test-resource

Output of uname -a or ver

No response

Output of java -version

OpenJDK Runtime Environment Temurin-11.0.16.1+1

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.4.1

Build tool (ie. output of mvnw --version or gradlew --version)

gradle 8.1.1

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @evanchooly (mongodb), @geoand (devservices), @loicmathieu (mongodb), @stuartwdouglas (devservices)

geoand commented 1 year ago

The problem is in your MongoResource.

You need to do:

String connectionUrl = String.format("mongodb://%s:%s@%s:%d", USERNAME, PASSWORD,container.getContainerName().substring(1), DB_PORT);

instead of what you are currently doing.

iompo commented 1 year ago

Hi @geoand, I tried, but that doesn't seem to solve the issue. The start method is never called.

iompo commented 1 year ago

I've updated the reproducer with the connection url fix. The test fails but no container is started and the mongo image is never pulled from the registry.