mengw15 opened a new pull request, #6904:
URL: https://github.com/apache/texera/pull/6904

   ### What changes were proposed in this PR?
   
   `CollaborationResource` had no spec and sat at 0% — all 87 tracked lines 
unhit. It reads as websocket-bound but the only collaborator is the 
`javax.websocket.Session` interface, which mocks cleanly with the ScalaMock 
already on amber's test classpath, so the session bookkeeping and message 
fan-out are ordinary unit-testable logic.
   
   Adds `CollaborationResourceSpec` with 13 tests covering the session 
lifecycle (`myOnOpen`, `myOnClose`), `WIdRequest` bookkeeping on both the 
authenticated and anonymous paths, `CommandRequest` and `RestoreVersionRequest` 
fan-out, `HeartBeatRequest`, and the locking branches that do not touch the 
database. A `mockSession` helper returns a `Session` with a fixed id whose 
outgoing messages are collected into a buffer; requests are built by 
serializing the real request case classes, so the `"type"` discriminator cannot 
drift out of sync with the production `@JsonTypeInfo` config.
   
   Three behaviors are worth calling out because they are subtle rather than 
obvious:
   
   - The multi-session `WIdRequest` test pins the 
`set.union(Set(senderSessId))` line, which returns a fresh set instead of 
mutating and only works because the result is reassigned into the map.
   - The fan-out tests assert the sender receives nothing, the same-workflow 
peer receives exactly one message, and a session on another workflow is 
untouched.
   - `wIdLockHolderSessionIdMap` stores a `null` sentinel for "no holder", 
which is a distinct state from an absent key. With the sentinel in place, 
`AcquireLockRequest` cannot resolve the holder session and rethrows — the spec 
pins that current behavior.
   
   The five bookkeeping maps live on the companion object and are therefore 
JVM-wide mutable state, so `beforeEach` clears all five; that is what keeps the 
suite order-independent. There are no clocks, threads, temp files or network 
calls in the spec.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6900.
   
   The read-only `TryLockRequest` rejection and the lock hand-off inside 
`myOnClose` both reach `WorkflowAccessResource.hasWriteAccess` and therefore 
`SqlServer`; they are left uncovered rather than pulling `MockTexeraDB` (and an 
embedded Postgres process) in for two branches.
   
   ### How was this PR tested?
   
   `sbt "WorkflowExecutionService/testOnly *CollaborationResourceSpec"` passes 
with 13 tests; `Test/scalafmtCheck` and `Test/scalafix --check` are clean. For 
the failure path, the self-exclusion guard in the `CommandRequest` fan-out was 
temporarily removed from the production code, which reddened the fan-out test 
and exited non-zero, and the guard was then restored — so the assertions 
genuinely constrain the behavior.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (claude-opus-5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to