Skip to content

flake: TestAgentConnectionMonitor_PingTimeout #970

@blink-so

Description

@blink-so

CI Run Link: https://github.com/coder/coder/actions/runs/17552496980

Commit Info: 065c7c3d5d6d50d5aba665fa05086161247863a0 by brettkolodny

Assignment Analysis:
Used git blame -L 98,156 ./coderd/workspaceagentsrpc_internal_test.go to identify test ownership. The test function TestAgentConnectionMonitor_PingTimeout was primarily authored by Spike Curtis (commits c9b7d61769 and b79785c86f from 2024-01-02 and 2024-02-01).

Error Analysis:
The test failed with a gomock expectation error:

controller.go:97: missing call(s) to *dbmock.MockStore.UpdateWorkspaceAgentConnectionByID(is anything, {agent=d5ebb7d0-6a88-4d76-a7d0-30e5a2d86173, replica=f7234106-910a-4b75-a6a8-6643df6fac8b, disconnected=true}) /home/runner/work/coder/coder/coderd/workspaceagentsrpc_internal_test.go:142
controller.go:97: aborting test due to missing call(s)

Root Cause:
This appears to be a timing-related flake in the agent connection monitor test. The test expects a specific mock call to UpdateWorkspaceAgentConnectionByID with disconnected=true to occur when a ping timeout happens, but the call was not made within the expected timeframe. This suggests a race condition between the ping timeout logic and the test expectations.

Test Details:

  • File: coderd/workspaceagentsrpc_internal_test.go
  • Function: TestAgentConnectionMonitor_PingTimeout (lines 98-156)
  • Test Type: Mock-based unit test for agent connection monitoring
  • Failure Pattern: Missing expected mock call for database update

Related Context:
The test sets up an agentConnectionMonitor with a fake connection and mock database, then simulates a ping timeout by setting lastPing to an hour in the past. It expects the monitor to detect the timeout and call UpdateWorkspaceAgentConnectionByID with disconnected=true, but this call didn't occur.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions