From 956c112f16bd224ee8c0d5c2464870e27197e160 Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Wed, 24 Jul 2024 10:31:45 +0100 Subject: [PATCH 1/2] tests: fix flaxy `TestCloseRunningCommand` test Looks like this test was failing due to bad syntax on the `while` loop, which caused it to die after 1 second. If the test took a bit longer, the process would be dead before the following assertions run, causing the test to fail/be flaky. Signed-off-by: Laura Brehm (cherry picked from commit cc68c66c9524b37609f3cf48afff52c1853200fe) Signed-off-by: Laura Brehm --- cli/connhelper/commandconn/commandconn_unix_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/connhelper/commandconn/commandconn_unix_test.go b/cli/connhelper/commandconn/commandconn_unix_test.go index 03bc46936443..b23362c2e4a7 100644 --- a/cli/connhelper/commandconn/commandconn_unix_test.go +++ b/cli/connhelper/commandconn/commandconn_unix_test.go @@ -48,7 +48,7 @@ func TestEOFWithoutError(t *testing.T) { func TestCloseRunningCommand(t *testing.T) { cmd := "sh" - args := []string{"-c", "while true; sleep 1; done"} + args := []string{"-c", "while true; do sleep 1; done"} done := make(chan struct{}) defer close(done) From 6fb9a5b264a65dfc965c25ffcc61e7bc33b4187d Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Wed, 24 Jul 2024 11:52:23 +0100 Subject: [PATCH 2/2] tests: fix other flaky `connhelper` tests Follow up to cc68c66c9524b37609f3cf48afff52c1853200fe (there were more tests with incorrect syntax). Signed-off-by: Laura Brehm (cherry picked from commit 4a7388f0dd6e5e6006907eea536bd04765fbc1d9) Signed-off-by: Laura Brehm --- cli/connhelper/commandconn/commandconn_unix_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/connhelper/commandconn/commandconn_unix_test.go b/cli/connhelper/commandconn/commandconn_unix_test.go index b23362c2e4a7..a8b19b8c7b78 100644 --- a/cli/connhelper/commandconn/commandconn_unix_test.go +++ b/cli/connhelper/commandconn/commandconn_unix_test.go @@ -155,7 +155,7 @@ func (mockStdoutEOF) Close() error { func TestCloseWhileWriting(t *testing.T) { cmd := "sh" - args := []string{"-c", "while true; sleep 1; done"} + args := []string{"-c", "while true; do sleep 1; done"} c, err := New(context.TODO(), cmd, args...) assert.NilError(t, err) @@ -185,7 +185,7 @@ func TestCloseWhileWriting(t *testing.T) { func TestCloseWhileReading(t *testing.T) { cmd := "sh" - args := []string{"-c", "while true; sleep 1; done"} + args := []string{"-c", "while true; do sleep 1; done"} c, err := New(context.TODO(), cmd, args...) assert.NilError(t, err)