Skip to content

Commit d1a8f26

Browse files
authored
sleep first time only (#2696)
1 parent 1713b99 commit d1a8f26

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

internal/testutil/acc/shared_resource.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func ClusterNameExecution(tb testing.TB) (projectID, clusterName string) {
8585
return sharedInfo.projectID, sharedInfo.clusterName
8686
}
8787

88-
// SerialSleep waits a few seconds so clusters are not created concurrently in the execution project, see HELP-65223.
88+
// SerialSleep waits a few seconds the first time so the first cluster in a project is not created concurrently, see HELP-65223.
8989
// This must be called once the test is marked as parallel, e.g. in PreCheck inside Terraform tests.
9090
func SerialSleep(tb testing.TB) {
9191
tb.Helper()
@@ -94,14 +94,20 @@ func SerialSleep(tb testing.TB) {
9494

9595
sharedInfo.muSleep.Lock()
9696
defer sharedInfo.muSleep.Unlock()
97-
time.Sleep(10 * time.Second)
97+
98+
if sharedInfo.alreadySlept {
99+
return
100+
}
101+
time.Sleep(5 * time.Second)
102+
sharedInfo.alreadySlept = true
98103
}
99104

100105
var sharedInfo = struct {
101-
projectID string
102-
projectName string
103-
clusterName string
104-
mu sync.Mutex
105-
muSleep sync.Mutex
106-
init bool
106+
projectID string
107+
projectName string
108+
clusterName string
109+
mu sync.Mutex
110+
muSleep sync.Mutex
111+
alreadySlept bool
112+
init bool
107113
}{}

0 commit comments

Comments
 (0)