Skip to content

[infra] Derive and validate the Flink versions tools/ut.sh uses - #1007

Open
weiqingy wants to merge 5 commits into
apache:mainfrom
weiqingy:1006-ut-sh-version-default
Open

[infra] Derive and validate the Flink versions tools/ut.sh uses#1007
weiqingy wants to merge 5 commits into
apache:mainfrom
weiqingy:1006-ut-sh-version-default

Conversation

@weiqingy

@weiqingy weiqingy commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Linked issue: #1006

Purpose of change

tools/ut.sh said omitting -f tests every supported Flink version. It tests one. The default was pinned to 2.2 while the root pom carries 2.3.0, so a bare run tested Java on 2.3.0 and Python on 2.2.x at once. -f was half-wired on top of that: it reached the e2e and Python tests, but nothing on the Java unit-test path reads it.

  • Derive the default from the root pom's <flink.version> instead of pinning it, so both lanes agree and the value cannot drift again. tools/update_flink_version.sh bumps poms and never touches this script, which is how the literal fell behind. Validated as x.y before use, since it flows into module paths, profile names and the pip requirement.
  • Scope -f to the e2e tests and reject it without -e. Unit tests stay where they were: each Java module on the <flink.version> its own pom resolves, Python on the root pom's. No caller in the repo passes -f without -e.
  • Validate what -f accepts. -f 9.9 used to ask Maven for a module that does not exist, so a typo looked like it worked. The supported set now comes from the dist/flink-* modules rather than a second hardcoded list. This also adds the missing flink-2.3 e2e profile, which -f 2.3 previously hit by fallthrough after Maven warned and ignored it. The profile omits flink.log4j2.version on purpose: its siblings pin 2.24.3 because they need a value different from the parent's, and 2.3 needs the parent's.

Subsumes #1008.

The issue's other option, iterating every version by default, is not implementable today: runtime fails test-compile at 1.20 because RescalingTest.java imports Flink 2.x-only packages. It would also multiply every Java unit-test job by roughly five, to duplicate what the java_it_tests matrix already covers.

Tests

Three bats files, 25 cases, in the harness CI already runs. Subprocess and shim patterns from help.bats and dry_run.bats; none sources ut.sh, which has no run guard.

They cover the derived default (that it follows a changed pom, and the malformed shapes that must be fatal), the -f rejection (its condition and each clause of its message, so a clause rewritten into something false fails), and version validation against a fake dist/. One case asserts the help text shows no -f form the script would reject. One guards the three lists that must agree, whose disagreement is what left 2.3 without a profile.

Full harness 216 ok / 1 not ok. The failure is pre-existing and unrelated (verify_example_job.bats via test_submit_examples_to_flink.sh:362, remaining_pids[@] unbound); it reproduces on unmodified main. ./tools/ut.sh -p on the new default: 825 passed, 13 skipped, exit 0, on apache-flink 2.3.0 confirmed from the environment.

One behavior change: the Python unit-test jobs in ci.yml and build_wheel.yml now install apache-flink~=2.3.0 rather than ~=2.2.0, the current PyPI latest. Both integration matrices pass -e -f explicitly and are unaffected. Not covered: the pip fallback branch of ut.sh -p.

API

No public API change. The observable change is to the script's CLI behavior and help text, described above.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

Every inaccurate claim was in the script's own help text, which this PR corrects. No file under docs/ references tools/ut.sh.

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

Generated-by: Claude Code 2.1.229 (Claude Opus 5)

… pom

The help text said that omitting -f runs every supported Flink version. It
runs one. DEFAULT_FLINK_VERSION was pinned to 2.2 while the root pom carried
2.3.0, so a bare tools/ut.sh tested Java on 2.3.0 and Python on 2.2.x in the
same command.

The default now derives from <flink.version> in the root pom, so both lanes
land on the same version and a bump cannot leave this script behind.
tools/update_flink_version.sh rewrites poms only, which is how the two drifted
apart in the first place. A value that is not shaped x.y is fatal rather than
flowing on into dist module paths, -P profile names and the pip requirement.

This changes what the Python unit-test jobs install, from apache-flink~=2.2.0
to ~=2.3.0, in both ci.yml and build_wheel.yml. Measured on the derived
default: 825 passed, 13 skipped against PyFlink 2.3.0. The integration
matrices pass -e -f explicitly and are unaffected.

The help text now states the derived default, and that -f applies to the e2e
and Python tests rather than to the Java unit tests.

Generated-by: Claude Code 2.1.229 (Claude Opus 5)
tools/ut.sh -j -f 1.20 accepted the flag and then tested exactly what it
would have tested anyway. The Java unit-test invocations pass no -P and
exclude the e2e modules, so an explicitly requested version never reaches
them, and nothing said so.

The warning fires only when a version was passed rather than defaulted,
Java is selected, and -e is not. It names the Java unit tests rather than
claiming the flag was ignored outright, because a default run also executes
the Python tests, which do install against the requested version.

A warning rather than a rejection: rejecting the flag would turn a working
command into a failing one, and the same information fits in a warning.

None of the workflow invocations trigger it. Both integration matrices pass
-e alongside -f, and the single-version jobs pass no -f.

Generated-by: Claude Code 2.1.229 (Claude Opus 5)
-f took any string. tools/ut.sh -j -e -f 9.9 asked Maven to build
dist/flink-9.9, a module that does not exist, and to activate a profile of
the same name. A typo looked like it worked.

The supported set now comes from the dist/flink-* modules rather than a
second hardcoded list, and both the explicit value and the derived default
are checked against it, so the two derivations cannot drift apart. Each
rejection names its own cause: a caller error, a root pom that has moved
ahead of the dist modules, or no dist modules at all.

-f 2.3 also selected a profile that did not exist. The e2e integration pom
defined flink-1.20 through flink-2.2 while 2.3 was its unprofiled default,
so Maven warned and carried on, landing on 2.3.0 by fallthrough. Adding the
profile makes the flag mean something for every value now accepted.

The new profile omits flink.log4j2.version. Its four siblings pin 2.24.3
because they need a value different from the parent's; 2.3 needs the
parent's 2.25.3, and a redundant pin would stop tracking it. Verified
behavior-neutral: flink.version, flink.agents.dist.artifactId and
flink.log4j2.version all resolve identically with and without -Pflink-2.3.

A test asserts the three lists that must agree still do: the dist/flink-*
directories, dist/pom.xml's modules, and the e2e integration pom's flink-*
profile ids. Their disagreement is what left 2.3 without a profile.

Generated-by: Claude Code 2.1.229 (Claude Opus 5)
@weiqingy weiqingy changed the title [infra] Derive the default Flink version in tools/ut.sh and flag an inert -f [infra] Derive and validate the Flink versions tools/ut.sh uses Aug 13, 2026
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs and removed doc-not-needed Your PR changes do not impact docs labels Aug 13, 2026
@wenjin272

Copy link
Copy Markdown
Contributor

Thanks for the update. Deriving the default Flink version from the root POM looks good.

One concern with the current CLI contract is that -f affects Python unit tests but not Java unit tests. Since CI runs UTs only against the default version and uses the E2E/IT matrix for multi-version coverage, could we scope -f to E2E tests only? Both Java and Python UTs would then consistently use the root POM version, and -f without -e could be rejected with a clear error.

The current examples should also be updated:

$0 -f 2.2  # Run tests only for Flink 2.2

This is not accurate because Java UTs still use the root POM version. If -f is E2E-only, the example could use -e -f 2.2 instead.

-f reached the e2e path and the Python tests but never the Java unit
tests, so one flag meant two things depending on what else was selected.
The script warned about that half of the split rather than removing it.

-f now selects the Flink version the e2e tests run against and nothing
else, and passing it without -e is rejected. Both unit-test lanes are
left where they already were: each Java module builds against the
<flink.version> its own pom resolves, and the Python unit tests install
the requirement built from the root pom's value. The rejection is
checked before the version itself is validated, because a flag that does
not apply makes the value it carries beside the point, and reporting that
value as unsupported would send the caller looking for a different one.

Nothing in the repository invokes -f without -e. Both matrix jobs pass
-e -f explicitly, and the four single-version invocations pass no -f, so
the capability this removes is running the Python unit tests against a
non-default PyFlink, which no job, script or document uses.

The help text carried three inaccurate examples, two of which predate
this branch: an inline list and a $0 block that both demonstrated forms
the script now rejects, and a missing-argument hint doing the same. All
three are corrected, and a test asserts the script demonstrates no -f
form it would itself reject, so a future example cannot reintroduce one.

The rejection's wording is pinned clause by clause. An earlier revision
of this branch claimed the unit tests run against the root pom version,
which is false for Java: dist/flink-1.20 stays in the unit-test reactor
and builds at 1.20.5. Rewriting any clause into something false now
fails a test rather than passing silently.

Generated-by: Claude Code 2.1.229 (Claude Opus 5)
@weiqingy

weiqingy commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

@wenjin272 Thanks, that is a better contract. Done in 32a90b0.

-f now selects the Flink version the e2e tests run against and nothing else, and passing it without -e exits 1 with an error naming the remedy. The warning is gone, since the case it warned about no longer exists. Nothing in the repo invokes -f without -e, so no CI job or documented command changes. The one thing it removes is ./tools/ut.sh -p -f 2.2, running the Python unit tests against a non-default PyFlink, which nothing here uses.

Examples fixed. There were two more carrying the same problem that I had missed: the inline Examples: -f 2.3, -f 1.20, -f 2.3 -f 1.20 line inside the -f block, and the missing-argument hint (e.g., -f 1.20). All three are -e -f forms now, and a test asserts the script demonstrates no -f form it would itself reject, so a future example cannot reintroduce one.

One correction on the wording while implementing it. "Both Java and Python UTs would then consistently use the root POM version" turns out not to hold for Java. The dist/flink-* modules stay in the unit-test reactor, since only the two e2e modules are excluded, and each of them pins its own version. dist/flink-1.20 is the only dist module with a test, and it runs at 1.20.5. So the help text now says the unit tests cannot be retargeted by -f, and that each Java module builds against the <flink.version> its own pom resolves, rather than naming one version for both lanes.

@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs and removed doc-not-needed Your PR changes do not impact docs labels Aug 16, 2026
The cross-language job failed while Maven Central was returning 429 for
the ASF parent pom, before any project was scanned. No source change;
this commit only re-triggers the workflow.

Generated-by: Claude Code 2.1.229 (Claude Opus 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants