Skip to content

Commit 46d95cb

Browse files
authored
fix: wait for dial goroutine to complete (#10959)
Fixes flake seen here: https://github.com/coder/coder/runs/19170327767 The goroutine that attempts to dial the socket didn't complete before the test did. Here we add an explicit wait for it to complete in each run of the loop.
1 parent 812fb95 commit 46d95cb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cli/ssh_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ func TestSSH(t *testing.T) {
406406
//
407407
// To work around this, we attempt to send messages in a loop until one succeeds
408408
success := make(chan struct{})
409+
done := make(chan struct{})
409410
go func() {
411+
defer close(done)
410412
var (
411413
conn net.Conn
412414
err error
@@ -444,6 +446,8 @@ func TestSSH(t *testing.T) {
444446
fsn.Notify()
445447
<-cmdDone
446448
fsn.AssertStopped()
449+
// wait for dial goroutine to complete
450+
_ = testutil.RequireRecvCtx(ctx, t, done)
447451

448452
// wait for the remote socket to get cleaned up before retrying,
449453
// because cleaning up the socket happens asynchronously, and we

0 commit comments

Comments
 (0)