Skip to content

Commit 5ecb0db

Browse files
authored
chore(coderd): fix test flake in TestAgentWebsocketMonitor_SendPings (#11518)
1 parent 5ed3c41 commit 5ecb0db

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

coderd/workspaceagentsrpc_internal_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,21 @@ func TestAgentWebsocketMonitor_BuildOutdated(t *testing.T) {
219219

220220
func TestAgentWebsocketMonitor_SendPings(t *testing.T) {
221221
t.Parallel()
222-
ctx := testutil.Context(t, testutil.WaitShort)
222+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
223+
t.Cleanup(cancel)
223224
fConn := &fakePingerCloser{}
224225
uut := &agentWebsocketMonitor{
225226
pingPeriod: testutil.IntervalFast,
226227
conn: fConn,
227228
}
228-
go uut.sendPings(ctx)
229+
done := make(chan struct{})
230+
go func() {
231+
uut.sendPings(ctx)
232+
close(done)
233+
}()
229234
fConn.requireEventuallyHasPing(t)
235+
cancel()
236+
<-done
230237
lastPing := uut.lastPing.Load()
231238
require.NotNil(t, lastPing)
232239
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy