Skip to content

Extremely slow for large vintage test suites #3050

@ben-manes

Description

@ben-manes

Steps to reproduce

This Gradle project (junit-example.zip) demonstrates this performance regression using Guava's testlib to generate many test cases against HashMap. In total this runs 982,500 tests and that can be adjusted in the MapTests iterator size.

$ gradle junit4Test

BUILD SUCCESSFUL in 2m 2s
2 actionable tasks: 2 executed

$ gradle junit5Test

BUILD SUCCESSFUL in 7m 49s
2 actionable tasks: 1 executed, 1 up-to-date

Context

I am trying to migrate Caffeine onto JUnitPlatform for running the suites. The external suites are JUnit 3 or 4, and the internal is TestNG. In total this amounts to ~10M tests due to brute force testing of different cache configurations.

The caffeine:junitTest suite runs 354,295 tests, which typically takes ~3 minutes. This fails after 17 minutes with an out-of-memory error. The TestNG scanner is also broken, but in a more severe manner. It tries to instantiate non-test classes unless those are explicitly excluded. It then appears to try to to run tests not in the specified group, perhaps just to ignore them, and exhausts memory without making any progress.

For the smaller modules the integration works wonderfully and simplifies the build files. It is only for these larger test suites does it seem to struggle. That might be related to #2460 but it seems worse than simply being inefficient with memory.

diff --git a/caffeine/testing.gradle b/caffeine/testing.gradle
index 30072599..985094a4 100644
--- a/caffeine/testing.gradle
+++ b/caffeine/testing.gradle
@@ -67,10 +67,13 @@ tasks.register('junitTest', Test) {
   group = 'Cache tests'
   description = 'JUnit tests'
 
-  useJUnit()
   dependsOn(jar)
   tasks.test.dependsOn(it)
 
+  useJUnitPlatform {
+    includeEngines 'junit-vintage'
+  }
+
   failFast = true
   maxHeapSize = '2g'
   systemProperty 'caffeine.osgi.jar', project(':caffeine').jar.archivePath.path

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions