mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore(coderd): fix test flake in TestAgentWebsocketMonitor_SendPings (#11518)
This commit is contained in:
@@ -219,14 +219,21 @@ func TestAgentWebsocketMonitor_BuildOutdated(t *testing.T) {
|
||||
|
||||
func TestAgentWebsocketMonitor_SendPings(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
t.Cleanup(cancel)
|
||||
fConn := &fakePingerCloser{}
|
||||
uut := &agentWebsocketMonitor{
|
||||
pingPeriod: testutil.IntervalFast,
|
||||
conn: fConn,
|
||||
}
|
||||
go uut.sendPings(ctx)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
uut.sendPings(ctx)
|
||||
close(done)
|
||||
}()
|
||||
fConn.requireEventuallyHasPing(t)
|
||||
cancel()
|
||||
<-done
|
||||
lastPing := uut.lastPing.Load()
|
||||
require.NotNil(t, lastPing)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user