quarkusio / quarkus

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

org.testcontainers dependencies exists in quarkus-universe-bom #9968

Closed juangon closed 3 years ago

juangon commented 4 years ago

Describe the bug It seems that it isn't possible to upgrade org.testcontainers:mariadb or other container dependencies to 1.14.3 in a custom project.

Workaround is to explicitely add root org.test.container dependency in pom.xml

Expected behavior No errors when using any container getJdbcUrl() method after upgrading org.testcontainers:mariadb to 1.14.3

Actual behavior Error while executing tests are thrown:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.NoSuchMethodError: java.lang.String org.testcontainers.containers.MariaDBContainer.getHost()

To Reproduce Steps to reproduce the behavior:

  1. Add org.testcontainers:mariadb:1.14.3 as a test dependency in pom.xml
  2. Add MariaDBContainer (or any other one) in a class extending QuarkusTestResourceLifecycleManager
  3. Add needed code to start/stop container in the previously created DB resource class, and return container.getJdbcUrl() in overriden start method as quarkus.datasource.jdbc.url property.
  4. Start tests.

Configuration

# Add your application.properties here, if applicable.

Screenshots (If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

Additional context (Add any other context about the problem here.)

gsmet commented 4 years ago

@juangon could you prepare a simple reproducer? Thanks.

geoand commented 4 years ago

I thought we removed it...

famod commented 4 years ago

I can confirm that there are various testcontainers entries in the universe BOM: https://repo1.maven.org/maven2/io/quarkus/quarkus-universe-bom/1.5.2.Final/quarkus-universe-bom-1.5.2.Final.pom

I had a litte "fun" with https://github.com/quarkusio/quarkus-platform/blob/master/bom/runtime/pom.xml and I was able to narrow it down. The following listing shows which BOM is dragging in which testcontainers dependency:

quarkus-hazelcast-client-bom:

        <groupId>org.testcontainers</groupId>
        <artifactId>testcontainers</artifactId>
        <version>1.12.4</version>

        <groupId>org.testcontainers</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>1.12.4</version>

        <groupId>org.testcontainers</groupId>
        <artifactId>postgresql</artifactId>
        <version>1.12.4</version>

kogito-bom:

        <groupId>org.testcontainers</groupId>
        <artifactId>testcontainers</artifactId>
        <version>1.12.4</version>

        <groupId>org.testcontainers</groupId>
        <artifactId>kafka</artifactId>
        <version>1.12.4</version>

cassandra-quarkus-bom:

        <groupId>org.testcontainers</groupId>
        <artifactId>cassandra</artifactId>
        <version>1.12.4</version>

I am not sure whether the cassandra bit is problematic since it doesn't pull in the main testcontainers artifact.

And now another "fun" part: https://issues.apache.org/jira/browse/MNG-5600 Meaning no exclusions for BOM imports and that means (AFAICS) that testcontainers has to be removed from the respective upstream BOMs.

Edit: Or the maven-replacer-plugin is utilized to remove all testcontainers deps...

geoand commented 3 years ago

testcontainers won't be removed from the BOM as we rely on it for DevServices