You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/07/26 03:47:33 UTC
[I] Add unit tests for CollaborationResource [texera]
mengw15 opened a new issue, #6900:
URL: https://github.com/apache/texera/issues/6900
### Task Summary
`CollaborationResource` (`amber/src/main/scala/org/apache/texera/web/resource/CollaborationResource.scala`) is at 0% — all 87 tracked lines are unhit, and there is no spec. It looks websocket-bound but is not: the only dependency is the `javax.websocket.Session` interface, which mocks cleanly with the ScalaMock already on amber's test classpath. `send` is a one-hop `session.getAsyncRemote.sendText`, and every event carries a `"type"` discriminator from `@JsonTypeInfo` on `CollabWebSocketEvent`, so assertions are plain string matches. Roughly 70% of the file — about 60 of the 87 unhit lines — never touches `SqlServer`, and that is what this issue targets; the two DB-backed branches are scoped out below.
### Behavior to add
Add `amber/src/test/scala/org/apache/texera/web/resource/CollaborationResourceSpec.scala`. Build a `mockSession(id)` helper returning a `Session` whose `getId` is fixed and whose `getAsyncRemote.sendText` is expectable.
**Session lifecycle (no DB)**
- `myOnOpen` registers the session in `sessionIdSessionMap`.
- `myOnClose` removes it and drops `sessionIdWIdMap`/`wIdSessionIdsMap` bookkeeping for the sender.
**`WIdRequest` (no DB)** — the authenticated path records `sessionIdUIdMap(sessId) == uId`; the anonymous path records `sessionIdWIdMap(sessId) == DUMMY_WID`. With two sessions on the same wid, assert both appear in `wIdSessionIdsMap(wId)` — the line building that set uses `set.union(Set(senderSessId))`, which returns a new set rather than mutating, and only survives because the result is reassigned. A multi-session test pins that.
**Fan-out (no DB)** — `CommandRequest` and `RestoreVersionRequest`: with three sessions, two on wid 1 and one on wid 2, assert the same-wid peer receives exactly one message, the sender receives none, and the other workflow's session is untouched.
**`HeartBeatRequest` (no DB)** — a single `HeartBeatResponse` back to the sender only.
**`TryLockRequest`, `DUMMY_WID` branch (no DB)** — sends `WorkflowAccessEvent(workflowReadonly = false)` then `LockGrantedEvent`.
**`AcquireLockRequest` (no DB)** — pre-seed `wIdLockHolderSessionIdMap`; assert the previous holder gets `ReleaseLockEvent`, the requester gets `LockGrantedEvent`, and the holder map flips.
### Out of scope
Two branches reach `WorkflowAccessResource.hasWriteAccess` and therefore `SqlServer`: the read-only `TryLockRequest` rejection, and the lock hand-off inside `myOnClose`. Leave both uncovered. Everything above runs in a single JVM against a mocked interface with no database, no filesystem and no network — keep the spec that way rather than pulling in `MockTexeraDB`, which would spawn an embedded Postgres process for two branches.
### Ordering hazard — do not skip
The five `object`-level maps (`sessionIdSessionMap`, `sessionIdWIdMap`, `sessionIdUIdMap`, `wIdSessionIdsMap`, `wIdLockHolderSessionIdMap`) are JVM-wide mutable state. Clear all five in `beforeEach` or the suite becomes order-dependent — that is the only realistic flakiness vector here. There are no clocks, threads or temp files involved. Also note `wIdLockHolderSessionIdMap` deliberately stores a `null` sentinel for "no holder"; tests must distinguish absent-key from null-value.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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: notifications-unsubscribe@texera.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Add unit tests for CollaborationResource [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan closed issue #6900: Add unit tests for CollaborationResource
URL: https://github.com/apache/texera/issues/6900
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Add unit tests for CollaborationResource [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #6900:
URL: https://github.com/apache/texera/issues/6900#issuecomment-5081854477
<!-- texera:template-compliance -->
👋 Thanks for opening this issue, @mengw15!
It looks like the issue description doesn't quite follow our template yet:
- This issue doesn't appear to use one of our templates (Bug, Feature, or Task). Please open it using a template so the required details are captured.
Filling out the template helps reviewers understand and triage your contribution faster. Please edit the description to complete it. This message will disappear automatically once the template is followed.
You can find the template prompts by editing the description, or see [CONTRIBUTING.md](https://github.com/apache/texera/blob/main/CONTRIBUTING.md) for the full contribution flow.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org