From c247e603d2af5b53be3a259be738991e27e29832 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 31 May 2018 14:03:46 -0700 Subject: [PATCH] terminate disk-usage routine in tests (#5998) tests were written in the manner by editing internal variables of fsObjects to mimic certain behavior from APIs, but this is racy when an active go-routine is reading from the same variable. Make sure to terminate the go-routine if possible for these tests. --- cmd/fs-v1_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/fs-v1_test.go b/cmd/fs-v1_test.go index 35291913d..b9f84519f 100644 --- a/cmd/fs-v1_test.go +++ b/cmd/fs-v1_test.go @@ -191,6 +191,8 @@ func TestFSGetBucketInfo(t *testing.T) { t.Fatal("BucketNotFound error not returned") } + globalServiceDoneCh <- struct{}{} + // Check for buckets and should get disk not found. fs.fsPath = filepath.Join(globalTestTmpDir, "minio-"+nextSuffix()) @@ -301,6 +303,8 @@ func TestFSDeleteObject(t *testing.T) { t.Fatal("Unexpected error: ", err) } + globalServiceDoneCh <- struct{}{} + // Delete object should err disk not found. fs.fsPath = filepath.Join(globalTestTmpDir, "minio-"+nextSuffix()) if err := fs.DeleteObject(context.Background(), bucketName, objectName); err != nil { @@ -342,6 +346,8 @@ func TestFSDeleteBucket(t *testing.T) { obj.MakeBucketWithLocation(context.Background(), bucketName, "") + globalServiceDoneCh <- struct{}{} + // Delete bucket should get error disk not found. fs.fsPath = filepath.Join(globalTestTmpDir, "minio-"+nextSuffix()) if err = fs.DeleteBucket(context.Background(), bucketName); err != nil { @@ -365,6 +371,8 @@ func TestFSListBuckets(t *testing.T) { t.Fatal("Unexpected error: ", err) } + globalServiceDoneCh <- struct{}{} + // Create a bucket with invalid name if err := os.MkdirAll(pathJoin(fs.fsPath, "vo^"), 0777); err != nil { t.Fatal("Unexpected error: ", err)