Skip to content

test(amber): cover workflow lifecycle cleanup - #7151

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-workflow-lifecycle-manager
Open

test(amber): cover workflow lifecycle cleanup#7151
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-workflow-lifecycle-manager

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds WorkflowLifecycleManagerSpec for the lifecycle manager's externally observable cleanup behavior.

Scenario Observable contract
Multiple users Cleanup waits until the final user disconnects.
Workflow state A RUNNING update cancels cleanup; a terminal update schedules it again.
Repeated terminal updates A later update replaces the older deadline.

The suite uses an isolated Pekko actor system and restores AmberRuntime's shared actor-system reference after the suite, so other Amber suites retain their runtime setup.

The assertions were mutation-tested against temporary production changes, all reverted before commit:

Temporary mutation Result
userCount == 0 to userCount < 0 1 test failed
status == RUNNING to status != RUNNING 2 tests failed
Remove cancellation of an active cleanup deadline 1 test failed

Any related issues, documentation, discussions?

Closes #7150

How was this PR tested?

"C:/Program Files (x86)/sbt/bin/sbt" -java-home "C:/Users/linxi/.jdks/jbr-17.0.14" "WorkflowExecutionService/testOnly org.apache.texera.web.WorkflowLifecycleManagerSpec"
Tests: succeeded 3, failed 0
"C:/Program Files (x86)/sbt/bin/sbt" -java-home "C:/Users/linxi/.jdks/jbr-17.0.14" "WorkflowExecutionService/Test/scalafmtCheck" "WorkflowExecutionService/Test/scalafix --check"

Both checks completed successfully.

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

Generated-by: Codex (GPT-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:

  • No candidates found from git blame history.

@aglinxinyuan
aglinxinyuan marked this pull request as ready for review July 31, 2026 02:51
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

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

Compared against main 91ed98d 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 401 0.245 24,448/34,133/34,133 us 🔴 +9.3% / 🔴 +116.2%
bs=100 sw=10 sl=64 813 0.496 119,066/155,332/155,332 us ⚪ within ±5% / 🔴 +40.8%
bs=1000 sw=10 sl=64 920 0.561 1,085,600/1,124,657/1,124,657 us ⚪ within ±5% / 🔴 -8.2%
Baseline details

Latest main 91ed98d from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 401 tuples/sec 404 tuples/sec 771.62 tuples/sec -0.7% -48.0%
bs=10 sw=10 sl=64 MB/s 0.245 MB/s 0.247 MB/s 0.471 MB/s -0.8% -48.0%
bs=10 sw=10 sl=64 p50 24,448 us 22,366 us 12,626 us +9.3% +93.6%
bs=10 sw=10 sl=64 p95 34,133 us 35,697 us 15,786 us -4.4% +116.2%
bs=10 sw=10 sl=64 p99 34,133 us 35,697 us 19,344 us -4.4% +76.5%
bs=100 sw=10 sl=64 throughput 813 tuples/sec 807 tuples/sec 971.56 tuples/sec +0.7% -16.3%
bs=100 sw=10 sl=64 MB/s 0.496 MB/s 0.492 MB/s 0.593 MB/s +0.8% -16.4%
bs=100 sw=10 sl=64 p50 119,066 us 124,036 us 103,463 us -4.0% +15.1%
bs=100 sw=10 sl=64 p95 155,332 us 148,682 us 110,296 us +4.5% +40.8%
bs=100 sw=10 sl=64 p99 155,332 us 148,682 us 118,690 us +4.5% +30.9%
bs=1000 sw=10 sl=64 throughput 920 tuples/sec 929 tuples/sec 1,001 tuples/sec -1.0% -8.1%
bs=1000 sw=10 sl=64 MB/s 0.561 MB/s 0.567 MB/s 0.611 MB/s -1.1% -8.2%
bs=1000 sw=10 sl=64 p50 1,085,600 us 1,075,537 us 1,008,988 us +0.9% +7.6%
bs=1000 sw=10 sl=64 p95 1,124,657 us 1,102,313 us 1,055,260 us +2.0% +6.6%
bs=1000 sw=10 sl=64 p99 1,124,657 us 1,102,313 us 1,074,689 us +2.0% +4.6%
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,499.00,200,128000,401,0.245,24447.51,34133.29,34133.29
1,100,10,64,20,2460.90,2000,1280000,813,0.496,119065.95,155332.07,155332.07
2,1000,10,64,20,21744.01,20000,12800000,920,0.561,1085600.45,1124657.19,1124657.19

@codecov-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.61%. Comparing base (91ed98d) to head (4f24bb6).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7151      +/-   ##
============================================
+ Coverage     79.58%   79.61%   +0.02%     
- Complexity     3837     3845       +8     
============================================
  Files          1160     1160              
  Lines         46188    46188              
  Branches       5145     5145              
============================================
+ Hits          36761    36772      +11     
+ Misses         7795     7770      -25     
- Partials       1632     1646      +14     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 91ed98d
agent-service 77.42% <ø> (ø) Carriedforward from 91ed98d
amber 73.16% <ø> (+0.06%) ⬆️
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from 91ed98d
config-service 65.97% <ø> (ø) Carriedforward from 91ed98d
file-service 66.80% <ø> (ø) Carriedforward from 91ed98d
frontend 83.08% <ø> (ø) Carriedforward from 91ed98d
notebook-migration-service 78.89% <ø> (ø) Carriedforward from 91ed98d
pyamber 97.31% <ø> (ø) Carriedforward from 91ed98d
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from 91ed98d

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

@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

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

Adds a new Amber unit test suite to validate WorkflowLifecycleManager’s externally observable cleanup contract (user-count gating, cancellation while RUNNING, and deadline refresh on repeated terminal updates), using a suite-local Pekko ActorSystem wired into AmberRuntime for scheduler-driven assertions.

Changes:

  • Introduces WorkflowLifecycleManagerSpec with three scenarios covering user-count tracking and cleanup scheduling behavior.
  • Uses ExecutionStateStore state updates to drive the lifecycle manager’s state-change subscription path.
  • Temporarily swaps AmberRuntime’s global actor-system reference for deterministic scheduling during the suite, then restores it.

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

Comment on lines +42 to +66
private var previousActorSystem: AnyRef = _

private def getAmberRuntimeField(name: String): AnyRef = {
val field = AmberRuntime.getClass.getDeclaredField(name)
field.setAccessible(true)
field.get(AmberRuntime)
}

private def setAmberRuntimeField(name: String, value: AnyRef): Unit = {
val field = AmberRuntime.getClass.getDeclaredField(name)
field.setAccessible(true)
field.set(AmberRuntime, value)
}

override protected def beforeAll(): Unit = {
super.beforeAll()
previousActorSystem = getAmberRuntimeField("_actorSystem")
setAmberRuntimeField("_actorSystem", testSystem)
}

override protected def afterAll(): Unit = {
setAmberRuntimeField("_actorSystem", previousActorSystem)
TestKit.shutdownActorSystem(testSystem)
super.afterAll()
}
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 tests for workflow lifecycle cleanup

4 participants