Repository navigation
Flush the Introspector after each TCK spec with the test listener - #16868
Conversation
jamesfredley
left a comment
There was a problem hiding this comment.
The listener is on the test runtime classpath of the TCK modules, including the four that do not apply test-config.gradle. It still flushes the Introspector cache after each test class, cleanupSpec no longer does that flush, and the additions stay on test configurations.
sbglasius
left a comment
There was a problem hiding this comment.
This an AI assisted review
Looks good. One line in grails-data-tck-config.gradle covers all five TCK modules. The Mongo and Neo4j super.cleanupSpec() calls are harmless now. The red Forge checks failed on a 429 from repo.grails.org, not on this change.
Some points, none blocking:
- External datastores that run the published TCK lose the flush. It cost nothing measurable in
cleanupSpec(), so could you say in the commit message why it was removed? GrailsDataTckManagerSpeconly proves the listener is on hibernate5-core's classpath, so its name could say that rather than "a TCK suite".- Nit:
Class.forName('org.junit.platform.launcher.TestExecutionListener')would avoid the newtestCompileOnlydependency.
GrailsDataTckManager.cleanupSpec() flushed the Introspector's caches after each TCK spec, and grails-test-listener flushes them after every test class. grails-data-tck-config.gradle puts the listener on the test runtime classpath of the modules that run the TCK, four of which do not apply test-config.gradle, and cleanupSpec() is a noop again. Their specs that are not TCK specs get the flush as well. GrailsDataTckManagerSpec checks that the hibernate5-core TCK suite runs with the listener. With the listener on these classpaths, the flush in cleanupSpec() only repeated it after each TCK spec, and a manager that overrides cleanupSpec() had to call super.cleanupSpec() to keep it. The cost is that a datastore outside this repository that runs the published TCK gets no flush from it, since grails-test-listener is not published. The flush in cleanupSpec() is not in a release yet, so none relies on it.
9e63487 to
b3818ce
Compare
|
Thanks! I've amended the commit for the first two:
|
✅ All tests passed ✅🏷️ Commit: b3818ce Learn more about TestLens at testlens.app/docs. |
Description
#16834 flushes the Introspector's caches in
GrailsDataTckManager.cleanupSpec(), after each TCK spec. #16837 addedgrails-test-listener, which flushes them after every test class of the modules that applygradle/test-config.gradle. Of the five modules that run the TCK, onlygrails-datamapping-core-testapplies it.grails-data-hibernate5-core,grails-data-hibernate7-core,grails-data-mongodb-coreandgrails-data-neo4j-corehave test scripts of their own. This moves the TCK suites to the listener:gradle/grails-data-tck-config.gradle, which all five apply, puts the listener on their test runtime classpath.GrailsDataTckManager.cleanupSpec()is a noop again, as before Release the Introspector's BeanInfo cache after each TCK spec #16834. Its Javadoc, which told a manager that overrides it to callsuper.cleanupSpec()or lose the flush, goes. The Mongo and Neo4j managers still call it.GrailsDataTckManagerSpecchecks that the hibernate5-core TCK suite runs with the listener, where it checked the flush incleanupSpec()before. Its module puts the JUnit Platform launcher on its test compile classpath forTestExecutionListener.The specs of these modules that aren't TCK specs get the flush as well.
grails-datamapping-tckis published andgrails-test-listenerisn't, so a datastore outside this repository that runs the published TCK doesn't get the flush from it. #16834 isn't in a release yet.Verification
The tests of the five modules pass on 8.0.x: hibernate5-core 225 classes and 1,165 tests, hibernate7-core 456 and 4,463, mongodb-core 246 and 1,026, neo4j-core 126 and 616, datamapping-core-test 148 and 685.
grails-test-listeneris on the test runtime classpath of each../gradlew clean aggregateViolations --continuepasses.:grails-data-hibernate7-core:test, the suite that ran out of heap before Release the Introspector's BeanInfo cache after each TCK spec #16834, runs in one JVM with Gradle's default 512 MB heap. I measured it with this change on Keep unit test JVMs for the whole task, flushing the Introspector after each class #16837's branch, with 8.0.x merged in for Release the Introspector's BeanInfo cache after each TCK spec #16834, before Keep unit test JVMs for the whole task, flushing the Introspector after each class #16837 was merged; it had 452 specs then. A probe listener, which is not part of this PR, recorded the live heap after a full GC before each spec, with the flush in the listener (this PR), incleanupSpec()(8.0.x), and nowhere:cleanupSpec()The three runs passed the same 4,338 tests.
Test performance
The listener takes no measurable time. On the same base as the heap measurements, I ran each module's
testtask with--rerun, one task at a time, with-PmaxTestParallel=4, without the probe and with-Xlog:gcon every test JVM, on a 72-thread machine with JDK 21. hibernate7-core ran twice per variant and the other modules once. The test time runs from the start of the first spec to the end of the last, from the JUnit XML reports; the GC figures add up all of the task's JVMs.cleanupSpec()cleanupSpec()cleanupSpec()cleanupSpec()cleanupSpec()forkEvery = 10.