From 57ef2767a5e39e54066d8a86936c38a897af8b43 Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Sat, 14 Dec 2024 12:25:05 +0100 Subject: [PATCH] test(action): add timeout to SSH server start Signed-off-by: AtomicFS --- action/container/ssh_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/action/container/ssh_test.go b/action/container/ssh_test.go index c09ffdc3..5390006f 100644 --- a/action/container/ssh_test.go +++ b/action/container/ssh_test.go @@ -9,6 +9,7 @@ import ( "fmt" "os" "testing" + "time" "dagger.io/dagger" "github.com/stretchr/testify/assert" @@ -110,7 +111,15 @@ func TestOpenSSH(t *testing.T) { assert.NoError(t, err) }() // Wait until SSH server is ready - <-tc.optsSSH.TunnelReady + ticker := time.NewTicker(5 * time.Second) + select { + case <-tc.optsSSH.TunnelReady: + ticker.Stop() + case <-ticker.C: + ticker.Stop() + ctx.Done() + assert.FailNow(t, "timeout waiting for SSH server to be ready") + } // Connect with client config := &ssh.ClientConfig{