Skip to content

test(amber): add unit test coverage for AdminUserResource - #7167

Merged
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/7163-admin-user-resource-test
Jul 31, 2026
Merged

test(amber): add unit test coverage for AdminUserResource#7167
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/7163-admin-user-resource-test

Conversation

@mengw15

@mengw15 mengw15 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds AdminUserResourceSpec, the first spec for AdminUserResource (previously
~0% coverage). It runs against embedded Postgres via MockTexeraDB and seeds
rows through the jOOQ DAOs, with 12 tests covering the admin user-management
methods, empty and populated:

  • list — returns the seeded users with name / email / role.
  • addUser — persists a new INACTIVE user.
  • updateUser — round-trips an editable-field change; rejects an email that
    already belongs to another user (WebApplicationException).
  • getCreatedWorkflow / getAccessedWorkflow — the per-user created / accessible
    workflow lists.
  • getUserQuota — the per-user quota view.
  • deleteCollection — removes the target execution row.

Two side-effecting branches are intentionally left to their owning code paths so
this stays a hermetic unit test: updateUser's role-change branch (sends an
e-mail via GmailResource) is not exercised — only the no-role-change and
conflict paths are; and deleteCollection is asserted on its DB delete (the
Iceberg document cleanup is a best-effort, exception-swallowed step).

Any related issues, documentation, discussions?

Closes #7163.

How was this PR tested?

sbt "WorkflowExecutionService/testOnly *AdminUserResourceSpec" — 12 succeeded, 0 failed. Test/scalafmtCheck and Test/scalafix --check clean. Failure path verified by breaking an assertion (→ 1 failed, non-zero exit) and restoring.

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

Generated-by: Claude Code (Opus 4.8 [1M context])

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

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.

🟡 Not ready to approve

The new spec’s cleanup logic does not remove addUser()-created rows (and includes a misleading comment about when cleanup runs), which breaks test hermeticity and can cause future flakiness.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds an initial ScalaTest spec for the Amber admin user-management REST resource (AdminUserResource), using MockTexeraDB (embedded Postgres + jOOQ DAOs) to seed and assert DB-backed behavior.

Changes:

  • Introduces AdminUserResourceSpec with unit tests covering list/add/update and several per-user workflow/quota endpoints.
  • Seeds users/workflows/executions via jOOQ DAOs and validates both empty and populated cases.
  • Adds a delete-collection test asserting DB-side deletion behavior.
File summaries
File Description
amber/src/test/scala/org/apache/texera/web/resource/dashboard/admin/user/AdminUserResourceSpec.scala New unit-test suite for AdminUserResource using embedded Postgres and jOOQ DAO seeding.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

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

Compared against main 45b7b20 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 381 0.232 26,610/36,003/36,003 us 🔴 +16.6% / 🔴 +128.1%
🔴 bs=100 sw=10 sl=64 894 0.546 108,431/155,063/155,063 us 🔴 +20.5% / 🔴 +40.6%
bs=1000 sw=10 sl=64 1,086 0.663 918,541/964,470/964,470 us ⚪ within ±5% / 🟢 -10.3%
Baseline details

Latest main 45b7b20 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 381 tuples/sec 442 tuples/sec 771.62 tuples/sec -13.8% -50.6%
bs=10 sw=10 sl=64 MB/s 0.232 MB/s 0.27 MB/s 0.471 MB/s -14.1% -50.7%
bs=10 sw=10 sl=64 p50 26,610 us 22,829 us 12,626 us +16.6% +110.8%
bs=10 sw=10 sl=64 p95 36,003 us 31,050 us 15,786 us +15.9% +128.1%
bs=10 sw=10 sl=64 p99 36,003 us 31,050 us 19,344 us +15.9% +86.1%
bs=100 sw=10 sl=64 throughput 894 tuples/sec 975 tuples/sec 971.56 tuples/sec -8.3% -8.0%
bs=100 sw=10 sl=64 MB/s 0.546 MB/s 0.595 MB/s 0.593 MB/s -8.2% -7.9%
bs=100 sw=10 sl=64 p50 108,431 us 101,558 us 103,463 us +6.8% +4.8%
bs=100 sw=10 sl=64 p95 155,063 us 128,690 us 110,296 us +20.5% +40.6%
bs=100 sw=10 sl=64 p99 155,063 us 128,690 us 118,690 us +20.5% +30.6%
bs=1000 sw=10 sl=64 throughput 1,086 tuples/sec 1,087 tuples/sec 1,001 tuples/sec -0.1% +8.5%
bs=1000 sw=10 sl=64 MB/s 0.663 MB/s 0.663 MB/s 0.611 MB/s 0.0% +8.5%
bs=1000 sw=10 sl=64 p50 918,541 us 919,757 us 1,008,988 us -0.1% -9.0%
bs=1000 sw=10 sl=64 p95 964,470 us 963,532 us 1,055,260 us +0.1% -8.6%
bs=1000 sw=10 sl=64 p99 964,470 us 963,532 us 1,074,689 us +0.1% -10.3%
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,525.54,200,128000,381,0.232,26610.37,36002.97,36002.97
1,100,10,64,20,2237.07,2000,1280000,894,0.546,108430.69,155063.35,155063.35
2,1000,10,64,20,18415.94,20000,12800000,1086,0.663,918540.62,964470.00,964470.00

@mengw15
mengw15 force-pushed the chore/7163-admin-user-resource-test branch from e4ee7eb to 346f427 Compare July 31, 2026 12:54
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.82%. Comparing base (45b7b20) to head (346f427).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7167      +/-   ##
============================================
+ Coverage     79.62%   79.82%   +0.20%     
- Complexity     3836     3842       +6     
============================================
  Files          1160     1160              
  Lines         46188    46188              
  Branches       5145     5145              
============================================
+ Hits          36777    36870      +93     
+ Misses         7778     7678     -100     
- Partials       1633     1640       +7     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 45b7b20
agent-service 77.42% <ø> (ø) Carriedforward from 45b7b20
amber 73.63% <ø> (+0.54%) ⬆️
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from 45b7b20
config-service 65.97% <ø> (ø) Carriedforward from 45b7b20
file-service 66.80% <ø> (ø) Carriedforward from 45b7b20
frontend 83.16% <ø> (ø) Carriedforward from 45b7b20
notebook-migration-service 78.89% <ø> (ø) Carriedforward from 45b7b20
pyamber 97.36% <ø> (ø) Carriedforward from 45b7b20
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from 45b7b20

*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 requested a review from aglinxinyuan July 31, 2026 13:09

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

@mengw15
mengw15 added this pull request to the merge queue Jul 31, 2026
Merged via the queue into apache:main with commit d31406e Jul 31, 2026
21 checks passed
@mengw15
mengw15 deleted the chore/7163-admin-user-resource-test branch July 31, 2026 19:26
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 AdminUserResource

4 participants