Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous testing fails when @QuarkusMainTest and a @ConfigMapping are involved #22792

Closed
cdhermann opened this issue Jan 11, 2022 · 3 comments · Fixed by #22809
Closed

Continuous testing fails when @QuarkusMainTest and a @ConfigMapping are involved #22792

cdhermann opened this issue Jan 11, 2022 · 3 comments · Fixed by #22809
Labels
Milestone

Comments

@cdhermann
Copy link
Contributor

Describe the bug

Running a test annotated with @QuarkusMainTest in continuous testing mode where another test tests a config mapping defined by @ConfigMapping causes the test to fail with a ClassCastException:

Caused by: java.lang.ClassCastException: class io.quarkus.test.junit.RunningAppConfigResolver$1 cannot be cast to class io.smallrye.config.SmallRyeConfig (io.quarkus.test.junit.RunningAppConfigResolver$1 and io.smallrye.config.SmallRyeConfig are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6c85b253)
        at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:241)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
        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:1452)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

It is important that the test testing the @ConfigMapping is run before the @QuarkusMainTest. The other way round the behavior couldn't be observed.

The tests pass when run with ./mvnw clean verify

Expected behavior

Tests passing when run with ./mvnw clean verify also pass when run in continuous testing mode.

Actual behavior

When a test using an injected @ConfigMapping is run before a @QuarkusMainTest the @QuarkusMainTest fails with a class cast exception:

Caused by: java.lang.ClassCastException: class io.quarkus.test.junit.RunningAppConfigResolver$1 cannot be cast to class io.smallrye.config.SmallRyeConfig (io.quarkus.test.junit.RunningAppConfigResolver$1 and io.smallrye.config.SmallRyeConfig are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6c85b253)
        at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:241)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
        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:1452)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

How to Reproduce?

  1. Download the demo at tag QuarkusMainTestFailWithConfigMapping
  2. Run quarkus dev
  3. Start tests -> fail
  4. Remove the @QuarkusMainTest -> pass
  5. Add again the @QuarkusMainTest and remove ConfigurationTest -> pass
  6. Add ConfigurationTest again
  7. Rename ConfigurationTest.java to GreetingConfigurationTest.java to ensure it is run after the @QuarkusMainTest in GreetingCommandTest.java
  8. Run the test in quarkus dev -> fail, but not because of the ClassCastException but because of what is described in LaunchResult#getOutput() behaves differently in continuous testing mode than with ./mvnw clean verify #22790
  9. Make sure the app looks the same as after the download and exit quarkus dev
  10. Run ./mvnw clean verify -> pass

Output of uname -a or ver

Darwin cdh 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:29:10 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T8101 arm64

Output of java -version

java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.2.Final

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

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: ~/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1 Java version: 17, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home Default locale: de_AT, platform encoding: UTF-8 OS name: "mac os x", version: "12.1", arch: "aarch64", family: "mac"

Additional information

No response

@cdhermann cdhermann added the kind/bug Something isn't working label Jan 11, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 11, 2022

/cc @stuartwdouglas

@gsmet gsmet added this to the 2.7 - main milestone Jan 11, 2022
@gsmet
Copy link
Member

gsmet commented Jan 11, 2022

@radcortez could you have a look at this one? It looks config related.

@radcortez
Copy link
Member

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants