[FLINK-40382][build] Stop surefire from hiding nested test classes - #28962
[FLINK-40382][build] Stop surefire from hiding nested test classes#28962spuru9 wants to merge 1 commit into
Conversation
b990445 to
f9996cd
Compare
|
Tests count increase for flink-table-type-utils — 151 → 418 in CI BEFORE — green master build, pre-fix: AFTER — PR #28962, commit f9996cd: Both are the Test (module: misc) job — that's where flink-table-type-utils runs, |
|
@snuyanzin @rmetzger Can you take a look. |
snuyanzin
left a comment
There was a problem hiding this comment.
Thanks for looking here
this approach changes lots of code however it does not fix the root cause
instead only moves it under the rug...
Surefire excludes **/$
why can't we overwrite this exclude for everyone?
That would be a better way. Checking if there is any blocker in the same. |
Surefire's default excludes drop **/*$*, so a test class declared as a static nested class is never selected. JUnit Jupiter only auto-discovers @nested inner classes, so such a class falls through both paths and never runs, with no log line, report file or skip count to show it. Override the excludes on the default-test execution. The include pattern there is name-based (**/*Test.*, **/*Tests.*), so only nested classes whose name ends in Test/Tests are picked up. The explicit **/*$* exclude on the integration-tests execution is left alone: its include is **/*.*, which would otherwise match Scala-generated names such as TypeInformationGenTest$$anon$85$$anon$86. This recovers the nested test classes without touching any test code: flink-table-type-utils goes from 151 to 418 tests, flink-core picks up both NullableSerializerTest variants (19 each) and flink-runtime picks up InputSelectionTest$BuilderTest (3). Of the 152 nested classes that newly match the include, 134 are existing @nested classes that already ran (JUnit deduplicates, so they do not run twice) and 2 are abstract bases that JUnit ignores. Generated-by: Claude Code (claude-opus-5)
f9996cd to
3120939
Compare
|
@snuyanzin There is a issue: surefire then selects both the enclosing and the nested class, and JUnit only deduplicates within a fork — so 127 already-correct AFTER (pom change applied) https://github.com/spuru9/flink/actions/runs/31730469547/job/94552235499 — Test (module: table) 18:41:35.826 [INFO] Running …aggfunctions.MaxWithRetractAggFunctionTest$ByteMaxWithRetractAggFunctionTest BEFORE (green master, same job) https://github.com/apache/flink/actions/runs/31416084933/job/93547589715 — Test (module: table) 18:07:33.852 [INFO] Running …$ByteMaxWithRetractAggFunctionTest |

Reworked after review feedback — this now fixes the root cause in
pom.xmlinstead of restructuring test code. The previous revision moved 15 nested classes around in three files (+595 lines); that fixed those three files and left the mechanism in place. Thanks @snuyanzin.What is the purpose of the change
A test class declared as a
staticnested class is never selected:**/*$*, so nested class files are never scanned.@Nestedinner classes.A
staticnested class falls through both. And because the enclosing class is oftenabstract, surefire emits nothing for it either — noRunningline, no report file, not evenTests run: 0. Nothing in a build indicates the omission.Brief change log
Override
<excludes>on thedefault-testexecution, which displaces surefire's defaults (specifying any<excludes>replaces the default list wholesale).The explicit
**/*$*exclude on theintegration-testsexecution is deliberately left alone. Its include is**/*.*, which would otherwise match Scala-generated names such asTypeInformationGenTest$$anon$85$$anon$86— the case the existing comment there warns about. 500 Scala test files remain inflink-table-api-scala,-scala-bridgeand the planner. Thedefault-testinclude is name-based (**/*Test.*,**/*Tests.*), which those names do not match, so relaxing it is safe.Verifying this change
No test code is touched. Locally, per module:
flink-table-type-utilsflink-core— bothNullableSerializerTestvariantsflink-runtime—InputSelectionTest$BuilderTestOf the 152 nested classes that newly match the include across already-built modules, 134 are existing
@Nestedclasses that already ran, 2 are abstract bases that JUnit ignores, and the remainder are the genuinely dead ones.Also verified: with
**/*.*and no$exclude, anonymous classes (Foo$1), helper nested classes and test-less*Test-named helpers are silently ignored rather than erroring.Note when testing locally:
mvn cleanis required. Staletarget/test-classesfrom a branch that restructured these classes produces phantomIllegalAccessErrors.flink-table-plannercould not be verified locally — it holds 134 of the 152 newly-matched classes and all the Scala test sources, so CI is the real check for this change.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noRowDataSerializer,ExternalSerializer,TimestampDataSerializer,NullableSerializer)Documentation
AI assistance