Skip to content

test(amber): cover WorkflowExecutionService state events and teardown - #8035

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:cov/workflow-execution-service
Open

test(amber): cover WorkflowExecutionService state events and teardown#8035
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:cov/workflow-execution-service

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

WorkflowExecutionServiceSpec goes from 3 tests to 11. The three existing tests stop at construction; the new ones drive the metadata-store handler and the teardown path.

Metric Before After
Codecov (fully-covered lines) 26/72 = 36.1% 36/72 = 50.0%
JaCoCo line-hit 30/72 39/72
Branch arms 5/18 10/18

+10 fully-covered lines and +5 branch arms. The two metrics differ by one because line 179 was already line-hit and flips only by completing its second arm — they are not interchangeable, so both are given.

Of the +10, six are logic and four are not. Lines 95, 179, 181–184 are the recovery-banner arm and the four unsubscribeAll calls. Lines 101, 107, 108 and 109 are scalac-generated public accessor pairs (confirmed with javap -p -l) that move because the teardown test assigns those vars from outside. Those four are a real consequence of driving teardown rather than coverage farming, but they are not logic and I would rather split them out than present all ten as equivalent.

What the reviewers found

Two independent adversarial reviewers ran against the first draft. Six of eight fresh mutants survived it. The three worth naming:

  • workflowContext.workflowSettings = request.workflowSettings (line 90) could be deleted outright and all 8 tests still passed. Every test executes that line, so it was fully covered and entirely unconstrained. It is not cosmetic: outputPortsNeedingStorage is what CostBasedScheduleGenerator reads to decide which output ports get materialized, and dataTransferBatchSize / executionMode feed the resource allocator. Dropping it silently reverts every execution to the default settings while the request's are ignored.
  • The recovering-state guard was pinned one-sidedly. The test only ever drove isRecovering false → true, so weakening newState.isRecovering != oldState.isRecovering to a bare newState.isRecovering survived. That mutant is the mirror of the failure the test's own comment claimed to guard: an update that clears the flag emits no event, so the frontend's Recovering banner never comes down.
  • Both the state guard and the fatalErrors guard could be deleted wholesale and nothing failed.

All are now killed by a named test. The published mutation table was also re-run from scratch, one mutant at a time, because one row's failure message had been copy-pasted from another row.

Verification

Measured with an identical suite-name filter on both sides, one fresh sbt JVM per measurement, rm -rf of the jacoco dir between runs, counters read per-line out of jacoco.xml.

An independent measurer re-derived the figure a second way — over the whole amber unit module, the actual CI scope, rather than the six-suite filter — and got byte-identical per-line data on both sides. That independently confirms the six-suite list is complete and that 26 → 36 is what Codecov will show.

Two corrections that measurement forced, both worth stating:

  • The repair round added 3 tests after the original measurement, and the expectation was that the figure would rise above 36. It did not. Those 3 tests bought zero additional fully-covered lines — they add branch arms on line 94 and mutation-kill strength only. 36 is the number.
  • Line 185 already counted as a Codecov hit before this PR despite mi=4, ci=1, because the method's return instruction is attributed to it. It is genuinely executed only now.

Full amber unit scope, both sides: 190 suites, the same 7 pre-existing Windows-only failures by name, zero new. The only per-suite change anywhere is this spec going 3 → 11 tests, so the new beforeAll inserts do not leak — MockTexeraDB gives each suite its own database, and ids 9207–9210 are unique across the repo because the Iceberg statistics URI is machine-global.

Deliberately not included

executeWorkflow's live-runtime half — the 44-line hole — has no seam. Line 124 calls ComputingUnitMaster.createAmberRuntime, which builds an AmberClient over AmberRuntime.actorSystem, a JVM-global private var that nothing in unit scope initialises. Injecting a seam would be a production change.

Lines 113/114/115 are refused for a sharper reason: JaCoCo probes the try block only at its exit, so they flip only if compile and Workflow.fromCompilationResult both succeed — which falls straight into createAmberRuntime. Whether that is survivable depends on ClientEventSpec having restored the global to null in its afterAll. WorkflowServiceSpec's own header documents this cross-suite hazard as its reason for deliberately steering into a compile failure instead. Cementing an accident is worse than leaving three lines.

Three mutants are reported as live rather than dropped: reordering client.shutdown() against the four unsubscribeAll calls (order is not a stated contract), and two whose only kill would be to assert current behaviour that is arguably wrong — adding FAILED to the stuck-banner guard, and pinning which field the teardown guard reads, where the only discriminating state currently NPEs.

No production file is touched.

Any related issues, documentation, discussions?

Closes #8033

How was this PR tested?

sbt "WorkflowExecutionService/testOnly org.apache.texera.web.service.WorkflowExecutionServiceSpec"
[info] Tests: succeeded 11, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.

WorkflowExecutionService/Test/scalafmtCheck and WorkflowExecutionService/Test/scalafix --check both pass.

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

Generated-by: Claude Code (Opus 5)

Copilot AI lite review requested due to automatic review settings August 27, 2026 05:17

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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: @mengw15
    You can notify them by mentioning @mengw15 in a comment.

@github-actions

Copy link
Copy Markdown
Contributor

✅ No material benchmark regressions detected

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

Compared against main 97e3585 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 596 0.364 16,353/20,842/20,842 us 🟢 -25.2% / 🔴 +50.6%
🟢 bs=100 sw=10 sl=64 1,168 0.713 82,501/114,693/114,693 us 🟢 -6.7% / 🔴 +22.4%
bs=1000 sw=10 sl=64 1,428 0.872 698,561/739,776/739,776 us ⚪ within ±5% / 🟢 -21.1%
Baseline details

Latest main 97e3585 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 596 tuples/sec 572 tuples/sec 894.86 tuples/sec +4.2% -33.4%
bs=10 sw=10 sl=64 MB/s 0.364 MB/s 0.349 MB/s 0.546 MB/s +4.3% -33.4%
bs=10 sw=10 sl=64 p50 16,353 us 16,349 us 11,139 us +0.0% +46.8%
bs=10 sw=10 sl=64 p95 20,842 us 27,879 us 13,843 us -25.2% +50.6%
bs=10 sw=10 sl=64 p99 20,842 us 27,879 us 16,839 us -25.2% +23.8%
bs=100 sw=10 sl=64 throughput 1,168 tuples/sec 1,123 tuples/sec 1,166 tuples/sec +4.0% +0.2%
bs=100 sw=10 sl=64 MB/s 0.713 MB/s 0.686 MB/s 0.711 MB/s +3.9% +0.2%
bs=100 sw=10 sl=64 p50 82,501 us 83,988 us 87,509 us -1.8% -5.7%
bs=100 sw=10 sl=64 p95 114,693 us 122,984 us 93,675 us -6.7% +22.4%
bs=100 sw=10 sl=64 p99 114,693 us 122,984 us 102,153 us -6.7% +12.3%
bs=1000 sw=10 sl=64 throughput 1,428 tuples/sec 1,404 tuples/sec 1,198 tuples/sec +1.7% +19.2%
bs=1000 sw=10 sl=64 MB/s 0.872 MB/s 0.857 MB/s 0.731 MB/s +1.8% +19.2%
bs=1000 sw=10 sl=64 p50 698,561 us 716,187 us 859,766 us -2.5% -18.7%
bs=1000 sw=10 sl=64 p95 739,776 us 775,973 us 902,897 us -4.7% -18.1%
bs=1000 sw=10 sl=64 p99 739,776 us 775,973 us 937,957 us -4.7% -21.1%
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,335.65,200,128000,596,0.364,16353.27,20841.91,20841.91
1,100,10,64,20,1712.61,2000,1280000,1168,0.713,82501.04,114692.88,114692.88
2,1000,10,64,20,14004.26,20000,12800000,1428,0.872,698561.07,739775.69,739775.69

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.35%. Comparing base (57a4230) to head (02c19c9).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8035      +/-   ##
============================================
+ Coverage     93.33%   93.35%   +0.01%     
- Complexity     4692     4698       +6     
============================================
  Files          1179     1179              
  Lines         47713    47713              
  Branches       5314     5314              
============================================
+ Hits          44534    44543       +9     
+ Misses         1730     1721       -9     
  Partials       1449     1449              
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from 57a4230
agent-service 99.32% <ø> (ø) Carriedforward from 57a4230
amber 89.52% <ø> (+0.05%) ⬆️
computing-unit-managing-service 73.67% <ø> (ø) Carriedforward from 57a4230
config-service 86.73% <ø> (ø) Carriedforward from 57a4230
file-service 86.70% <ø> (ø) Carriedforward from 57a4230
frontend 95.82% <ø> (ø) Carriedforward from 57a4230
notebook-migration-service 79.31% <ø> (ø) Carriedforward from 57a4230
pyamber 97.74% <ø> (ø) Carriedforward from 57a4230
workflow-compiling-service 77.19% <ø> (ø) Carriedforward from 57a4230

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

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +160 to +164
override protected def beforeAll(): Unit = {
initializeDBAndReplaceDSLContext()

val user = new User
user.setUid(testUid)
Comment on lines +215 to +220
override protected def afterAll(): Unit = {
try {
TestKit.shutdownActorSystem(system)
closeConnectionPool()
} finally super.afterAll()
}

@mengw15 mengw15 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

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.

Add unit test coverage for WorkflowExecutionService state events and teardown

4 participants