mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: speed up agent container websocket close test (#25559)
`TestWatchAgentContainers/CoderdWebSocketCanHandleClientClosing` spent about 15 seconds waiting for the real websocket heartbeat ticker to detect that the client closed. Add a clock-aware `HeartbeatClose` wrapper and pass `api.Clock` through the containers watch handler so the test can drive the heartbeat deterministically with `quartz.Mock`. The test still verifies the same client-close teardown path, but it advances the heartbeat tick instead of waiting for wall-clock time. Refs #25557 Discovered as part of the work on CODAGT-381.
This commit is contained in:
@@ -871,7 +871,7 @@ func (api *API) watchWorkspaceAgentContainers(rw http.ResponseWriter, r *http.Re
|
||||
ctx, wsNetConn := codersdk.WebsocketNetConn(ctx, conn, websocket.MessageText)
|
||||
defer wsNetConn.Close()
|
||||
|
||||
go httpapi.HeartbeatClose(ctx, logger, cancel, conn)
|
||||
go httpapi.HeartbeatCloseWithClock(ctx, logger, cancel, conn, api.Clock)
|
||||
|
||||
encoder := json.NewEncoder(wsNetConn)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user