Detect and verify JVM AOT cache recording during integration tests - #37124
Open
vpelikh wants to merge 2 commits into
Open
Detect and verify JVM AOT cache recording during integration tests#37124vpelikh wants to merge 2 commits into
vpelikh wants to merge 2 commits into
Conversation
Introduce an AotCacheTestExecutionListener that is registered by default and activates automatically when the test JVM is started with AOT cache recording enabled via the JDK 25+ -XX:AOTCacheOutput=<path> flag (injected by the Spring Boot Maven or Gradle plugins). When active, the listener validates the JDK version and the application class loader, eagerly loads the ApplicationContext so that context creation is captured as part of the training workload, warns if spring.context.exit=onRefresh is set, and verifies on JVM exit that the cache file was produced at the path specified by the -XX:AOTCacheOutput flag. Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Author
|
CC @sdeleuze |
Update TestExecutionListenersTests to include the new AotCacheTestExecutionListener in the expected default listener lists, and remove an unused jspecify NonNull import from AotCacheTestExecutionListenerTests that failed checkstyle. Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Author
|
Fixed CI failures in 57d0ee0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce
AotCacheTestExecutionListener, registered by default in the TestContext framework. It activates automatically when the test JVM is started with AOT cache recording enabled via the JDK 25+ single-step-XX:AOTCacheOutput=<path>flag, injected by the Spring Boot Maven or Gradle plugins.The JVM performs the actual cache generation. This listener coordinates the training run and verifies the outcome:
ApplicationContextso that context creation is captured as part of the training workload.-Dspring.context.exit=onRefreshis set, since it would terminate the test JVM mid-run.-XX:AOTCacheOutputflag.Why
This PR is part of #36774. Generating the JVM AOT cache from integration tests lets a realistic test suite exercise a broader portion of the application's startup and request-handling workflow than a simple
-Dspring.context.exit=onRefreshrun, producing a more effective cache. The cache also stores method profiling information, so exercising realistic code paths improves warmup behavior as well.How it works
RuntimeMXBean.getInputArguments().aot-cache/application.aotrelative to the test working directory, matching the location detected by the Paketo Spring Boot buildpack and bundled into the image by the Spring Boot build plugins.Documentation
integration/aot-cache.adoc: new "Generating the cache from integration tests" section.testcontext-framework/tel-config.adocandTestExecutionListenerjavadoc: added the listener to the default listener list.Notes
Related PRs
aotCacheRecordoption that injects the-XX:AOTCacheOutputJVM flag into the test JVM forked by the plugin, so that running tests also records the AOT cache. The PR was closed and needs to be recreated to provide full support for generating the cache from integration tests.