Skip to content

Commit 24df7b6

Browse files
committed
Use a global mutux rather than one per struct
1 parent f4c09f3 commit 24df7b6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/octopus_container_test_framework.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ func (g *TestLogConsumer) Accept(l testcontainers.Log) {
5656
fmt.Println(string(l.Content))
5757
}
5858

59+
var globalMutex = sync.Mutex{}
60+
5961
type OctopusContainerTest struct {
60-
mu sync.Mutex
6162
}
6263

6364
func (o *OctopusContainerTest) enableContainerLogging(container testcontainers.Container, ctx context.Context) error {
@@ -296,15 +297,15 @@ func (o *OctopusContainerTest) ArrangeTest(t *testing.T, testFunc func(t *testin
296297
// I don't think test containers are thread safe - parallel tests
297298
// frequently show that multiple tests access the same containers.
298299
// So only one thread can create a stack at a time
299-
o.mu.Lock()
300+
globalMutex.Lock()
300301
network, octopusContainer, sqlServer, err := o.createDockerInfrastructure(t, ctx)
301-
o.mu.Unlock()
302+
globalMutex.Unlock()
302303

303304
// Attempt to clean up whatever resources were created.
304305
// Don't return errors for the cleanup, just report them
305306
defer func() {
306-
o.mu.Lock()
307-
defer o.mu.Unlock()
307+
globalMutex.Lock()
308+
defer globalMutex.Unlock()
308309

309310
stopTime := 1 * time.Minute
310311

0 commit comments

Comments
 (0)