From 03f8b25b502c7a93b4e3f5190be6ce13f082cf53 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 16 May 2022 05:36:00 -0700 Subject: [PATCH] disable connectDisks loop under testing (#14920) avoids races during tests, keeps tests predictable --- cmd/erasure-sets.go | 4 +++- cmd/globals.go | 3 +++ cmd/test-utils_test.go | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 61964f1b4..e3f85e2d3 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -485,7 +485,9 @@ func newErasureSets(ctx context.Context, endpoints PoolEndpoints, storageDisks [ go s.cleanupDeletedObjects(ctx) // Start the disk monitoring and connect routine. - go s.monitorAndConnectEndpoints(ctx, defaultMonitorConnectEndpointInterval) + if !globalIsTesting { + go s.monitorAndConnectEndpoints(ctx, defaultMonitorConnectEndpointInterval) + } return s, nil } diff --git a/cmd/globals.go b/cmd/globals.go index 66062644a..715600cbb 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -139,6 +139,9 @@ var ( // Indicates if the running minio is in gateway mode. globalIsGateway = false + // Indicates if server code should go through testing path. + globalIsTesting = false + // Name of gateway server, e.g S3, NAS etc globalGatewayName = "" diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index 6a6bc7324..b3d40b627 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -73,6 +73,9 @@ import ( func TestMain(m *testing.M) { flag.Parse() + // set to 'true' when testing is invoked + globalIsTesting = true + globalActiveCred = auth.Credentials{ AccessKey: auth.DefaultAccessKey, SecretKey: auth.DefaultSecretKey,