Skip to content

test(amber): cover PveManager system-package resolution and package deletion - #8036

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/pve-manager
Aug 27, 2026
Merged

aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/pve-manager

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Six tests added to PveResourceSpec, covering PveManager's error paths. That file already owns this class's tests — 15 "PveManager" should blocks — so this extends it rather than adding a second spec.

Metric Before After
Codecov (fully-covered lines) 198/228 = 86.8% 205/228 = 89.9%
Branch arms 53/140 60/140

+7 fully-covered lines and +7 branch arms. The newly covered lines are the three give-up arms of resolveSystemPackages (149/151, 170/172, 181/183) and the uninstall-failure arm of deletePackages (565) — all plain control flow, no logger.info/debug bodies, so none is a line that looks green locally and dies in CI.

These figures are the CI-equivalent projection, not the raw local numbers. PveResourceSpec has 6 pre-existing Windows-only failures — its fake runner fabricates a POSIX <venv>/bin/python while PveManager resolves <venv>/Scripts/python.exe — so the raw local delta is inflated and is deliberately not quoted. The projection was built by applying a throwaway test-file scaffold that makes the runner platform-aware, measuring both sides with it applied byte-identically, then reverting it.

On the absolute endpoints: two independent measurements agree on +7 but differ by 3 on the endpoints (198 → 205 vs 195 → 202). The delta is solid and reproduced three times; the endpoint is the softer number. I would rather say that than publish a figure with more confidence than it has.

What the reviewers found

This bundle went through a mutation audit and then a separate vacuity review, and each found real defects the other could not.

The mutation audit's most serious catch: the resolver tests recorded what the runner was handed but asserted only its length, never what ran. Retargeting the install from the throwaway venv to PythonUtils.getPythonExecutable was byte-identical to baseline — meaning resolveSystemPackages would pip-install requirements.txt into the machine's system Python and report that interpreter's package set as "the system set", with the test named "give up without attempting the install" unable to tell the difference.

The vacuity review then found three things a mutation audit structurally cannot:

  • The throwaway-venv cleanup was executed four times per run and constrained by nothing. Swapping Comparator.reverseOrder() for naturalOrder() makes the delete hit the non-empty parent first, throw, and get swallowed by the block's own catch — the entire temp tree leaks, and the suite stayed green.
  • The sanitiser's composition order was unpinned. Each rule (trim, drop-blank, drop-comment) was pinned individually, but exchanging .map(_.trim).filter(…) for .filter(…).map(_.trim) survived, because every fixture line landed the same way either way. Fixed by indenting the ## FIXME fixture line two spaces — it is a comment only after trimming, so it is the one line that separates the two orders.
  • Three comments staked the fixture's whole rationale on the --constraint file, and the word appeared in the spec only inside comments. No assertion referenced the flag, the file, or its contents. Two mutants were therefore unkillable — including one that keeps package names but drops every version pin, leaving pip free to resolve any pyarrow.

All are now killed by a named test. The new --constraint test adds zero coverage — its path was already covered — and is included purely as a mutation-strength test; it is the sole killer of the constraint-file mutant.

Verification

Four load-bearing mutants were re-run against the final content, one at a time, each with a uniqueness-asserted anchor, reverted from a scratch snapshot, with the production diff verified empty and an md5 match before every subsequent compile. All four killed, each by a named test.

One published mutation row was discarded rather than reported: applied exactly as written it failed to compile (forward reference to value collected), and a compile-only mutant proves nothing. It was replaced with a semantically equivalent hoisted variant that does compile and does die.

No regression. The 6 pre-existing failures are identical in name on main and on this branch, not merely equal in count. All six new tests pass on Windows unscaffolded.

Deliberately not included

resolveSystemPackages fails open and this PR does not pin that as correct. All three give-up arms return Seq.empty, and callers degrade silently: systemPackageNames becomes empty, so a user may install or delete any package including one the Python workers depend on, and the --constraint file becomes empty, so user installs are no longer pinned. The tests assert the giving up — that the next command never runs, that a partial freeze is discarded — which is unambiguously right. No assertion blesses "empty set" as the correct answer for the application, and the spec says so. Fixing it is a production change.

Two survivor probes are recorded rather than pinned: the three logger.error calls can all be deleted with the suite outcome-identical (asserting on log lines means attaching an appender inside a shared, strictly-serial JVM, and those lines stay Codecov-missed regardless because of the scalalogging guard arm), and the cleanup finally block can be replaced with () — those lines already count as hits through try/finally bytecode duplication, so pinning them is worth zero.

systemPackages / systemPackageNames / systemConstraintFile are JVM-lifetime lazy vals, so resolution can be driven exactly once per JVM and the public getSystemPackages can never be exercised against a failing runner. The tests reach the private method reflectively; a rename yields NoSuchMethodException, i.e. a test error rather than a false pass, which was verified.

No production file is touched.

Any related issues, documentation, discussions?

Closes #8034

How was this PR tested?

sbt "WorkflowExecutionService/testOnly org.apache.texera.web.resource.pythonvirtualenvironment.*"
[info] Total number of tests run: 57
[info] Tests: succeeded 51, failed 6, canceled 1, ignored 0, pending 0

The 6 failures are the pre-existing Windows-only ones described above and are present on main unchanged; under the CI-equivalence scaffold the same scope reports succeeded 57, failed 0.

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:

  • No candidates found from git blame history.

@github-actions

Copy link
Copy Markdown
Contributor

✅ No material benchmark regressions detected

🟢 0 better · 🔴 0 worse · ⚪ 15 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 401 0.245 23,894/36,288/36,288 us ⚪ within ±5% / 🔴 +162.1%
⚪ bs=100 sw=10 sl=64 812 0.495 121,947/144,648/144,648 us ⚪ within ±5% / 🔴 +54.4%
⚪ bs=1000 sw=10 sl=64 934 0.57 1,064,392/1,137,046/1,137,046 us ⚪ within ±5% / 🔴 +25.9%
Baseline details

Latest main 97e3585 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 401 tuples/sec 420 tuples/sec 894.86 tuples/sec -4.5% -55.2%
bs=10 sw=10 sl=64 MB/s 0.245 MB/s 0.257 MB/s 0.546 MB/s -4.7% -55.1%
bs=10 sw=10 sl=64 p50 23,894 us 23,915 us 11,139 us -0.1% +114.5%
bs=10 sw=10 sl=64 p95 36,288 us 36,351 us 13,843 us -0.2% +162.1%
bs=10 sw=10 sl=64 p99 36,288 us 36,351 us 16,839 us -0.2% +115.5%
bs=100 sw=10 sl=64 throughput 812 tuples/sec 835 tuples/sec 1,166 tuples/sec -2.8% -30.3%
bs=100 sw=10 sl=64 MB/s 0.495 MB/s 0.51 MB/s 0.711 MB/s -2.9% -30.4%
bs=100 sw=10 sl=64 p50 121,947 us 116,696 us 87,509 us +4.5% +39.4%
bs=100 sw=10 sl=64 p95 144,648 us 140,503 us 93,675 us +3.0% +54.4%
bs=100 sw=10 sl=64 p99 144,648 us 140,503 us 102,153 us +3.0% +41.6%
bs=1000 sw=10 sl=64 throughput 934 tuples/sec 925 tuples/sec 1,198 tuples/sec +1.0% -22.0%
bs=1000 sw=10 sl=64 MB/s 0.57 MB/s 0.565 MB/s 0.731 MB/s +0.9% -22.1%
bs=1000 sw=10 sl=64 p50 1,064,392 us 1,076,570 us 859,766 us -1.1% +23.8%
bs=1000 sw=10 sl=64 p95 1,137,046 us 1,154,055 us 902,897 us -1.5% +25.9%
bs=1000 sw=10 sl=64 p99 1,137,046 us 1,154,055 us 937,957 us -1.5% +21.2%
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.06,200,128000,401,0.245,23894.26,36287.58,36287.58
1,100,10,64,20,2463.83,2000,1280000,812,0.495,121946.78,144647.98,144647.98
2,1000,10,64,20,21407.47,20000,12800000,934,0.570,1064392.39,1137046.36,1137046.36

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8036   +/-   ##
=========================================
  Coverage     93.33%   93.34%           
+ Complexity     4692     4688    -4     
=========================================
  Files          1179     1179           
  Lines         47713    47713           
  Branches       5314     5314           
=========================================
+ Hits          44534    44537    +3     
+ Misses         1730     1724    -6     
- Partials       1449     1452    +3     
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from 57a4230
agent-service 99.32% <ø> (ø) Carriedforward from 57a4230
amber 89.49% <ø> (+0.01%) ⬆️
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 no new comments.

@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

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 27, 2026
Merged via the queue into apache:main with commit b01b11f Aug 27, 2026
24 checks passed
@aglinxinyuan
aglinxinyuan deleted the cov/pve-manager branch August 27, 2026 08:46
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 PveManager system-package resolution and package deletion

4 participants