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.
This commit is contained in:
Harshavardhana 2018-05-31 14:03:46 -07:00 committed by kannappanr
parent 74328c3061
commit c247e603d2

View File

@ -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)