test(auth): add unit test coverage for JwtAuth, RequestLoggingFilter, and UserActivityTracker#6093
test(auth): add unit test coverage for JwtAuth, RequestLoggingFilter, and UserActivityTracker#6093aglinxinyuan wants to merge 2 commits into
Conversation
… and UserActivityTracker - JwtAuth.jwtClaims: field mapping, config-derived expiry (ignoring expireInDays), JwtParser round-trip, null-optional-field tolerance - RequestLoggingFilter: chain delegation + request logging, and register() wiring (mockito for the servlet/jetty types) - UserActivityTracker: extend the existing spec to cover the markActive and evictStale catch blocks via a throwing clock
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
Adds Scala unit-test coverage for previously under-tested common/auth behavior (JWT claim issuance/parsing, request logging filter wiring, and user-activity tracking exception paths) without changing production code.
Changes:
- Add
JwtAuthSpecto pin claim mapping, config-derived expiry, token round-trip viaJwtParser, and null-optional handling. - Add
RequestLoggingFilterSpecto coverdoFilterandregisterwiring. - Extend
UserActivityTrackerSpecto exercisemarkActive/evictStaleexception-swallowing paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| common/auth/src/test/scala/org/apache/texera/auth/JwtAuthSpec.scala | New unit tests for JWT claim contents, expiry derivation, and parser round-trip. |
| common/auth/src/test/scala/org/apache/texera/auth/RequestLoggingFilterSpec.scala | New unit tests for request logging filter delegation and servlet-context registration. |
| common/auth/src/test/scala/org/apache/texera/auth/UserActivityTrackerSpec.scala | Additional tests to cover exception-handling branches in activity tracking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6093 +/- ##
============================================
+ Coverage 58.17% 58.54% +0.37%
- Complexity 3144 3179 +35
============================================
Files 1132 1132
Lines 43674 43674
Branches 4734 4734
============================================
+ Hits 25407 25569 +162
+ Misses 16831 16675 -156
+ Partials 1436 1430 -6
*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:
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 378 | 0.231 | 25,428/33,686/33,686 us | 🔴 -9.1% / 🔴 +119.7% |
| ⚪ | bs=100 sw=10 sl=64 | 777 | 0.474 | 126,668/155,558/155,558 us | ⚪ within ±5% / 🔴 +43.6% |
| ⚪ | bs=1000 sw=10 sl=64 | 924 | 0.564 | 1,075,537/1,160,058/1,160,058 us | ⚪ within ±5% / 🔴 +12.4% |
Baseline details
Latest main a3f22bb from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 378 tuples/sec | 416 tuples/sec | 772.08 tuples/sec | -9.1% | -51.0% |
| bs=10 sw=10 sl=64 | MB/s | 0.231 MB/s | 0.254 MB/s | 0.471 MB/s | -9.1% | -51.0% |
| bs=10 sw=10 sl=64 | p50 | 25,428 us | 23,488 us | 12,745 us | +8.3% | +99.5% |
| bs=10 sw=10 sl=64 | p95 | 33,686 us | 34,127 us | 15,330 us | -1.3% | +119.7% |
| bs=10 sw=10 sl=64 | p99 | 33,686 us | 34,127 us | 19,054 us | -1.3% | +76.8% |
| bs=100 sw=10 sl=64 | throughput | 777 tuples/sec | 815 tuples/sec | 982.64 tuples/sec | -4.7% | -20.9% |
| bs=100 sw=10 sl=64 | MB/s | 0.474 MB/s | 0.497 MB/s | 0.6 MB/s | -4.6% | -21.0% |
| bs=100 sw=10 sl=64 | p50 | 126,668 us | 121,213 us | 101,961 us | +4.5% | +24.2% |
| bs=100 sw=10 sl=64 | p95 | 155,558 us | 150,823 us | 108,335 us | +3.1% | +43.6% |
| bs=100 sw=10 sl=64 | p99 | 155,558 us | 150,823 us | 114,379 us | +3.1% | +36.0% |
| bs=1000 sw=10 sl=64 | throughput | 924 tuples/sec | 920 tuples/sec | 1,013 tuples/sec | +0.4% | -8.8% |
| bs=1000 sw=10 sl=64 | MB/s | 0.564 MB/s | 0.562 MB/s | 0.618 MB/s | +0.4% | -8.8% |
| bs=1000 sw=10 sl=64 | p50 | 1,075,537 us | 1,087,133 us | 993,573 us | -1.1% | +8.2% |
| bs=1000 sw=10 sl=64 | p95 | 1,160,058 us | 1,147,506 us | 1,032,489 us | +1.1% | +12.4% |
| bs=1000 sw=10 sl=64 | p99 | 1,160,058 us | 1,147,506 us | 1,065,526 us | +1.1% | +8.9% |
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,528.71,200,128000,378,0.231,25427.62,33686.07,33686.07
1,100,10,64,20,2573.55,2000,1280000,777,0.474,126668.02,155557.81,155557.81
2,1000,10,64,20,21638.61,20000,12800000,924,0.564,1075537.23,1160057.84,1160057.84- JwtAuth: assert the expiry window tracks AuthConfig for two very different expireInDays values, proving the argument is ignored rather than coincidentally matching - RequestLoggingFilter: force the request-log logger to INFO and use Mockito inOrder to assert the chain is invoked before the request fields are read
What changes were proposed in this PR?
Add unit test coverage for three
common/authclasses, selected from the Codecov report. No production-code changes.JwtAuth.scalajwtClaimsmaps everyUserfield onto its claim; expiry is derived fromAuthConfig(theexpireInDaysarg is ignored — a real quirk); token round-trips back throughJwtParser; null optional fields don't errorRequestLoggingFilter.scaladoFilterdelegates to the chain and logs the request line;registerwires the filter onto the servlet context for all dispatch types (mockito for the servlet/jetty types)UserActivityTracker.scalamarkActiveandevictStalecatch blocks (via a throwing clock)Any related issues, documentation, discussions?
Follow-up to the review feedback on #6043: prioritize tests that fill uncovered code paths.
How was this PR tested?
sbt "Auth/testOnly *JwtAuthSpec *RequestLoggingFilterSpec *UserActivityTrackerSpec"— 15 tests, all greensbt "Auth/Test/scalafmtCheck"andsbt "Auth/scalafixAll --check"— cleanWas this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])