Use a 10s timeout instead of 3s to reduce test flakiness. The purpose of the timeout is to ensure that if something's broken the test doesn't run forever. However if things are slow, it could lead to the test failing. Also report on whether we got the lock so that if this fix doesn't solve the problem, we have more information to go on. (#11222)

This commit is contained in:
Nick Cabatoff 2021-03-29 09:52:32 -04:00 committed by GitHub
parent 65f1f2cccd
commit 1e27062732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,9 +233,8 @@ func TestMySQLHABackend_LockFailPanic(t *testing.T) {
t.Fatalf("lock 2: %v", err)
}
// Cancel attempt in 50 msec
stopCh := make(chan struct{})
time.AfterFunc(3*time.Second, func() {
time.AfterFunc(10*time.Second, func() {
close(stopCh)
})
@ -256,14 +255,13 @@ func TestMySQLHABackend_LockFailPanic(t *testing.T) {
// trigger the panic shown in https://github.com/hashicorp/vault/issues/8203
cleanup()
// Cancel attempt in 50 msec
stopCh2 := make(chan struct{})
time.AfterFunc(3*time.Second, func() {
time.AfterFunc(10*time.Second, func() {
close(stopCh2)
})
leaderCh2, err = lock2.Lock(stopCh2)
if err == nil {
t.Fatalf("expected error, got none")
t.Fatalf("expected error, got none, leaderCh2=%v", leaderCh2)
}
}