Skip to content

test(flink): improve sink append and partitioner test coverage - #19399

Open
cshuo wants to merge 4 commits into
apache:masterfrom
cshuo:flink-sink-coverage
Open

test(flink): improve sink append and partitioner test coverage#19399
cshuo wants to merge 4 commits into
apache:masterfrom
cshuo:flink-sink-coverage

Conversation

@cshuo

@cshuo cshuo commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Describe the issue this Pull Request addresses

Closes #19398.

The Flink sink append buffer variants and dynamic bucket assignment paths had substantial unit-test coverage gaps. The existing end-to-end drivers are integration-test-only, so these paths need focused unit tests that run in the regular Maven/Codecov workflow.

Summary and Changelog

  • Exercise continuous-sort, Disruptor, and bounded in-memory append buffers through the Flink test harness.
  • Verify buffer selection, checkpoint flushing, write statuses, partitioned output, and persisted name,age sort order.
  • Add unit coverage for dynamic bucket assignment of existing and new record keys and its checkpoint lifecycle.
  • Extend record-level-index backend tests for lazy cache creation, checkpoint-aware eviction, dictionary encoding, and exact cache-size inference.
  • Cover BulkInsertWriterHelper constructor and error-wrapping paths.
  • Initialize and close append-buffer resources, including the test IO manager, in InsertFunctionWrapper.

Local JaCoCo line coverage from the targeted suite:

Class Before After
AppendWriteFunctionWithContinuousSort 0% 77.7%
AppendWriteFunctionWithDisruptorBufferSort 0% 80.9%
AppendWriteFunctionWithBIMBufferSort 0% 78.6%
DynamicBucketAssignFunction 0% 97.9%
RecordLevelIndexBackend 56% 75.2%
BulkInsertWriterHelper 71% 79.6%

Validation:

mvn -Punit-tests -pl hudi-flink-datasource/hudi-flink -am \
  -Dtest=TestAppendWriteFunction,TestAppendWriteFunctionWithBufferSort,TestAppendWriteFunctionWithBIMBufferSort,TestDynamicBucketAssignFunction,TestRecordLevelIndexBackend,TestBulkInsertWriteHelper \
  -Dsurefire.failIfNoSpecifiedTests=false \
  -DskipITs -DskipSparkTests -DskipScalaTests test

Result: 45 tests run, 0 failures, 0 errors, 0 skipped.

Impact

No public API or user-facing behavior changes. The only production-source adjustment marks the cache-size inference helper package-visible with @VisibleForTesting; the remaining changes add tests and improve test-harness resource cleanup.

Risk Level

Low. The targeted Maven reactor build, Checkstyle, RAT, and JaCoCo report all completed successfully.

Documentation Update

None.

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@cshuo
cshuo force-pushed the flink-sink-coverage branch from 4a2c7b8 to da031aa Compare July 29, 2026 02:22
@cshuo cshuo changed the title [SUPPORT] Improve Flink sink append and partitioner test coverage test(flink): improve sink append and partitioner test coverage Jul 29, 2026
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.86%. Comparing base (d56e674) to head (118be36).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19399      +/-   ##
============================================
+ Coverage     72.19%   74.86%   +2.66%     
+ Complexity    32595    32359     -236     
============================================
  Files          2561     2574      +13     
  Lines        148328   142978    -5350     
  Branches      18654    17719     -935     
============================================
- Hits         107087   107037      -50     
+ Misses        32774    27886    -4888     
+ Partials       8467     8055     -412     
Components Coverage Δ
hudi-common 82.26% <ø> (+0.84%) ⬆️
hudi-client 81.79% <ø> (+0.22%) ⬆️
hudi-flink 78.87% <ø> (+0.24%) ⬆️
hudi-spark-datasource 68.34% <ø> (+9.67%) ⬆️
hudi-utilities 71.22% <ø> (+0.80%) ⬆️
hudi-cli 15.32% <ø> (ø)
hudi-hadoop 63.49% <ø> (ø)
hudi-sync 70.67% <ø> (+0.02%) ⬆️
hudi-io 79.57% <ø> (ø)
hudi-timeline-service 83.54% <ø> (+0.09%) ⬆️
hudi-cloud 64.00% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (ø)
Flag Coverage Δ
common-and-other-modules 47.99% <ø> (+1.29%) ⬆️
flink-integration-tests 47.71% <ø> (+0.01%) ⬆️
hadoop-mr-java-client 43.38% <ø> (+0.06%) ⬆️
integration-tests 13.63% <ø> (+0.04%) ⬆️
spark-client-hadoop-common 48.71% <ø> (+0.01%) ⬆️
spark-java-tests 51.37% <ø> (+2.04%) ⬆️
spark-scala-tests 46.08% <ø> (+1.22%) ⬆️
utilities 36.65% <ø> (+0.19%) ⬆️

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

Files with missing lines Coverage Δ
...ink/partitioner/index/RecordLevelIndexBackend.java 92.10% <ø> (+3.94%) ⬆️

... and 77 files with indirect coverage changes

🚀 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.

@cshuo
cshuo marked this pull request as ready for review July 29, 2026 03:09

@hudi-agent hudi-agent 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.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR fills in unit-test coverage for the Flink append-buffer variants, dynamic bucket assignment, record-level-index backend, and BulkInsertWriterHelper, with the only production change being a visibility widening (@VisibleForTesting) on inferMemorySizeForCache. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. A couple of minor readability suggestions on list vs. array assertion and the nested try-finally teardown in the test harness.

cc @yihua

@github-actions github-actions Bot added the size:L PR with lines of changes in (300, 1000] label Jul 29, 2026

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

The buffer tests are useful, but the new teardown path still leaves the async-clustering resources open and orders IO-manager shutdown too early.

cshuo added 2 commits July 29, 2026 14:41
Address review comments 3670917923 and 3670736056.
Address review comment 3670736052.

@cshuo cshuo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed all current review comments in 284fb5f and 118be36. The targeted async-clustering and buffer-sort tests pass (21 tests, 0 failures).

@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@hudi-agent hudi-agent 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.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR adds focused unit-test coverage for the Flink append buffer variants, dynamic bucket assignment, record-level-index backend, and BulkInsertWriterHelper, with the only production change being a private → package-private @VisibleForTesting widening of RecordLevelIndexBackend.inferMemorySizeForCache(). I traced the new DynamicBucketAssignFunction tests against the production processElement/checkpoint logic and the shared closeAll teardown ordering, and they line up with the actual contracts. No new issues flagged from this automated pass — a Hudi committer or PMC member can take it from here for a final review. A couple of minor test-readability suggestions below, otherwise clean.

cc @yihua

@ParameterizedTest
@EnumSource(value = BufferType.class, names = {"CONTINUOUS_SORT", "DISRUPTOR", "BOUNDED_IN_MEMORY"})
public void testBufferedAppendFunctionsWriteAndFlushOnCheckpoint(BufferType bufferType) throws Exception {
Configuration writeConf = TestConfigurations.getDefaultConf(tempFile.getAbsolutePath());

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.

🤖 nit: this writeConf setup block (operation/metadata/buffer type/sort keys/size + the continuous/disruptor if-else) is duplicated verbatim in testBufferedAppendFunctionsPersistRowsInSortOrder — could you pull it into a small buildWriteConf(bufferType) helper?

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

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

Labels

size:L PR with lines of changes in (300, 1000]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FLINK] Improve Flink sink append and bucket partitioner test coverage

5 participants