You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "David Anderson (Jira)" <ji...@apache.org> on 2026/07/16 01:11:00 UTC

[jira] [Resolved] (FLINK-40138) Migration test snapshot generator does not drive the JUnit 5 lifecycle, breaking snapshot generation for JUnit-5-migrated tests in flink-tests

     [ https://issues.apache.org/jira/browse/FLINK-40138?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Anderson resolved FLINK-40138.
------------------------------------
    Resolution: Fixed

> Migration test snapshot generator does not drive the JUnit 5 lifecycle, breaking snapshot generation for JUnit-5-migrated tests in flink-tests
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-40138
>                 URL: https://issues.apache.org/jira/browse/FLINK-40138
>             Project: Flink
>          Issue Type: Bug
>          Components: Test Infrastructure, Tests
>    Affects Versions: 2.3.0, 2.4.0
>            Reporter: David Anderson
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.3.1, 2.4.0
>
>
> h3. Problem
> Running the snapshot generator for \{{flink-tests}} as documented in \{{flink-migration-test-utils/README.md}}:
> {code:bash}
> mvn clean package -Pgenerate-migration-test-data -Dgenerate.version=2.3 -nsu -Dfast -DskipTests
> {code}
> fails on the \{{flink-tests}} module. The Maven output only shows this error:
> {code}
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run
> (generate-migration-test-data) on project flink-tests: An Ant BuildException has occured:
> Java returned: 1
> {code}
> The forked JVM actually fails with:
> {code}
> Caused by: java.lang.NullPointerException
>     at org.apache.flink.util.Preconditions.checkNotNull(Preconditions.java:59)
>     at org.apache.flink.util.concurrent.ScheduledExecutorServiceAdapter.<init>(ScheduledExecutorServiceAdapter.java:37)
>     at org.apache.flink.test.state.operator.restore.AbstractOperatorRestoreTestBase.<init>(AbstractOperatorRestoreTestBase.java:103)
>     ...
> {code}
> h3. Root cause (as determined by Claude)
> The JUnit 5 migration ([FLINK-39124]) converted the migration tests' JUnit 4 \{{@ClassRule}}/\{{@Rule}} \{{ExternalResource}}s into JUnit 5 \{{@RegisterExtension}} extensions and \{{@BeforeEach}} methods, but \{{MigrationTestsSnapshotGenerator}}/\{{SnapshotGeneratorUtils}} were not updated. The generator instantiates test classes by reflection and only drives JUnit 4 rules (\{{RunRules}}), so the JUnit 5 lifecycle never runs. This surfaces as two distinct failures:
> Operator-restore tests (\{{AbstractOperatorRestoreTestBase}} and subclasses): the instance field initializer \{{scheduledExecutor = new ScheduledExecutorServiceAdapter(EXECUTOR_RESOURCE.getExecutor())}} throws NPE, because the \{{@RegisterExtension TestExecutorExtension}}'s \{{beforeAll}} (which creates the executor) is never called. The \{{MiniClusterExtension}} and the \{{@BeforeEach setClusterClient(@InjectClusterClient …)}} method are likewise never driven.
> {\{StatefulJob*MigrationITCase}}: silently skipped. [FLINK-39124] also changed \{{generateSnapshots}} from \{{public}} to \{{private}}, and the generator discovers generator methods via \{{Class.getMethods()}} (public only), so the \{{@ParameterizedSnapshotsGenerator}} method (and its \{{private static}} parameters method, looked up via \{{Class.getMethod}}) are no longer found. This is the same class of silent failure reported in [FLINK-34972].
> The regression is present on \{{master}} and \{{release-2.3}}. It was not caught earlier because the last reference-data generation ([FLINK-38775], 2.2) predates the JUnit 5 migration.
> h3. Related
> - Blocks [FLINK-40020] (Flink 2.3: update reference data for migration tests)
> - Regression from [FLINK-39124] (JUnit 5 migration of flink-tests)
> - Overlaps with [FLINK-34972] (generator silently produces no files for some subclasses)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)