From b314d26e06ef859d66c098488661fbf2311f8d39 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:04:49 +0200 Subject: [PATCH] wait in second test --- internal/testutil/acc/shared_resource.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/testutil/acc/shared_resource.go b/internal/testutil/acc/shared_resource.go index 3c4f42ed41..5a23ae0efd 100644 --- a/internal/testutil/acc/shared_resource.go +++ b/internal/testutil/acc/shared_resource.go @@ -95,19 +95,19 @@ func SerialSleep(tb testing.TB) { sharedInfo.muSleep.Lock() defer sharedInfo.muSleep.Unlock() - if sharedInfo.alreadySlept { - return + sharedInfo.testCount++ + // SerialSleep is called in tests before they create the cluster, so wait in the second test after the first cluster is being created before creating the second cluster + if sharedInfo.testCount == 2 { + time.Sleep(5 * time.Second) } - time.Sleep(5 * time.Second) - sharedInfo.alreadySlept = true } var sharedInfo = struct { - projectID string - projectName string - clusterName string - mu sync.Mutex - muSleep sync.Mutex - alreadySlept bool - init bool + projectID string + projectName string + clusterName string + mu sync.Mutex + muSleep sync.Mutex + testCount int + init bool }{}