mirror of
https://github.com/minio/minio.git
synced 2025-11-29 05:19:03 -05:00
Avoid hiding disk errors in some cases in FS Shutdown (#2668)
This commit is contained in:
committed by
Harshavardhana
parent
241c56e6d7
commit
51e337228e
@@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -59,3 +60,39 @@ func TestNewFS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestFSShutdown - initialize a new FS object layer then calls Shutdown
|
||||
// to check returned results
|
||||
func TestFSShutdown(t *testing.T) {
|
||||
// Create an FS object and shutdown it. No errors expected
|
||||
disk := filepath.Join(os.TempDir(), "minio-"+nextSuffix())
|
||||
obj, err := newFSObjects(disk)
|
||||
if err != nil {
|
||||
t.Fatal("Cannot create a new FS object: ", err)
|
||||
}
|
||||
|
||||
fs := obj.(fsObjects)
|
||||
fsStorage := fs.storage.(*posix)
|
||||
|
||||
bucketName := "testbucket"
|
||||
objectName := "object"
|
||||
objectContent := "12345"
|
||||
|
||||
obj.MakeBucket(bucketName)
|
||||
obj.PutObject(bucketName, objectName, int64(len(objectContent)), bytes.NewReader([]byte(objectContent)), nil)
|
||||
|
||||
if err := fs.Shutdown(); err != nil {
|
||||
t.Fatal("Cannot shutdown the FS object: ", err)
|
||||
}
|
||||
|
||||
// Create an FS and program errors with disks when shutdown is called
|
||||
for i := 1; i <= 5; i++ {
|
||||
naughty := newNaughtyDisk(fsStorage, map[int]error{i: errFaultyDisk}, nil)
|
||||
fs.storage = naughty
|
||||
if err := fs.Shutdown(); err != errFaultyDisk {
|
||||
t.Fatal(i, ", Got unexpected fs shutdown error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
removeAll(disk)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user