Working group proposal: Test classloading #41867
holly-cummins
started this conversation in
Design Discussions
Replies: 3 comments
-
+1 from me, and I'd be interested in joining this group. I could see this effort possibly morphing into a more general review of class loading in the future as well. |
Beta Was this translation helpful? Give feedback.
0 replies
-
+1 from me as well |
Beta Was this translation helpful? Give feedback.
0 replies
-
I can't commit to join/be regular but +1 on it being important and very curious to hear/follow progress and help testing if need arises! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal
At the moment, Quarkus tests are invoked using one classloader, and then executed in a different classloader. This mostly works well, but means some use cases don't work: extensions cannot manipulate test classes in the same way that they do normal application classes. For example, anything run via a JUnit
@TestTemplate
test case will see the un-transformed class.It also means we have extra user-facing complexity, such as the
QuarkusTest*Callback
s](https://quarkus.io/guides/getting-started-testing#enrichment-via-quarkustestcallback):A final benefit is a reduction in the internal complexity of our code. Hopping between classloaders during test execution takes a lot of work, and adds a lot of code! It also is brittle in places. For example, because the hop between classloaders relies on serialization in some cases, it's becoming harder to do as the JVM tightens up security restrictions. We used to rely on xstream, but that stopped working in Java 17. In #40601, @dmlloyd moved us to use the JBoss Serializer, which works better, but might still be affected by future restrictions on class access.
The goal of this working group is to allow test classes to fully participate in the 'quarkification' of classes. The mechanism for this is probably just to load the test classes with the classloader we intend to run them with, so that JUnit sees the 'correct' version of the class.
Progress tracking
The following GitHub issues cover the problems we're seeing:
UniAsserter
with@ParameterizedTest
#24590@QuarkusTest
method parameter fails withClassNotFoundException
#42006I'm less sure about the issues at the bottom of the list, they're "maybes".
The first big set of changes is tracked by PR #34681, although there will probably be pre-work needed to add more tests, and post-work needed to tidy up code paths, docs, and start deprecating
QuarkusTest*Callback
s if possible.Realistic Aim
This is a smaller rewrite of classloading than we've done in the past, so with proper focus, it should be achievable in a reasonable time frame.
End in Sight
This work is done when tests are loaded with the classloader they're run with, and obvious bits of vestigial code and docs have been cleaned up.
Beta Was this translation helpful? Give feedback.
All reactions