|
|
@ -99,35 +99,38 @@ func TestNewFS(t *testing.T) { |
|
|
|
// TestFSShutdown - initialize a new FS object layer then calls Shutdown
|
|
|
|
// TestFSShutdown - initialize a new FS object layer then calls Shutdown
|
|
|
|
// to check returned results
|
|
|
|
// to check returned results
|
|
|
|
func TestFSShutdown(t *testing.T) { |
|
|
|
func TestFSShutdown(t *testing.T) { |
|
|
|
// Prepare for tests
|
|
|
|
|
|
|
|
|
|
|
|
// Create and return an fsObject with its path in the disk
|
|
|
|
|
|
|
|
prepareTest := func() (fsObjects, string) { |
|
|
|
disk := filepath.Join(os.TempDir(), "minio-"+nextSuffix()) |
|
|
|
disk := filepath.Join(os.TempDir(), "minio-"+nextSuffix()) |
|
|
|
defer removeAll(disk) |
|
|
|
|
|
|
|
obj := initFSObjects(disk, t) |
|
|
|
obj := initFSObjects(disk, t) |
|
|
|
|
|
|
|
|
|
|
|
fs := obj.(fsObjects) |
|
|
|
fs := obj.(fsObjects) |
|
|
|
fsStorage := fs.storage.(*posix) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bucketName := "testbucket" |
|
|
|
bucketName := "testbucket" |
|
|
|
objectName := "object" |
|
|
|
objectName := "object" |
|
|
|
objectContent := "12345" |
|
|
|
objectContent := "12345" |
|
|
|
|
|
|
|
|
|
|
|
obj.MakeBucket(bucketName) |
|
|
|
obj.MakeBucket(bucketName) |
|
|
|
sha256sum := "" |
|
|
|
sha256sum := "" |
|
|
|
obj.PutObject(bucketName, objectName, int64(len(objectContent)), bytes.NewReader([]byte(objectContent)), nil, sha256sum) |
|
|
|
obj.PutObject(bucketName, objectName, int64(len(objectContent)), bytes.NewReader([]byte(objectContent)), nil, sha256sum) |
|
|
|
|
|
|
|
return fs, disk |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Test Shutdown with regular conditions
|
|
|
|
// Test Shutdown with regular conditions
|
|
|
|
|
|
|
|
fs, disk := prepareTest() |
|
|
|
if err := fs.Shutdown(); err != nil { |
|
|
|
if err := fs.Shutdown(); err != nil { |
|
|
|
t.Fatal("Cannot shutdown the FS object: ", err) |
|
|
|
t.Fatal("Cannot shutdown the FS object: ", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
removeAll(disk) |
|
|
|
|
|
|
|
|
|
|
|
// Test Shutdown with faulty disks
|
|
|
|
// Test Shutdown with faulty disk
|
|
|
|
for i := 1; i <= 5; i++ { |
|
|
|
for i := 1; i <= 5; i++ { |
|
|
|
|
|
|
|
fs, disk := prepareTest() |
|
|
|
|
|
|
|
fsStorage := fs.storage.(*posix) |
|
|
|
fs.storage = newNaughtyDisk(fsStorage, map[int]error{i: errFaultyDisk}, nil) |
|
|
|
fs.storage = newNaughtyDisk(fsStorage, map[int]error{i: errFaultyDisk}, nil) |
|
|
|
if err := fs.Shutdown(); errorCause(err) != errFaultyDisk { |
|
|
|
if err := fs.Shutdown(); errorCause(err) != errFaultyDisk { |
|
|
|
t.Fatal(i, ", Got unexpected fs shutdown error: ", err) |
|
|
|
t.Fatal(i, ", Got unexpected fs shutdown error: ", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
removeAll(disk) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TestFSLoadFormatFS - test loadFormatFS with healty and faulty disks
|
|
|
|
// TestFSLoadFormatFS - test loadFormatFS with healty and faulty disks
|
|
|
|