Skip to content

Fix flaky Java tests - #40298

Open
reuvenlax wants to merge 8 commits into
apache:masterfrom
reuvenlax:fix_flaky_tests_java
Open

reuvenlax wants to merge 8 commits into
apache:masterfrom
reuvenlax:fix_flaky_tests_java

Conversation

@reuvenlax

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.04255% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.55%. Comparing base (020707d) to head (12e4e1c).
⚠️ Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
...ava/org/apache/beam/runners/prism/PrismRunner.java 48.07% 24 Missing and 3 partials ⚠️
...truction/DefaultExpansionServiceClientFactory.java 0.00% 24 Missing ⚠️
...uredstreaming/translation/SparkSessionFactory.java 26.66% 9 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40298      +/-   ##
============================================
+ Coverage     56.15%   58.55%   +2.40%     
- Complexity     2290    13732   +11442     
============================================
  Files          1121     2579    +1458     
  Lines        177169   270129   +92960     
  Branches       1488    11173    +9685     
============================================
+ Hits          99489   158183   +58694     
- Misses        75158   105947   +30789     
- Partials       2522     5999    +3477     
Flag Coverage Δ
java 64.84% <34.04%> (-10.91%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.

This pull request likely touches a core component ("core" label). Please review with scrutiny.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@Abacn Abacn 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.

Thanks, there are many independent fixes, and some are safe while other may need some consideration. Two main comments

  • Side effect of retry
  • Some findings here may have already been fixed on HEAD recently

sparkConf.setJars(filterFilesToStage(options, SPARK_JAR_EXCLUDES));
// Enable `userClassPathFirst` to prevent issues with guava, jackson and others.
sparkConf.setIfMissing("spark.executor.userClassPathFirst", "true");
if (!master.startsWith("local")) {

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.

Some flakiness should be fixed by #40270 already

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think I can revert this change.

cancelSparkJobs.run();
}
} finally {
if (cancelRequested.get()) {

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 sounds like related to #40101, which has been fixed recently

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW pr/40103 (fix for 40101) actually introduced some of the flaky tests that this PR tries to address, so the flakes seen by this PR postdate 40103.

executor.stop();
if (attempt < MAX_START_ATTEMPTS
&& (!alive
|| (e.getMessage() != null && e.getMessage().contains("JobService/Prepare")))) {

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.

Retry can reduce flakiness in general. However on genuine failure, keep retrying only delays the program execution. We should only retry transient failures (e.g. port conflict)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we expect genuine failures on starting the Prism runner?

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.

IIUC Java's prism runner wrapper downloads a prism binary if not already exist in .cache/apache_beam. If downloads fail (no access to github.com; platform not have pre-build binary; run on a dev version and the binary not built separately; blocked by Stanta; etc) it could fail

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @kennknowles

@kennknowles

Copy link
Copy Markdown
Member

R: @Abacn

Feel free to re-add me if you want.

Parting comment/question: I have not been following this specific PR. Is it being broken into separate PRs or just multi-commit on this PR?

@kennknowles
kennknowles requested a review from Abacn October 8, 2026 14:12
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@reuvenlax

Copy link
Copy Markdown
Contributor Author

friendly ping!

@Abacn

Abacn commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

There are separate fixes merged recently #40449 #40393 #40291

@kennknowles

Copy link
Copy Markdown
Member

R: @Abacn

@derrickaw

Copy link
Copy Markdown
Collaborator

Hi @reuvenlax, frinedly ping to resolve conflicts. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants