quarkiverse / quarkus-minio

Minio (https://min.io) Client Quarkus Extension
Apache License 2.0
16 stars 24 forks source link

Support for Quarkus integration test with docker #226

Closed andrejpetras closed 1 year ago

andrejpetras commented 1 year ago

Hi,

could you please add support for the Quarkus Docker integration tests?

We use quarkus.container-image.build=true to build a Docker image with Quarkus before running the integration tests. In the next step we will do integration tests and Quarkus will create a common network of all dev services and our application as a Docker container. Quarkus documentation: https://quarkus.io/guides/getting-started-testing#quarkus-integration-test

In this case,quarkus.minio.url should not contain the hostname and port of the Docker container on the local machine, but the hostname of the Docker container on the share network, for example: http://minio:9000.

I created this function for quarkus-mockserver: https://github.com/quarkiverse/quarkus-mockserver/blob/main/deployment/src/main/java/io/quarkiverse/mockserver/devservices/DevServicesMockServerProcessor.java#LL95C20-L95C65

Based on "!devServicesSharedNetworkBuildItem.isEmpty()" we can decide which URL we want to configure.

jtama commented 1 year ago

Doesn't this suits your need ?

https://quarkiverse.github.io/quarkiverse-docs/quarkus-minio/dev/index.html#_shared_server

andrejpetras commented 1 year ago

I'm afraid not, that's a different use case.

The quarkus.minio.url property for integration tests is set up like http://localhost:2343, which is fine if you're not using Docker but only JVM (jar)

If we use the Quarkus property "quarkus.container-image.build=true", the integration tests launch the application as a Docker container in the shared network with other development services. In this case, "quarkus.minio.url" must be set up for the Minio service on the Docker network http://minio:9000 because the application and minio are running as docker container in the same network.

https://quarkus.io/guides/getting-started-testing#quarkus-integration-test

@QuarkusIntegrationTest should be used to launch and test the artifact produced by the Quarkus build, and supports testing a jar (of whichever type), a native image or container image. Put simply, this means that if the result of a Quarkus build (mvn package or gradle build) is a jar, that jar will be launched as java -jar …​ and tests run against it. If instead a native image was built, then the application is launched as ./application …​ and again the tests run against the running application. Finally, if a container image was created during the build (by including the quarkus-container-image-jib or quarkus-container-image-docker extensions and having the quarkus.container-image.build=true property configured), then a container is created and run (this requires the docker executable being present).