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:
Anis Elleuch
2022-05-12 23:24:58 +01:00
committed by GitHub
parent 4629abd5a2
commit ca69e54cb6
3 changed files with 14 additions and 11 deletions

View File

@@ -244,7 +244,7 @@ func newXLStorage(ep Endpoint) (s *xlStorage, err error) {
diskIndex: -1,
}
go formatErasureCleanupTmp(s.diskPath) // cleanup any old data.
bgFormatErasureCleanupTmp(s.diskPath) // cleanup any old data.
formatData, formatFi, err := formatErasureMigrate(s.diskPath)
if err != nil && !errors.Is(err, os.ErrNotExist) {