Skip to content

test(amber): add unit test coverage for UserQuotaResource - #7168

Merged
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/7162-userquota-resource-test
Jul 31, 2026
Merged

test(amber): add unit test coverage for UserQuotaResource#7168
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/7162-userquota-resource-test

Conversation

@mengw15

@mengw15 mengw15 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds UserQuotaResourceSpec for UserQuotaResource (previously ~0% coverage,
no spec). The suite runs against embedded Postgres via MockTexeraDB and seeds
users / workflows / versions / executions / datasets through the generated DAOs.

13 tests, each starting from a clean slate (so they are order-independent):

  • getUserCreatedWorkflow — empty list when the user owns no workflows; the owned workflows with their id / name / creation time when WORKFLOW_OF_USER is seeded.
  • getUserAccessedWorkflow — empty list with no grants; the accessible workflow ids from WORKFLOW_USER_ACCESS.
  • getUserQuotaSize — empty array with no executions; the assembled per-execution resultBytes / runTimeStatsBytes / logBytes (seeded across WORKFLOW_EXECUTIONS.RUNTIME_STATS_SIZE, OPERATOR_PORT_EXECUTIONS.RESULT_SIZE, and OPERATOR_EXECUTIONS.CONSOLE_MESSAGES_SIZE).
  • The JAX-RS endpoints (getCreatedWorkflow, getAccessedWorkflow, getUserQuota, getCreatedDatasets) via a new SessionUser, covering the thin delegation wrappers; getCreatedDatasets covers the empty case and the created-datasets case (size is deterministically 0 — the size calculation is disabled in the current dataset implementation).
  • deleteExecutionCollection and the deleteCollection endpoint — assert the execution row is removed from WORKFLOW_EXECUTIONS.

No production code was changed.

Any related issues, documentation, discussions?

Closes #7162

How was this PR tested?

New unit tests, run locally against embedded Postgres:

sbt "WorkflowExecutionService/testOnly org.apache.texera.web.resource.dashboard.user.quota.UserQuotaResourceSpec"
# Tests: succeeded 13, failed 0
sbt "WorkflowExecutionService/Test/scalafmtCheck" "WorkflowExecutionService/Test/scalafix --check"   # clean

The failure path was verified by deliberately breaking an assertion and
confirming the suite goes red. To keep the suite deterministic, the
creationTime assertion compares against the DB round-tripped value rather than
the in-memory timestamp (Postgres rounds the stored value, so an exact
in-memory comparison would be flaky).

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.

🟢 Ready to approve

The PR adds isolated embedded-Postgres tests without modifying production code and aligns with the linked issue’s requested coverage.

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

Pull request overview

Adds a new ScalaTest spec to cover UserQuotaResource in the Amber module, exercising both the underlying jOOQ-backed query helpers and the thin JAX-RS endpoint wrappers against an embedded Postgres via MockTexeraDB.

Changes:

  • Add UserQuotaResourceSpec with empty + populated cases for created/accessed workflows, quota storage sizing, and created datasets.
  • Add coverage for deletion behavior via deleteExecutionCollection and the deleteCollection endpoint, asserting execution rows are removed.
File summaries
File Description
amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/quota/UserQuotaResourceSpec.scala New embedded-Postgres-backed unit tests covering UserQuotaResource query helpers and endpoints, including deletion behavior.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 5 worse · ⚪ 10 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 368 0.225 26,307/36,660/36,660 us 🔴 -10.0% / 🔴 +132.2%
bs=100 sw=10 sl=64 951 0.581 104,030/126,294/126,294 us ⚪ within ±5% / 🔴 +14.5%
bs=1000 sw=10 sl=64 1,103 0.673 913,699/947,950/947,950 us ⚪ within ±5% / 🟢 -11.8%
Baseline details

Latest main 45b7b20 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 368 tuples/sec 409 tuples/sec 771.62 tuples/sec -10.0% -52.3%
bs=10 sw=10 sl=64 MB/s 0.225 MB/s 0.25 MB/s 0.471 MB/s -10.0% -52.2%
bs=10 sw=10 sl=64 p50 26,307 us 23,948 us 12,626 us +9.8% +108.4%
bs=10 sw=10 sl=64 p95 36,660 us 34,431 us 15,786 us +6.5% +132.2%
bs=10 sw=10 sl=64 p99 36,660 us 34,431 us 19,344 us +6.5% +89.5%
bs=100 sw=10 sl=64 throughput 951 tuples/sec 934 tuples/sec 971.56 tuples/sec +1.8% -2.1%
bs=100 sw=10 sl=64 MB/s 0.581 MB/s 0.57 MB/s 0.593 MB/s +1.9% -2.0%
bs=100 sw=10 sl=64 p50 104,030 us 105,644 us 103,463 us -1.5% +0.5%
bs=100 sw=10 sl=64 p95 126,294 us 128,691 us 110,296 us -1.9% +14.5%
bs=100 sw=10 sl=64 p99 126,294 us 128,691 us 118,690 us -1.9% +6.4%
bs=1000 sw=10 sl=64 throughput 1,103 tuples/sec 1,115 tuples/sec 1,001 tuples/sec -1.1% +10.2%
bs=1000 sw=10 sl=64 MB/s 0.673 MB/s 0.681 MB/s 0.611 MB/s -1.2% +10.1%
bs=1000 sw=10 sl=64 p50 913,699 us 890,382 us 1,008,988 us +2.6% -9.4%
bs=1000 sw=10 sl=64 p95 947,950 us 962,202 us 1,055,260 us -1.5% -10.2%
bs=1000 sw=10 sl=64 p99 947,950 us 962,202 us 1,074,689 us -1.5% -11.8%
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,542.92,200,128000,368,0.225,26306.74,36659.72,36659.72
1,100,10,64,20,2102.22,2000,1280000,951,0.581,104030.47,126294.22,126294.22
2,1000,10,64,20,18140.33,20000,12800000,1103,0.673,913698.72,947950.38,947950.38

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.76%. Comparing base (45b7b20) to head (ec03999).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7168      +/-   ##
============================================
+ Coverage     79.62%   79.76%   +0.14%     
- Complexity     3836     3840       +4     
============================================
  Files          1160     1160              
  Lines         46188    46188              
  Branches       5145     5145              
============================================
+ Hits          36777    36843      +66     
+ Misses         7778     7709      -69     
- Partials       1633     1636       +3     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 45b7b20
agent-service 77.42% <ø> (ø) Carriedforward from 45b7b20
amber 73.47% <ø> (+0.38%) ⬆️
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 12:56

@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 9fa6124 Jul 31, 2026
24 checks passed
@mengw15
mengw15 deleted the chore/7162-userquota-resource-test branch July 31, 2026 19:31
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 UserQuotaResource

4 participants