From 1e2706273236f8dbea81da9395deace1f4dcedc4 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Mon, 29 Mar 2021 09:52:32 -0400 Subject: [PATCH] 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) --- physical/mysql/mysql_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/physical/mysql/mysql_test.go b/physical/mysql/mysql_test.go index 20de019caa..27d596b95e 100644 --- a/physical/mysql/mysql_test.go +++ b/physical/mysql/mysql_test.go @@ -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) } }