Skip to content

fix(ci): unpin ServerProfilingIT and GrpcAuthInterceptorTest from implementation details that moved under them - #6890

Merged
robfrank merged 1 commit into
mainfrom
fix/ci-main-33266454013-triage
Aug 30, 2026
Merged

robfrank merged 1 commit into
mainfrom
fix/ci-main-33266454013-triage

Conversation

@robfrank

@robfrank robfrank commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the two test failures red on main in run 33266454013. Both are tests asserting something the code never promised. Neither covers a regression in the code under test - the production behaviour in both cases is the intended one, and in one case it is a security fix that shipped without a test.

ServerProfilingIT - 11 failures + 1 cascading error (integration-tests lane)

expected: "albert"
 but was: "root"
	at ServerProfilingIT.checkJohnUser(ServerProfilingIT.java:598)

checkJohnUser() asserted that "albert" is the first line of server-users.jsonl:

assertThat(repository.getUsers().getFirst().getString("name")).isEqualTo("albert");

That order is whatever order ServerSecurity happens to serialize its user store in. Nothing reads it - this assertion was its only consumer.

It used to be produced by usersToJSON() iterating users, a ConcurrentHashMap, whose hash order for these two names happens to be [albert, root] (verified). Since 9fbbb06 ("persist before publishing a user mutation") createUser persists snapshotWith(name, cfg), which walks the pre-mutation map and appends the new user, so the file is now [root, albert]. Deterministic append order rather than hash order - the better of the two, and no reason to change it back to satisfy a test.

The assertion now names which principals were persisted rather than which line each landed on:

final List<String> persistedUsers = repository.getUsers().stream().map(user -> user.getString("name")).toList();
assertThat(persistedUsers).containsExactlyInAnyOrder("root", "albert");

Strictly stronger than the pair it replaces (size() == 2 plus a positional name check), and immune to the next change in serialization order.

The 12th test, multipleGroupsAnyType, errored with Cannot create bucket 'Bucket1' because already exists. That is a cascade, not a separate cause: an earlier test failed at checkJohnUser() before reaching its dropSchema(), leaving the schema behind. It goes green with the assertion fixed.

GrpcAuthInterceptorTest.validateTokenReturnsTrueForValidSession (unit-tests lane)

Wanted but not invoked: serverCallHandler.startCall(<any>, <any>);
Actually, there were zero interactions with this mock.

7c4e44a (#6808) closed a revocation hole: the gRPC bearer branch trusted the ServerSecurityUser the HttpAuthSession captured at login, so a dropped or rotated principal kept authenticating until its token idle-expired. getValidSession() now re-resolves the name against the live users map.

The test stubs getUsers() (to make security enabled) but not getUser(), so the Mockito mock returned null and every token read as an orphan - the call was closed and startCall never reached. Stubbed, with the reason stated at the stub so the next person does not read it as boilerplate.

Added coverage for the revocation itself

That branch shipped with no gRPC test, so the behaviour #6808 exists to enforce was unguarded on this transport. validateTokenReturnsFalseWhenPrincipalNoLongerExists asserts both halves:

  • the call is closed and the handler never starts, and
  • the orphaned session is evicted (removeSession), so it cannot keep answering getSessionByToken() until it idle-expires.

Proven able to fail: with the security.getUser(...) == null branch disabled, the new test fails on the removeSession verification and the other 8 stay green.

Verification

Suite Result
mvn -o -pl grpcw verify 201/201 green
mvn -o -pl server verify -DskipITs=false -Dtest='com.arcadedb.server.security.**' -Dit.test='com.arcadedb.server.security.**' 139/139 green, incl. ServerProfilingIT 13/13
Both failures reproduced on main first identical to CI (11F+1E, and 1F)

Test-only change: no src/main file is touched.

Summary by CodeRabbit

  • Bug Fixes

    • Improved gRPC authentication so sessions for removed users are rejected immediately.
    • Invalid or orphaned sessions are now closed, preventing further requests from reaching handlers.
  • Tests

    • Expanded authentication coverage for revoked users and inactive sessions.
    • Improved persisted-user verification to work regardless of result ordering.

… them

Both failures on main are tests asserting something the code never promised, not
regressions in the code they cover.

ServerProfilingIT (11 failures + 1 cascading error): checkJohnUser() asserted that
"albert" is the FIRST line of server-users.jsonl. That order is whatever order
ServerSecurity serializes its user store in, and nothing reads it. It used to come
straight out of a ConcurrentHashMap, whose hash order happens to iterate
[albert, root]; since 9fbbb06 persists a mutation BEFORE publishing it,
snapshotWith() appends the new user to the pre-mutation list, so the file is now
[root, albert]. The assertion now names which principals were persisted, not which
line each landed on - strictly stronger than before, and immune to the next change
in serialization order. The 12th test errored on "Bucket1 already exists": it is a
cascade, an earlier test failing at checkJohnUser() before reaching dropSchema().

GrpcAuthInterceptorTest.validateTokenReturnsTrueForValidSession: 7c4e44a (#6808)
made the bearer branch re-resolve the session's principal against the live users map
so a dropped or rotated principal's token stops working at once. The test stubs
getUsers() but not getUser(), so the mock returned null and every token now reads as
an orphaned one. Stubbed, with the reason stated at the stub.

That branch shipped with no gRPC test, so the revocation it enforces was unguarded on
this transport. Added validateTokenReturnsFalseWhenPrincipalNoLongerExists, which
asserts both halves: the call is closed, and the orphaned session is evicted rather
than left to answer getSessionByToken() until it idle-expires. Verified it fails when
the branch is disabled.

Verification: grpcw 201/201, server com.arcadedb.server.security.** 139/139 (includes
ServerProfilingIT 13/13), both green.
@codacy-production

codacy-production Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage ∅ diff coverage · -6.43% coverage variation

Metric Results
Coverage variation ✅ -6.43% coverage variation
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5d86d17) 168316 135397 80.44%
Head commit (b3fb200) 200703 (+32387) 148545 (+13148) 74.01% (-6.43%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6890) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@mergify

mergify Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a90aa33-43d9-42c6-921f-4ca04090687b

📥 Commits

Reviewing files that changed from the base of the PR and between 5d86d17 and b3fb200.

📒 Files selected for processing (2)
  • grpcw/src/test/java/com/arcadedb/server/grpc/GrpcAuthInterceptorTest.java
  • server/src/test/java/com/arcadedb/server/security/ServerProfilingIT.java

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The changes strengthen gRPC authentication test coverage for removed users and make persisted-user assertions independent of serialization order.

Changes

gRPC authentication validation

Layer / File(s) Summary
Live principal and orphaned-session coverage
grpcw/src/test/java/com/arcadedb/server/grpc/GrpcAuthInterceptorTest.java
The valid-session test stubs live principal lookup. New coverage rejects orphaned tokens, removes their sessions, closes calls, and prevents handler execution.

Persisted-user assertion

Layer / File(s) Summary
Order-independent persisted-user check
server/src/test/java/com/arcadedb/server/security/ServerProfilingIT.java
The test collects persisted usernames and verifies exactly root and albert without relying on serialization order.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b3fb2

This test-only change updates assertions to match the intended behavior and adds coverage for principal revocation; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: updating ServerProfilingIT and GrpcAuthInterceptorTest so they no longer depend on implementation details. It is specific and related to the changeset.
Description check ✅ Passed The description gives a detailed summary, motivation, failure details, test changes, security context, and verification results. It does not use all template headings or include the checklist, but it …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives a detailed summary, motivation, failure details, test changes, security context, and verification results. It does not use all template headings or include the checklist, but it provides the required review context and is mostly complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-main-33266454013-triage

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Aug 29, 2026

Copy link
Copy Markdown

Reviewed the diff. This is a clean, well-scoped test-only fix, both changes are correct.

ServerProfilingIT.checkJohnUser

  • Replacing the positional getFirst().getString("name")).isEqualTo("albert") check with containsExactlyInAnyOrder("root", "albert") is the right fix: it's strictly stronger than the pair it replaces (still implicitly asserts exactly 2 elements, no extras/dupes) while dropping the coupling to serialization order, which was never a documented contract. Verified SecurityUserFileRepository.getUsers() still returns a List, so .stream() works fine here.
  • The comment explaining why the order changed (ConcurrentHashMap hash order vs. the newer persist-before-publish append order from 9fbbb06) is genuinely useful context for the next person who touches this and is exactly the kind of "why, not what" comment called for in this repo's conventions.

GrpcAuthInterceptorTest

  • The added when(mockSecurity.getUser("testuser")).thenReturn(mockUser) stub correctly matches GrpcAuthInterceptor.getValidSession()'s re-resolution against the live users map (line 235 of GrpcAuthInterceptor.java), fixing the "zero interactions" Mockito failure caused by the previously-unstubbed getUser() returning null.
  • The new validateTokenReturnsFalseWhenPrincipalNoLongerExists test is a solid regression test for the revocation fix in POST/PUT/DELETE /api/v1/server/users mutate users only on the node that served the request, while the equivalent POST /api/v1/server commands replicate through Raft #6808: it exercises the actual code path (orphaned principal → call closed, startCall never reached, session evicted via removeSession), not just a happy-path stub fix. Good catch that this behavior previously shipped without direct test coverage.
  • Verified HttpAuthSessionManager.removeSession(String) and ServerSecurity.getUser(String) signatures match what's stubbed/verified here.

Minor/nit

  • No functional issues found. Both tests now assert on behavior/contract rather than incidental implementation detail, which should make them robust to future refactors.

No production code changes, no new dependencies, no security or performance concerns beyond what's already covered by the #6808 fix these tests now protect.

@codecov

codecov Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.88%. Comparing base (5d86d17) to head (b3fb200).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6890      +/-   ##
==========================================
+ Coverage   71.86%   71.88%   +0.02%     
==========================================
  Files        1883     1883              
  Lines      168316   168316              
  Branches    35664    35664              
==========================================
+ Hits       120959   120997      +38     
+ Misses      32958    32929      -29     
+ Partials    14399    14390       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robfrank
robfrank merged commit 8d6af94 into main Aug 30, 2026
50 of 54 checks passed
@robfrank
robfrank deleted the fix/ci-main-33266454013-triage branch August 30, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant