quarkusio / quarkus

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

Neo4j Dev Service image cannot be substituted with custom-built image #20945

Closed languitar closed 2 years ago

languitar commented 2 years ago

Describe the bug

The Neo4j dev service has a property quarkus.neo4j.devservices.image-name to substitute the used Neo4j Docker image with a custom one. However, this property is currently only of limit usefulness, because the dev service -- in contrast to other dev services -- does not declare the provided image as a compatible subsitution to testcontainers.

Expected behavior

Any image that I deliberately provide as a Neo4j substitution is accepted and used.

Actual behavior

java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.neo4j.deployment.Neo4jDevServicesProcessor#startNeo4jDevService threw an exception: java.lang.RuntimeException: java.lang.IllegalStateException: Failed to verify that image 'registry.gitlab.com/xxx/neo4j-with-plugins:v4.4.9' is a compatible substitute for 'neo4j'. This generally means that you are trying to use an image that Testcontainers has not been designed to use. If this is deliberate, and if you are confident that the image is compatible, you should declare compatibility in code using the `asCompatibleSubstituteFor` method. For example:
   DockerImageName myImage = DockerImageName.parse("registry.gitlab.com/xxx/neo4j-with-plugins:v4.4.9").asCompatibleSubstituteFor("neo4j");
and then use `myImage` instead.
    at io.quarkus.neo4j.deployment.Neo4jDevServicesProcessor.startNeo4jDevService(Neo4jDevServicesProcessor.java:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:829)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalStateException: Failed to verify that image 'registry.gitlab.com/xxx/neo4j-with-plugins:v4.4.9' is a compatible substitute for 'neo4j'. This generally means that you are trying to use an image that Testcontainers has not been designed to use. If this is deliberate, and if you are confident that the image is compatible, you should declare compatibility in code using the `asCompatibleSubstituteFor` method. For example:
   DockerImageName myImage = DockerImageName.parse("registry.gitlab.com/xxx/neo4j-with-plugins:v4.4.9").asCompatibleSubstituteFor("neo4j");
and then use `myImage` instead.
    at org.testcontainers.utility.DockerImageName.assertCompatibleWith(DockerImageName.java:248)
    at org.testcontainers.containers.Neo4jContainer.<init>(Neo4jContainer.java:91)
    at org.testcontainers.containers.Neo4jContainer.<init>(Neo4jContainer.java:77)
    at io.quarkus.neo4j.deployment.Neo4jDevServicesProcessor.startNeo4j(Neo4jDevServicesProcessor.java:130)
    at io.quarkus.neo4j.deployment.Neo4jDevServicesProcessor.startNeo4jDevService(Neo4jDevServicesProcessor.java:72)
    ... 11 more

How to Reproduce?

mvn io.quarkus.platform:quarkus-maven-plugin:2.3.1.Final:create \
          -DprojectGroupId=org.acme \
          -DprojectArtifactId=neo4j-quickstart \
          -DclassName="org.acme.datasource.GreetingResource" \
          -Dextensions="resteasy,neo4j,resteasy-jackson,neo4j"

cd neo4j-quickstart

echo "quarkus.neo4j.devservices.image-name = debian:buster" >> ./src/main/resources/application.properties

mvn verify

Output of uname -a or ver

Linux pres 5.10.75-1-lts #1 SMP Wed, 20 Oct 2021 11:02:09 +0000 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment (build 11.0.12+7) OpenJDK 64-Bit Server VM (build 11.0.12+7, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

see commands above

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

maven

Additional information

Something like https://github.com/quarkusio/quarkus/blob/main/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java#L68 is missing for the Neo4j dev service. Support for any kind of image substitution seems to have been added for other dev services with https://github.com/quarkusio/quarkus/pull/15939 but Neo4j didn't exist at that point in time.

quarkus-bot[bot] commented 2 years ago

/cc @michael-simons