Skip to content

test(workflow-execution-service): extend ResultExportService unit test coverage#6902

Merged
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/6898-result-export-stream-writers
Jul 27, 2026
Merged

test(workflow-execution-service): extend ResultExportService unit test coverage#6902
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/6898-result-export-stream-writers

Conversation

@mengw15

@mengw15 mengw15 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

ResultExportService sits at ~6% line coverage: the existing spec only covers parseOperators and validateExportRequest, leaving the whole export-encoding layer untested. The streamDocumentAs* writers look storage-bound but are not — each takes a VirtualDocument[Tuple] parameter, so a small in-spec fake document makes them testable against a ByteArrayOutputStream, with no Iceberg, MinIO or DB.

This extends ResultExportServiceSpec with 19 tests that reach the private writers through PrivateMethodTester: streamDocumentAsCSV (both early returns, inferred vs supplied headers, and a document larger than Constants.CHUNK_SIZE to exercise the buffered chunk loop), streamCellData (rowIndex/columnIndex validation messages, an unretrievable row, and the happy-path bytes), convertFieldToBytes (all three branches), streamDocumentAsHTML, streamDocumentAsParquetZip (verbatim copy plus source-stream close, and error propagation), streamDocumentAsArrow (round-trips the tuples back through ArrowFileReader), and NonClosingOutputStream.

Two existing behaviors are pinned as-is rather than changed: with supplied headers the first row is not consumed by header inference, so it still appears in the body (the asymmetry against the None branch), and streamDocumentAsHTML throws NoSuchElementException on an empty document because .head is unguarded. getOperatorDocument, saveToDatasets, saveStreamToDataset and generateFileName stay uncovered — they need DocumentFactory.openDocument, a live file-service endpoint, or embed LocalDateTime.now().

Any related issues, documentation, discussions?

Closes #6898. Extends the spec added by #6705.

How was this PR tested?

sbt "WorkflowExecutionService/testOnly *ResultExportServiceSpec" passes with 24 tests (5 existing, 19 new); Test/scalafmtCheck and Test/scalafix --check are clean. Verified the failure path by inverting the supplied-headers assertion and confirming the suite went red and exited non-zero. Every test runs in-process against an in-spec fake document, so no external service is involved.

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

Generated-by: Claude Code (Fable 5)

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Ma77Ball
    You can notify them by mentioning @Ma77Ball in a comment.

Copilot AI 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.

Pull request overview

Expands unit test coverage for ResultExportService’s export/encoding writer methods (CSV, Arrow, HTML, Parquet zip, single-cell data) by invoking private helpers via ScalaTest’s PrivateMethodTester and using an in-memory VirtualDocument fake to avoid external storage dependencies.

Changes:

  • Adds an in-spec VirtualDocument[Tuple] fake plus tracking input/output streams to test writer behavior in-process.
  • Introduces new tests covering CSV header behaviors, chunked CSV streaming, cell extraction/validation, field-to-bytes conversion, HTML export, Parquet-zip copy/close semantics, Arrow round-trip, and NonClosingOutputStream.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 5 worse · ⚪ 10 noise (<±5%) · 0 without baseline

Compared against main 4af3a85 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 365 0.223 26,467/36,419/36,419 us 🔴 +8.7% / 🔴 +119.5%
bs=100 sw=10 sl=64 795 0.485 125,728/151,800/151,800 us ⚪ within ±5% / 🔴 +39.1%
bs=1000 sw=10 sl=64 896 0.547 1,122,018/1,142,495/1,142,495 us ⚪ within ±5% / 🔴 +11.9%
Baseline details

Latest main 4af3a85 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 365 tuples/sec 397 tuples/sec 754.55 tuples/sec -8.1% -51.6%
bs=10 sw=10 sl=64 MB/s 0.223 MB/s 0.242 MB/s 0.461 MB/s -7.9% -51.6%
bs=10 sw=10 sl=64 p50 26,467 us 24,479 us 12,816 us +8.1% +106.5%
bs=10 sw=10 sl=64 p95 36,419 us 33,500 us 16,594 us +8.7% +119.5%
bs=10 sw=10 sl=64 p99 36,419 us 33,500 us 19,806 us +8.7% +83.9%
bs=100 sw=10 sl=64 throughput 795 tuples/sec 823 tuples/sec 969.38 tuples/sec -3.4% -18.0%
bs=100 sw=10 sl=64 MB/s 0.485 MB/s 0.502 MB/s 0.592 MB/s -3.4% -18.0%
bs=100 sw=10 sl=64 p50 125,728 us 119,975 us 103,584 us +4.8% +21.4%
bs=100 sw=10 sl=64 p95 151,800 us 150,180 us 109,097 us +1.1% +39.1%
bs=100 sw=10 sl=64 p99 151,800 us 150,180 us 117,304 us +1.1% +29.4%
bs=1000 sw=10 sl=64 throughput 896 tuples/sec 911 tuples/sec 1,004 tuples/sec -1.6% -10.7%
bs=1000 sw=10 sl=64 MB/s 0.547 MB/s 0.556 MB/s 0.613 MB/s -1.6% -10.7%
bs=1000 sw=10 sl=64 p50 1,122,018 us 1,097,333 us 1,002,357 us +2.2% +11.9%
bs=1000 sw=10 sl=64 p95 1,142,495 us 1,151,730 us 1,046,463 us -0.8% +9.2%
bs=1000 sw=10 sl=64 p99 1,142,495 us 1,151,730 us 1,073,661 us -0.8% +6.4%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,547.88,200,128000,365,0.223,26466.77,36418.75,36418.75
1,100,10,64,20,2517.26,2000,1280000,795,0.485,125728.42,151799.70,151799.70
2,1000,10,64,20,22323.78,20000,12800000,896,0.547,1122017.85,1142494.95,1142494.95

@codecov-commenter

codecov-commenter commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.52%. Comparing base (4af3a85) to head (18adb51).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6902      +/-   ##
============================================
+ Coverage     78.39%   78.52%   +0.13%     
- Complexity     3723     3750      +27     
============================================
  Files          1161     1161              
  Lines         46066    46066              
  Branches       5107     5107              
============================================
+ Hits          36112    36173      +61     
+ Misses         8343     8281      -62     
- Partials       1611     1612       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 4af3a85
agent-service 76.76% <ø> (ø) Carriedforward from 4af3a85
amber 71.87% <ø> (+0.36%) ⬆️
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from 4af3a85
config-service 66.66% <ø> (ø) Carriedforward from 4af3a85
file-service 67.21% <ø> (ø) Carriedforward from 4af3a85
frontend 82.64% <ø> (ø) Carriedforward from 4af3a85
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 4af3a85
pyamber 93.48% <ø> (ø) Carriedforward from 4af3a85
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 4af3a85

*This pull request uses carry forward flags. 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:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…t coverage

Cover the private export-encoding writers (streamDocumentAsCSV/Arrow/HTML/
ParquetZip, streamCellData, convertFieldToBytes) and NonClosingOutputStream via
PrivateMethodTester and an in-spec fake VirtualDocument, so no Iceberg, MinIO or
DB is involved.
@mengw15
mengw15 force-pushed the chore/6898-result-export-stream-writers branch from 409fa2c to 18adb51 Compare July 26, 2026 04:20
@mengw15
mengw15 requested a review from aglinxinyuan July 26, 2026 05:07

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

LGTM!

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jul 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 27, 2026
@mengw15
mengw15 added this pull request to the merge queue Jul 27, 2026
Merged via the queue into apache:main with commit 9de1386 Jul 27, 2026
20 checks passed
@mengw15
mengw15 deleted the chore/6898-result-export-stream-writers branch July 27, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend ResultExportService unit test coverage

4 participants