From 46d95cb0f0b3edadc02177e69805f99e28bfe595 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Fri, 1 Dec 2023 11:37:32 +0400 Subject: [PATCH] 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. --- cli/ssh_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/ssh_test.go b/cli/ssh_test.go index e60117ee6f..b865d1d207 100644 --- a/cli/ssh_test.go +++ b/cli/ssh_test.go @@ -406,7 +406,9 @@ func TestSSH(t *testing.T) { // // To work around this, we attempt to send messages in a loop until one succeeds success := make(chan struct{}) + done := make(chan struct{}) go func() { + defer close(done) var ( conn net.Conn err error @@ -444,6 +446,8 @@ func TestSSH(t *testing.T) { fsn.Notify() <-cmdDone fsn.AssertStopped() + // wait for dial goroutine to complete + _ = testutil.RequireRecvCtx(ctx, t, done) // wait for the remote socket to get cleaned up before retrying, // because cleaning up the socket happens asynchronously, and we