Skip to content

Conversation

holly-cummins
Copy link
Contributor

@holly-cummins holly-cummins commented May 9, 2025

Used for resetting at the end of QuarkusTests and avoid having two code paths both trying to do TCCL-ing.

At first glance, #47657 looked simple. The cause was that we weren't resetting the TCCL back to to the system classloader at the end of quarkus test execution, so plain tests were then being run with the QuarkusClassLoader, which did not work well.

Digging into it, it became clear it was a bit more complex. By the time the QuarkusTestExtension methods run, the TCCL is already set to be a runtime classloader, so any resetting is pointless. The pre-set of the TCCL was introduced in #47379. Even though it was my code it took me a while in the debugger to figure out where it was being set, so I've added some comments. The un-set in the extension listener should work to reset everything, but in nested tests, the 'old' classloader gets overwritten. I've switched to using a stack, which should help with this.

I've also removed a whole bunch of TCCL-setting in QuarkusTestExtension, since we now have the 'super-wrapper' around the whole test which sets and resets the TCCL. Having other TCCL-setting is a no-op and just adds to the code complexity.

@holly-cummins holly-cummins changed the title Use a stack for the TCCL Use a stack to store the TCCL for resetting at the end of QuarkusTests May 9, 2025
@holly-cummins holly-cummins force-pushed the reset-tccl-after-quarkus-test branch from 52856a0 to 0ae7d5e Compare May 9, 2025 19:52
@quarkus-bot

This comment has been minimized.

@holly-cummins holly-cummins added the ci/test-platform CI will run a Platform build consuming the Core changes and report the results label May 10, 2025
@holly-cummins holly-cummins force-pushed the reset-tccl-after-quarkus-test branch from 0ae7d5e to cb46de5 Compare May 10, 2025 10:28
@quarkus-bot

This comment has been minimized.

@geoand geoand changed the title Use a stack to store the TCCL for resetting at the end of QuarkusTests Use a stack to store the TCCL May 12, 2025
@geoand
Copy link
Contributor

geoand commented May 12, 2025

Thanks a lot for this!

I've relaunched CI in order to see if the failures are related or just flaky tests

@holly-cummins
Copy link
Contributor Author

Thanks a lot for this!

I've relaunched CI in order to see if the failures are related or just flaky tests

I had a green CI, but then I switched from Stack to Deque, and added the platform tests. We run the platform ci rather rarely, so it could be something else which has caused the failures (although, let's face it, it's a classloading failure in tests, so this change is the most likely suspect :) ). The spring failure looks like a GitHub CI glitch.

I'll have a go at reproducing the camel failures locally.

@geoand
Copy link
Contributor

geoand commented May 12, 2025

👌🏽

@quarkus-bot

This comment has been minimized.

@holly-cummins
Copy link
Contributor Author

holly-cummins commented May 12, 2025

Actually, having looked at these failures locally, I'm confident it's unrelated to my changes. I'm not seeing the runtime error, instead I'm seeing a compilation error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.14.0:testCompile (default-testCompile) on project camel-quarkus-integration-test-kubernetes: Compilation failure: Compilation failure: 
[ERROR] /Users/holly/Code/quarkus/camel-quarkus/integration-tests/kubernetes/src/test/java/org/apache/camel/quarkus/component/kubernetes/it/KubernetesConfigMapTest.java:[24,48] cannot find symbol
[ERROR]   symbol:   class KubernetesServer
[ERROR]   location: package io.fabric8.kubernetes.client.server.mock

In the CI, java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer happens because KubernetesServer has gone away. The commit that moved quarkus to a version of the kubernetes client without that file is e114f81; camel-quarkus has adjusted to the new package name in apache/camel-quarkus@cbcbd65 but we won't see the fix in our CI until the camel upgrade merges.

@holly-cummins holly-cummins requested a review from geoand May 12, 2025 11:03
@holly-cummins holly-cummins force-pushed the reset-tccl-after-quarkus-test branch from cb46de5 to 741719e Compare May 12, 2025 11:25
Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@geoand geoand added triage/backport triage/waiting-for-ci Ready to merge when CI successfully finishes labels May 12, 2025
@quarkus-bot
Copy link

quarkus-bot bot commented May 12, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 741719e.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
Platform Tests - JDK 17 Test Platform Failures Logs Raw logs 🚧

Full information is available in the Build summary check run.
You can consult the Develocity build scans.

Failures

⚙️ Platform Tests - JDK 17 #

- Failing: Root module 

📦 Root module

Failed to execute goal io.quarkus:quarkus-platform-bom-maven-plugin:0.0.120:invoke-platform-project (build-platform-project) on project quarkus-platform-config: Failed to build the platform project, please consult the errors logged above.

📦 quarkus-platform/generated-platform-project/quarkus-camel/integration-tests/camel-quarkus-integration-test-kubernetes

org.apache.camel.quarkus.component.kubernetes.it.KubernetesConfigMapTest. - History - More details - Source on GitHub

java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.client.server.mock.KubernetesServer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

org.apache.camel.quarkus.component.kubernetes.it.KubernetesCustomResourceTest. - History - More details - Source on GitHub

java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.client.server.mock.KubernetesServer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

org.apache.camel.quarkus.component.kubernetes.it.KubernetesDeploymentTest. - History - More details - Source on GitHub

java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.client.server.mock.KubernetesServer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

org.apache.camel.quarkus.component.kubernetes.it.KubernetesJobTest. - History - More details - Source on GitHub

java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.client.server.mock.KubernetesServer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

org.apache.camel.quarkus.component.kubernetes.it.KubernetesPodsTest. - History - More details - Source on GitHub

java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.client.server.mock.KubernetesServer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

org.apache.camel.quarkus.component.kubernetes.it.KubernetesSecretTest. - History - More details - Source on GitHub

java.lang.NoClassDefFoundError: io/fabric8/kubernetes/client/server/mock/KubernetesServer
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.client.server.mock.KubernetesServer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

📦 quarkus-platform/generated-platform-project/quarkus-cxf/integration-tests/quarkus-cxf-integration-test-server

io.quarkiverse.cxf.it.server.ServerThreadPoolStressTest.stress line 71 - History - More details - Source on GitHub

java.util.concurrent.ExecutionException: java.lang.RuntimeException: Failed to access [/home/runner/.m2/repository/org/apache/httpcomponents/httpclient/4.5.14/httpclient-4.5.14.jar] because the FileSystem has been closed
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at io.quarkiverse.cxf.it.server.ServerThreadPoolStressTest.stress(ServerThreadPoolStressTest.java:71)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:994)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:842)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

📦 quarkus-platform/generated-platform-project/quarkus-operator-sdk/integration-tests/quarkus-operator-sdk-integration-tests

io.quarkiverse.operatorsdk.it.OperatorSDKResourceTest.allControllersShouldHaveAssociatedConfiguration - History - More details - Source on GitHub

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:662)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:757)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at io.quarkus.test.junit.TestResourceUtil$TestResourceManagerReflections.startReflectively(TestResourceUtil.java:217)

Flaky tests - Develocity

⚙️ JVM Integration Tests - JDK 21

📦 integration-tests/opentelemetry-grpc-only

io.quarkus.it.opentelemetry.grpc.HelloGrpcClientTest.testHello - History

  • java.lang.RuntimeException: Failed to start quarkus - java.lang.RuntimeException
java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:662)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:757)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)

@geoand
Copy link
Contributor

geoand commented May 12, 2025

@holly-cummins does it make sense to keep the platform tests around if they are just going to be failing until Camel releases? I can imagine this will cause folks some confusion...

@holly-cummins
Copy link
Contributor Author

@holly-cummins does it make sense to keep the platform tests around if they are just going to be failing until Camel releases? I can imagine this will cause folks some confusion...

I agree it's not ideal. They're only run if people opt-in by setting the ci/test-platform label, so most people wouldn't see them. It might be that @gsmet and @jamesnetherton can work out a 'next' branch to run against that would be clean. The Camel team are pro-active about monitoring their version of the platform CI and doing fixes, so the fix is there, just ... not here. :)

@geoand
Copy link
Contributor

geoand commented May 12, 2025

Got it, makes sense.

@geoand geoand merged commit 119f8eb into quarkusio:main May 12, 2025
57 of 58 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.23 - main milestone May 12, 2025
@quarkus-bot quarkus-bot bot removed triage/waiting-for-ci Ready to merge when CI successfully finishes ci/test-platform CI will run a Platform build consuming the Core changes and report the results labels May 12, 2025
@gsmet gsmet modified the milestones: 3.23 - main, 3.22.3 May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using nested JUnit test classes with QuarkusTest breaks non-Quarkus tests

3 participants