Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fixes sleep in tests #2707

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions internal/testutil/acc/shared_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}{}