mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
tests: Fix sporadic failure of TestXLStorageDeleteFile (#14911)
The test expects from DeleteFile to return errDiskNotFound when the disk is not available. It calls os.RemoveAll() to remove one disk after XL storage initialization. However, this latter contains some goroutines which can race with os.RemoveAll() and then the test fails sporadically with returning random errors. The commit will tweak the initialization routine of the XL storage to only run deletion of temporary and metacache data in the background, so TestXLStorageDeleteFile won't fail anymore.
This commit is contained in:
@@ -959,13 +959,6 @@ func TestXLStorageDeleteFile(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll(path)
|
||||
|
||||
// create xlStorage test setup
|
||||
xlStorageDeletedStorage, diskPath, err := newXLStorageTestSetup()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
||||
}
|
||||
// removing the disk, used to recreate disk not found error.
|
||||
os.RemoveAll(diskPath)
|
||||
// Setup test environment.
|
||||
if err = xlStorage.MakeVol(context.Background(), "success-vol"); err != nil {
|
||||
t.Fatalf("Unable to create volume, %s", err)
|
||||
@@ -1066,6 +1059,17 @@ func TestXLStorageDeleteFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// create xlStorage test setup
|
||||
xlStorageDeletedStorage, diskPath, err := newXLStorageTestSetup()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
||||
}
|
||||
// removing the disk, used to recreate disk not found error.
|
||||
err = os.RemoveAll(diskPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to remoe xlStorage diskpath, %s", err)
|
||||
}
|
||||
|
||||
// TestXLStorage for delete on an removed disk.
|
||||
// should fail with disk not found.
|
||||
err = xlStorageDeletedStorage.Delete(context.Background(), "del-vol", "my-file", false)
|
||||
|
||||
Reference in New Issue
Block a user