test(amber): add unit test coverage for UserQuotaResource - #7168
Conversation
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
🟢 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
UserQuotaResourceSpecwith empty + populated cases for created/accessed workflows, quota storage sizing, and created datasets. - Add coverage for deletion behavior via
deleteExecutionCollectionand thedeleteCollectionendpoint, 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.
|
| 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 Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What changes were proposed in this PR?
Adds
UserQuotaResourceSpecforUserQuotaResource(previously ~0% coverage,no spec). The suite runs against embedded Postgres via
MockTexeraDBand seedsusers / 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 whenWORKFLOW_OF_USERis seeded.getUserAccessedWorkflow— empty list with no grants; the accessible workflow ids fromWORKFLOW_USER_ACCESS.getUserQuotaSize— empty array with no executions; the assembled per-executionresultBytes/runTimeStatsBytes/logBytes(seeded acrossWORKFLOW_EXECUTIONS.RUNTIME_STATS_SIZE,OPERATOR_PORT_EXECUTIONS.RESULT_SIZE, andOPERATOR_EXECUTIONS.CONSOLE_MESSAGES_SIZE).getCreatedWorkflow,getAccessedWorkflow,getUserQuota,getCreatedDatasets) via anew SessionUser, covering the thin delegation wrappers;getCreatedDatasetscovers the empty case and the created-datasets case (size is deterministically 0 — the size calculation is disabled in the current dataset implementation).deleteExecutionCollectionand thedeleteCollectionendpoint — assert the execution row is removed fromWORKFLOW_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:
The failure path was verified by deliberately breaking an assertion and
confirming the suite goes red. To keep the suite deterministic, the
creationTimeassertion compares against the DB round-tripped value rather thanthe 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])