Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit655a36c

Browse files
authored
test: fix TestAgentConnectionMonitor_PingTimeout race with mock assertions (#19836)
Fixescoder/internal#970The test doesn't wait for `monitor()` to complete, and the mock database call that we assert takes place in a `defer` within `monitor()`. This allows the mock assertions to race with the defer and flake the test.Solution is to explicitly wait for `monitor()` to complete before the end of the test, so that mock assertions (which happen in a `t.Cleanup()`) don't race.
1 parent4fc0093 commit655a36c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎coderd/workspaceagentsrpc_internal_test.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,14 @@ func TestAgentConnectionMonitor_PingTimeout(t *testing.T) {
150150
AnyTimes().
151151
Return(database.WorkspaceBuild{ID:build.ID},nil)
152152

153-
gouut.monitor(ctx)
153+
done:=make(chanstruct{})
154+
gofunc() {
155+
uut.monitor(ctx)
156+
close(done)
157+
}()
154158
fConn.requireEventuallyClosed(t,websocket.StatusGoingAway,"ping timeout")
155159
fUpdater.requireEventuallySomeUpdates(t,build.WorkspaceID)
160+
_=testutil.TryReceive(ctx,t,done)// ensure monitor() exits before mDB assertions are checked.
156161
}
157162

158163
funcTestAgentConnectionMonitor_BuildOutdated(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp