Skip to content

Flush the Introspector after each TCK spec with the test listener - #16868

Merged
matrei merged 1 commit into
apache:8.0.xfrom
matrei:build/tck-introspector-listener
Nov 5, 2026
Merged

matrei merged 1 commit into
apache:8.0.xfrom
matrei:build/tck-introspector-listener

Conversation

@matrei

@matrei matrei commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

#16834 flushes the Introspector's caches in GrailsDataTckManager.cleanupSpec(), after each TCK spec. #16837 added grails-test-listener, which flushes them after every test class of the modules that apply gradle/test-config.gradle. Of the five modules that run the TCK, only grails-datamapping-core-test applies it. grails-data-hibernate5-core, grails-data-hibernate7-core, grails-data-mongodb-core and grails-data-neo4j-core have 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 call super.cleanupSpec() or lose the flush, goes. The Mongo and Neo4j managers still call it.
  • GrailsDataTckManagerSpec checks that the hibernate5-core TCK suite runs with the listener, where it checked the flush in cleanupSpec() before. Its module puts the JUnit Platform launcher on its test compile classpath for TestExecutionListener.

The specs of these modules that aren't TCK specs get the flush as well.

grails-datamapping-tck is published and grails-test-listener isn'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

Test performance

The listener takes no measurable time. On the same base as the heap measurements, I ran each module's test task with --rerun, one task at a time, with -PmaxTestParallel=4, without the probe and with -Xlog:gc on 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.

Module Flush Test time GC pauses Full GCs GC pause time
hibernate7-core Listener 656 s, 654 s 878, 845 0, 0 18.9 s, 17.9 s
cleanupSpec() 651 s, 658 s 907, 849 0, 1 19.1 s, 19.2 s
None 651 s, 664 s 1,072, 1,104 2, 2 21.6 s, 22.4 s
hibernate5-core Listener 125 s 210 0 3.6 s
cleanupSpec() 126 s 223 0 3.6 s
mongodb-core Listener 216 s 273 0 3.4 s
cleanupSpec() 217 s 274 0 3.6 s
neo4j-core Listener 155 s 1,494 0 16.3 s
cleanupSpec() 155 s 1,504 0 16.4 s
datamapping-core-test Listener 17 s 91 0 1.5 s
cleanupSpec() 16 s 93 0 1.3 s
  • The test times of the two flushes are within 1% of each other in every module.
  • Without a flush, hibernate7-core needs about a quarter more GC pauses and runs full GCs, but the extra 3–4 s of pauses are within the variation between runs.
  • neo4j-core started 114 JVMs, because these runs predate Keep the Neo4j core test JVMs for the whole test task #16859, which removed its forkEvery = 10.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 sbglasius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. 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?
  2. GrailsDataTckManagerSpec only proves the listener is on hibernate5-core's classpath, so its name could say that rather than "a TCK suite".
  3. Nit: Class.forName('org.junit.platform.launcher.TestExecutionListener') would avoid the new testCompileOnly dependency.

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.
@matrei
matrei force-pushed the build/tck-introspector-listener branch from 9e63487 to b3818ce Compare November 5, 2026 16:29
@matrei

matrei commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! I've amended the commit for the first two:

  1. The commit message now says why the flush moved out of cleanupSpec(). With the listener on the TCK modules' classpaths, it only flushed a second time, and a manager that overrides cleanupSpec() had to call super.cleanupSpec() to keep it. The message also names the cost for datastores outside this repository. The flush in cleanupSpec() isn't in a release, so none relies on it yet.
  2. The feature is now "the hibernate5-core TCK suite runs with the listener that flushes the Introspector's caches after each spec".
  3. I kept the import. hibernate5-test-config.gradle already puts the launcher on the test runtime classpath, so the testCompileOnly line only adds it for compilation, and the typed reference fails to compile if the class moves.

@testlens-app

testlens-app Bot commented Nov 5, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: b3818ce
▶️ Tests: 101384 executed
⚪️ Checks: 96/96 completed


Learn more about TestLens at testlens.app/docs.

@matrei
matrei merged commit bca56da into apache:8.0.x Nov 5, 2026
97 checks passed
@matrei
matrei deleted the build/tck-introspector-listener branch November 5, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants