Skip to content

Commit c1a61b9

Browse files
internal/tests/cluster: switch flaky test to polling (hashicorp#3153)
* internal/tests/cluster: switch flaky test to polling Also extend deadline from 10 seconds to 1 minute, hopefully this should fix any flakiness in this test. * fixup! internal/tests/cluster: switch flaky test to polling
1 parent ecdb77b commit c1a61b9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

internal/tests/cluster/switch_kms_method_test.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cluster
55

66
import (
7+
"context"
78
"os"
89
"strings"
910
"sync"
@@ -74,8 +75,22 @@ func TestWorkerUpgradeKmsAuthMethod(t *testing.T) {
7475
})
7576
defer w1.Shutdown()
7677

77-
// Give time for it to connect
78-
time.Sleep(10 * time.Second)
78+
timeout := time.Minute
79+
ctx, cancel := context.WithTimeout(context.Background(), timeout)
80+
defer cancel()
81+
for {
82+
logBuf, err = os.ReadFile(ec.AllEvents.Name())
83+
require.NoError(t, err)
84+
if strings.Count(string(logBuf), "worker has successfully authenticated") == 2 {
85+
break
86+
}
87+
select {
88+
case <-ctx.Done():
89+
t.Fatal("worker had not successfully connected after ", timeout.String())
90+
case <-time.After(time.Second):
91+
// Try again
92+
}
93+
}
7994

8095
// We should find only one nonce, and one successful worker authentication,
8196
// both in the output and in the database

0 commit comments

Comments
 (0)