2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-06-29 06:13:44 -04:00
|
|
|
|
2016-08-18 19:23:42 -04:00
|
|
|
package cmd
|
2016-06-29 06:13:44 -04:00
|
|
|
|
|
|
|
import (
|
2016-09-13 14:01:10 -04:00
|
|
|
"bytes"
|
2022-10-14 06:08:40 -04:00
|
|
|
"context"
|
2017-01-16 20:05:00 -05:00
|
|
|
"os"
|
2016-06-29 06:13:44 -04:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2019-03-14 16:08:51 -04:00
|
|
|
|
2021-05-06 11:52:02 -04:00
|
|
|
"github.com/minio/madmin-go"
|
2016-06-29 06:13:44 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestNewFS - tests initialization of all input disks
|
|
|
|
// and constructs a valid `FS` object layer.
|
|
|
|
func TestNewFS(t *testing.T) {
|
2022-10-14 06:08:40 -04:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2016-06-29 06:13:44 -04:00
|
|
|
// Do not attempt to create this path, the test validates
|
2018-02-20 15:21:12 -05:00
|
|
|
// so that NewFSObjectLayer initializes non existing paths
|
2016-06-29 06:13:44 -04:00
|
|
|
// and successfully returns initialized object layer.
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-06-29 06:13:44 -04:00
|
|
|
|
2022-10-14 06:08:40 -04:00
|
|
|
_, err := NewFSObjectLayer(ctx, "")
|
2016-10-05 15:48:07 -04:00
|
|
|
if err != errInvalidArgument {
|
|
|
|
t.Errorf("Expecting error invalid argument, got %s", err)
|
|
|
|
}
|
2022-10-14 06:08:40 -04:00
|
|
|
_, err = NewFSObjectLayer(ctx, disk)
|
2016-10-05 15:48:07 -04:00
|
|
|
if err != nil {
|
2022-08-04 19:10:08 -04:00
|
|
|
errMsg := "Unable to recognize backend format, Drive is not in FS format."
|
2016-10-05 15:48:07 -04:00
|
|
|
if err.Error() == errMsg {
|
|
|
|
t.Errorf("Expecting %s, got %s", errMsg, err)
|
2016-07-03 23:01:40 -04:00
|
|
|
}
|
2016-06-29 06:13:44 -04:00
|
|
|
}
|
|
|
|
}
|
2016-09-13 14:01:10 -04:00
|
|
|
|
2016-11-11 19:36:07 -05:00
|
|
|
// TestFSShutdown - initialize a new FS object layer then calls
|
|
|
|
// Shutdown to check returned results
|
2016-09-13 14:01:10 -04:00
|
|
|
func TestFSShutdown(t *testing.T) {
|
2022-05-30 13:58:37 -04:00
|
|
|
t.Skip()
|
|
|
|
|
2016-11-11 19:36:07 -05:00
|
|
|
bucketName := "testbucket"
|
|
|
|
objectName := "object"
|
2016-11-09 13:10:14 -05:00
|
|
|
// Create and return an fsObject with its path in the disk
|
2018-02-20 15:21:12 -05:00
|
|
|
prepareTest := func() (*FSObjects, string) {
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2016-11-09 13:10:14 -05:00
|
|
|
obj := initFSObjects(disk, t)
|
2018-02-20 15:21:12 -05:00
|
|
|
fs := obj.(*FSObjects)
|
2018-08-15 00:41:47 -04:00
|
|
|
|
2016-11-09 13:10:14 -05:00
|
|
|
objectContent := "12345"
|
2022-07-25 20:51:32 -04:00
|
|
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{})
|
2020-04-09 12:30:02 -04:00
|
|
|
obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
2016-11-09 13:10:14 -05:00
|
|
|
return fs, disk
|
|
|
|
}
|
2016-09-13 14:01:10 -04:00
|
|
|
|
2016-09-16 16:06:49 -04:00
|
|
|
// Test Shutdown with regular conditions
|
2016-11-09 13:10:14 -05:00
|
|
|
fs, disk := prepareTest()
|
2020-04-09 12:30:02 -04:00
|
|
|
if err := fs.Shutdown(GlobalContext); err != nil {
|
2016-09-13 14:01:10 -04:00
|
|
|
t.Fatal("Cannot shutdown the FS object: ", err)
|
|
|
|
}
|
2017-08-12 22:25:43 -04:00
|
|
|
os.RemoveAll(disk)
|
2016-09-13 14:01:10 -04:00
|
|
|
|
2016-11-09 13:10:14 -05:00
|
|
|
// Test Shutdown with faulty disk
|
2017-02-07 15:51:23 -05:00
|
|
|
fs, disk = prepareTest()
|
2020-06-12 23:04:01 -04:00
|
|
|
fs.DeleteObject(GlobalContext, bucketName, objectName, ObjectOptions{})
|
2017-08-12 22:25:43 -04:00
|
|
|
os.RemoveAll(disk)
|
2020-04-09 12:30:02 -04:00
|
|
|
if err := fs.Shutdown(GlobalContext); err != nil {
|
2017-02-07 15:51:23 -05:00
|
|
|
t.Fatal("Got unexpected fs shutdown error: ", err)
|
2016-12-01 16:59:06 -05:00
|
|
|
}
|
2016-09-16 16:06:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// TestFSGetBucketInfo - test GetBucketInfo with healty and faulty disks
|
|
|
|
func TestFSGetBucketInfo(t *testing.T) {
|
2022-05-30 13:58:37 -04:00
|
|
|
t.Skip()
|
|
|
|
|
2016-09-16 16:06:49 -04:00
|
|
|
// Prepare for testing
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2016-10-05 15:48:07 -04:00
|
|
|
obj := initFSObjects(disk, t)
|
2018-02-20 15:21:12 -05:00
|
|
|
fs := obj.(*FSObjects)
|
2016-09-16 16:06:49 -04:00
|
|
|
bucketName := "bucket"
|
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
err := obj.MakeBucketWithLocation(GlobalContext, "a", MakeBucketOptions{})
|
2018-04-23 23:27:33 -04:00
|
|
|
if !isSameType(err, BucketNameInvalid{}) {
|
|
|
|
t.Fatal("BucketNameInvalid error not returned")
|
|
|
|
}
|
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
err = obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{})
|
2018-04-23 23:27:33 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2016-09-16 16:06:49 -04:00
|
|
|
|
|
|
|
// Test with valid parameters
|
2022-07-25 20:51:32 -04:00
|
|
|
info, err := fs.GetBucketInfo(GlobalContext, bucketName, BucketOptions{})
|
2016-09-16 16:06:49 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if info.Name != bucketName {
|
|
|
|
t.Fatalf("wrong bucket name, expected: %s, found: %s", bucketName, info.Name)
|
|
|
|
}
|
|
|
|
|
2018-04-23 23:27:33 -04:00
|
|
|
// Test with non-existent bucket
|
2022-07-25 20:51:32 -04:00
|
|
|
_, err = fs.GetBucketInfo(GlobalContext, "a", BucketOptions{})
|
2018-04-23 23:27:33 -04:00
|
|
|
if !isSameType(err, BucketNotFound{}) {
|
|
|
|
t.Fatal("BucketNotFound error not returned")
|
2016-09-16 16:06:49 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Check for buckets and should get disk not found.
|
2018-06-04 21:35:41 -04:00
|
|
|
os.RemoveAll(disk)
|
2017-08-10 17:11:57 -04:00
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
if _, err = fs.GetBucketInfo(GlobalContext, bucketName, BucketOptions{}); err != nil {
|
2018-06-04 21:35:41 -04:00
|
|
|
if !isSameType(err, BucketNotFound{}) {
|
|
|
|
t.Fatal("BucketNotFound error not returned")
|
|
|
|
}
|
2016-09-16 16:06:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-09 20:46:46 -04:00
|
|
|
func TestFSPutObject(t *testing.T) {
|
|
|
|
// Prepare for tests
|
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2017-05-09 20:46:46 -04:00
|
|
|
|
|
|
|
obj := initFSObjects(disk, t)
|
|
|
|
bucketName := "bucket"
|
|
|
|
objectName := "1/2/3/4/object"
|
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{}); err != nil {
|
2017-05-09 20:46:46 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2017-05-25 12:22:43 -04:00
|
|
|
|
|
|
|
// With a regular object.
|
2020-04-09 12:30:02 -04:00
|
|
|
_, err := obj.PutObject(GlobalContext, bucketName+"non-existent", objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
2017-05-25 12:22:43 -04:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("Unexpected should fail here, bucket doesn't exist")
|
|
|
|
}
|
2018-04-10 12:36:37 -04:00
|
|
|
if _, ok := err.(BucketNotFound); !ok {
|
2017-05-25 12:22:43 -04:00
|
|
|
t.Fatalf("Expected error type BucketNotFound, got %#v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// With a directory object.
|
2020-04-09 12:30:02 -04:00
|
|
|
_, err = obj.PutObject(GlobalContext, bucketName+"non-existent", objectName+SlashSeparator, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), 0, "", ""), ObjectOptions{})
|
2017-05-25 12:22:43 -04:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("Unexpected should fail here, bucket doesn't exist")
|
|
|
|
}
|
2018-04-10 12:36:37 -04:00
|
|
|
if _, ok := err.(BucketNotFound); !ok {
|
2017-05-25 12:22:43 -04:00
|
|
|
t.Fatalf("Expected error type BucketNotFound, got %#v", err)
|
|
|
|
}
|
|
|
|
|
2020-04-09 12:30:02 -04:00
|
|
|
_, err = obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
2017-05-09 20:46:46 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-16 16:06:49 -04:00
|
|
|
// TestFSDeleteObject - test fs.DeleteObject() with healthy and corrupted disks
|
|
|
|
func TestFSDeleteObject(t *testing.T) {
|
2022-05-30 13:58:37 -04:00
|
|
|
t.Skip()
|
2016-09-16 16:06:49 -04:00
|
|
|
// Prepare for tests
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2016-10-05 15:48:07 -04:00
|
|
|
obj := initFSObjects(disk, t)
|
2018-02-20 15:21:12 -05:00
|
|
|
fs := obj.(*FSObjects)
|
2016-09-16 16:06:49 -04:00
|
|
|
bucketName := "bucket"
|
|
|
|
objectName := "object"
|
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{})
|
2020-04-09 12:30:02 -04:00
|
|
|
obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
2016-09-16 16:06:49 -04:00
|
|
|
|
|
|
|
// Test with invalid bucket name
|
2020-06-12 23:04:01 -04:00
|
|
|
if _, err := fs.DeleteObject(GlobalContext, "fo", objectName, ObjectOptions{}); !isSameType(err, BucketNameInvalid{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
// Test with bucket does not exist
|
2020-06-12 23:04:01 -04:00
|
|
|
if _, err := fs.DeleteObject(GlobalContext, "foobucket", "fooobject", ObjectOptions{}); !isSameType(err, BucketNotFound{}) {
|
2017-01-16 20:05:00 -05:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
2016-09-16 16:06:49 -04:00
|
|
|
// Test with invalid object name
|
2020-06-12 23:04:01 -04:00
|
|
|
if _, err := fs.DeleteObject(GlobalContext, bucketName, "\\", ObjectOptions{}); !(isSameType(err, ObjectNotFound{}) || isSameType(err, ObjectNameInvalid{})) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
// Test with object does not exist.
|
2020-06-12 23:04:01 -04:00
|
|
|
if _, err := fs.DeleteObject(GlobalContext, bucketName, "foooobject", ObjectOptions{}); !isSameType(err, ObjectNotFound{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
// Test with valid condition
|
2020-06-12 23:04:01 -04:00
|
|
|
if _, err := fs.DeleteObject(GlobalContext, bucketName, objectName, ObjectOptions{}); err != nil {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Delete object should err disk not found.
|
2018-06-04 21:35:41 -04:00
|
|
|
os.RemoveAll(disk)
|
2020-06-12 23:04:01 -04:00
|
|
|
if _, err := fs.DeleteObject(GlobalContext, bucketName, objectName, ObjectOptions{}); err != nil {
|
2018-04-10 12:36:37 -04:00
|
|
|
if !isSameType(err, BucketNotFound{}) {
|
2017-01-16 20:05:00 -05:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
2016-09-16 16:06:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestFSDeleteBucket - tests for fs DeleteBucket
|
|
|
|
func TestFSDeleteBucket(t *testing.T) {
|
2022-05-30 13:58:37 -04:00
|
|
|
t.Skip()
|
2016-09-16 16:06:49 -04:00
|
|
|
// Prepare for testing
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2016-10-05 15:48:07 -04:00
|
|
|
obj := initFSObjects(disk, t)
|
2018-02-20 15:21:12 -05:00
|
|
|
fs := obj.(*FSObjects)
|
2016-09-16 16:06:49 -04:00
|
|
|
bucketName := "bucket"
|
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
err := obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{})
|
2016-09-16 16:06:49 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test with an invalid bucket name
|
2021-10-06 13:24:40 -04:00
|
|
|
if err = fs.DeleteBucket(GlobalContext, "fo", DeleteBucketOptions{}); !isSameType(err, BucketNotFound{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
2018-04-23 23:27:33 -04:00
|
|
|
|
2016-09-16 16:06:49 -04:00
|
|
|
// Test with an inexistant bucket
|
2021-10-06 13:24:40 -04:00
|
|
|
if err = fs.DeleteBucket(GlobalContext, "foobucket", DeleteBucketOptions{}); !isSameType(err, BucketNotFound{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
// Test with a valid case
|
2021-10-06 13:24:40 -04:00
|
|
|
if err = fs.DeleteBucket(GlobalContext, bucketName, DeleteBucketOptions{}); err != nil {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
|
2022-07-25 20:51:32 -04:00
|
|
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{})
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2017-08-10 17:11:57 -04:00
|
|
|
// Delete bucket should get error disk not found.
|
2018-06-04 21:35:41 -04:00
|
|
|
os.RemoveAll(disk)
|
2021-10-06 13:24:40 -04:00
|
|
|
if err = fs.DeleteBucket(GlobalContext, bucketName, DeleteBucketOptions{}); err != nil {
|
2018-04-10 12:36:37 -04:00
|
|
|
if !isSameType(err, BucketNotFound{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestFSListBuckets - tests for fs ListBuckets
|
|
|
|
func TestFSListBuckets(t *testing.T) {
|
2022-05-30 13:58:37 -04:00
|
|
|
t.Skip()
|
2016-09-16 16:06:49 -04:00
|
|
|
// Prepare for tests
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2016-10-05 15:48:07 -04:00
|
|
|
obj := initFSObjects(disk, t)
|
2018-02-20 15:21:12 -05:00
|
|
|
fs := obj.(*FSObjects)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
|
|
|
bucketName := "bucket"
|
2022-07-25 20:51:32 -04:00
|
|
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, MakeBucketOptions{}); err != nil {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a bucket with invalid name
|
2022-01-02 12:15:06 -05:00
|
|
|
if err := os.MkdirAll(pathJoin(fs.fsPath, "vo^"), 0o777); err != nil {
|
2017-01-16 20:05:00 -05:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
f, err := os.Create(pathJoin(fs.fsPath, "test"))
|
|
|
|
if err != nil {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
f.Close()
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Test list buckets to have only one entry.
|
2022-07-25 20:51:32 -04:00
|
|
|
buckets, err := fs.ListBuckets(GlobalContext, BucketOptions{})
|
2016-09-16 16:06:49 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
if len(buckets) != 1 {
|
2017-01-16 20:05:00 -05:00
|
|
|
t.Fatal("ListBuckets not working properly", buckets)
|
2016-09-16 16:06:49 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Test ListBuckets with disk not found.
|
2018-06-04 21:35:41 -04:00
|
|
|
os.RemoveAll(disk)
|
2022-07-25 20:51:32 -04:00
|
|
|
if _, err := fs.ListBuckets(GlobalContext, BucketOptions{}); err != nil {
|
2018-04-10 12:36:37 -04:00
|
|
|
if err != errDiskNotFound {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatal("Unexpected error: ", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestFSHealObject - tests for fs HealObject
|
|
|
|
func TestFSHealObject(t *testing.T) {
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2016-10-05 15:48:07 -04:00
|
|
|
obj := initFSObjects(disk, t)
|
2020-06-12 23:04:01 -04:00
|
|
|
_, err := obj.HealObject(GlobalContext, "bucket", "object", "", madmin.HealOpts{})
|
2018-04-10 12:36:37 -04:00
|
|
|
if err == nil || !isSameType(err, NotImplemented{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatalf("Heal Object should return NotImplemented error ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-13 20:35:09 -04:00
|
|
|
// TestFSHealObjects - tests for fs HealObjects to return not implemented.
|
|
|
|
func TestFSHealObjects(t *testing.T) {
|
2016-12-16 01:25:05 -05:00
|
|
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
2017-08-12 22:25:43 -04:00
|
|
|
defer os.RemoveAll(disk)
|
2016-09-16 16:06:49 -04:00
|
|
|
|
2016-10-05 15:48:07 -04:00
|
|
|
obj := initFSObjects(disk, t)
|
2020-04-09 12:30:02 -04:00
|
|
|
err := obj.HealObjects(GlobalContext, "bucket", "prefix", madmin.HealOpts{}, nil)
|
2018-04-10 12:36:37 -04:00
|
|
|
if err == nil || !isSameType(err, NotImplemented{}) {
|
2016-09-16 16:06:49 -04:00
|
|
|
t.Fatalf("Heal Object should return NotImplemented error ")
|
|
|
|
}
|
2016-09-13 14:01:10 -04:00
|
|
|
}
|