diff --git a/test/integration/concierge_impersonation_proxy_test.go b/test/integration/concierge_impersonation_proxy_test.go index f2b6bb12b..adda98f07 100644 --- a/test/integration/concierge_impersonation_proxy_test.go +++ b/test/integration/concierge_impersonation_proxy_test.go @@ -599,6 +599,11 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl // start but don't wait for the attach command err = attachCmd.Start() require.NoError(t, err) + attachExitCh := make(chan struct{}) + go func() { + assert.NoError(t, attachCmd.Wait()) + close(attachExitCh) + }() // write to stdin on the attach process _, err = attachStdin.Write([]byte(echoString + "\n")) @@ -611,8 +616,7 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl // close stdin and attach process should exit err = attachStdin.Close() require.NoError(t, err) - err = attachCmd.Wait() - require.NoError(t, err) + requireClose(t, attachExitCh, time.Second*20) }) t.Run("websocket client", func(t *testing.T) { @@ -1183,3 +1187,16 @@ func isServiceUnavailableViaSquidError(err error, proxyServiceEndpoint string) ( return true, "" } + +func requireClose(t *testing.T, c chan struct{}, timeout time.Duration) { + t.Helper() + timer := time.NewTimer(timeout) + select { + case <-c: + if !timer.Stop() { + <-timer.C + } + case <-timer.C: + require.FailNow(t, "failed to receive from channel within "+timeout.String()) + } +}