Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

test: add miniClusterMutex to prevent race conditions

Chris Lu6fc170c64576
diff --git a/test/s3tables/s3tables_integration_test.go b/test/s3tables/s3tables_integration_test.go
index 4789018bdd..ac7fcb0d52 100644
--- a/test/s3tables/s3tables_integration_test.go
+++ b/test/s3tables/s3tables_integration_test.go
@@ -12,6 +12,8 @@ import (
"testing"
"time"
+ "sync"
+
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -21,6 +23,10 @@ import (
flag "github.com/seaweedfs/seaweedfs/weed/util/fla9"
)
+var (
+ miniClusterMutex sync.Mutex
+)
+
func TestS3TablesIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
@@ -366,6 +372,10 @@ func startMiniCluster(t *testing.T) (*TestCluster, error) {
go func() {
defer cluster.wg.Done()
+ // Protect global state mutation with a mutex
+ miniClusterMutex.Lock()
+ defer miniClusterMutex.Unlock()
+
// Save current directory and args
oldDir, _ := os.Getwd()
oldArgs := os.Args