|
|
|
@ -31,6 +31,53 @@ import ( |
|
|
|
|
"github.com/minio/minio-go" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// Tests bucket re-create errors.
|
|
|
|
|
func TestMakeBucketErrorV2(t *testing.T) { |
|
|
|
|
if testing.Short() { |
|
|
|
|
t.Skip("skipping functional tests for short runs") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
|
false, |
|
|
|
|
) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatal("Error:", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Enable tracing, write to stderr.
|
|
|
|
|
// c.TraceOn(os.Stderr)
|
|
|
|
|
|
|
|
|
|
// Set user agent.
|
|
|
|
|
c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0") |
|
|
|
|
|
|
|
|
|
// Generate a new random bucket name.
|
|
|
|
|
bucketName := randString(60, rand.NewSource(time.Now().UnixNano())) |
|
|
|
|
|
|
|
|
|
// Make a new bucket in 'eu-west-1'.
|
|
|
|
|
if err = c.MakeBucket(bucketName, "private", "eu-west-1"); err != nil { |
|
|
|
|
t.Fatal("Error:", err, bucketName) |
|
|
|
|
} |
|
|
|
|
if err = c.MakeBucket(bucketName, "private", "eu-west-1"); err == nil { |
|
|
|
|
t.Fatal("Error: make bucket should should fail for", bucketName) |
|
|
|
|
} |
|
|
|
|
// Verify valid error response from server.
|
|
|
|
|
if minio.ToErrorResponse(err).Code != "BucketAlreadyExists" && |
|
|
|
|
minio.ToErrorResponse(err).Code != "BucketAlreadyOwnedByYou" { |
|
|
|
|
t.Fatal("Error: Invalid error returned by server", err) |
|
|
|
|
} |
|
|
|
|
if err = c.RemoveBucket(bucketName); err != nil { |
|
|
|
|
t.Fatal("Error:", err, bucketName) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Test get object reader to not throw error on being closed twice.
|
|
|
|
|
func TestGetObjectClosedTwiceV2(t *testing.T) { |
|
|
|
|
if testing.Short() { |
|
|
|
|
t.Skip("skipping functional tests for short runs") |
|
|
|
@ -39,8 +86,8 @@ func TestGetObjectClosedTwiceV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
@ -124,7 +171,7 @@ func TestRemovePartiallyUploadedV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
@ -191,8 +238,8 @@ func TestResumbalePutObjectV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
@ -302,8 +349,8 @@ func TestResumableFPutObjectV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
@ -370,6 +417,57 @@ func TestResumableFPutObjectV2(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests various bucket supported formats.
|
|
|
|
|
func TestMakeBucketRegionsV2(t *testing.T) { |
|
|
|
|
if testing.Short() { |
|
|
|
|
t.Skip("skipping functional tests for short runs") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
|
false, |
|
|
|
|
) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatal("Error:", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Enable tracing, write to stderr.
|
|
|
|
|
// c.TraceOn(os.Stderr)
|
|
|
|
|
|
|
|
|
|
// Set user agent.
|
|
|
|
|
c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0") |
|
|
|
|
|
|
|
|
|
// Generate a new random bucket name.
|
|
|
|
|
bucketName := randString(60, rand.NewSource(time.Now().UnixNano())) |
|
|
|
|
|
|
|
|
|
// Make a new bucket in 'eu-central-1'.
|
|
|
|
|
if err = c.MakeBucket(bucketName, "private", "eu-west-1"); err != nil { |
|
|
|
|
t.Fatal("Error:", err, bucketName) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err = c.RemoveBucket(bucketName); err != nil { |
|
|
|
|
t.Fatal("Error:", err, bucketName) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Make a new bucket with '.' in its name, in 'us-west-2'. This
|
|
|
|
|
// request is internally staged into a path style instead of
|
|
|
|
|
// virtual host style.
|
|
|
|
|
if err = c.MakeBucket(bucketName+".withperiod", "private", "us-west-2"); err != nil { |
|
|
|
|
t.Fatal("Error:", err, bucketName+".withperiod") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Remove the newly created bucket.
|
|
|
|
|
if err = c.RemoveBucket(bucketName + ".withperiod"); err != nil { |
|
|
|
|
t.Fatal("Error:", err, bucketName+".withperiod") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests resumable put object multipart upload.
|
|
|
|
|
func TestResumablePutObjectV2(t *testing.T) { |
|
|
|
|
if testing.Short() { |
|
|
|
@ -379,8 +477,8 @@ func TestResumablePutObjectV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
@ -443,8 +541,8 @@ func TestGetObjectReadSeekFunctionalV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
@ -557,8 +655,8 @@ func TestGetObjectReadAtFunctionalV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
// Connect and make sure bucket exists.
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
// Instantiate new minio client object.
|
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
@ -699,7 +797,7 @@ func TestFunctionalV2(t *testing.T) { |
|
|
|
|
// Seed random based on current time.
|
|
|
|
|
rand.Seed(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
c, err := minio.New( |
|
|
|
|
c, err := minio.NewV2( |
|
|
|
|
"s3.amazonaws.com", |
|
|
|
|
os.Getenv("ACCESS_KEY"), |
|
|
|
|
os.Getenv("SECRET_KEY"), |
|
|
|
|