@ -18,7 +18,6 @@ package cmd
import (
import (
"bytes"
"bytes"
"context"
"io/ioutil"
"io/ioutil"
"math/rand"
"math/rand"
"os"
"os"
@ -46,23 +45,23 @@ func TestRepeatPutObjectPart(t *testing.T) {
// cleaning up of temporary test directories
// cleaning up of temporary test directories
defer removeRoots ( disks )
defer removeRoots ( disks )
err = objLayer . MakeBucketWithLocation ( context . Background ( ) , "bucket1" , "" )
err = objLayer . MakeBucketWithLocation ( GlobalContext , "bucket1" , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
uploadID , err := objLayer . NewMultipartUpload ( context . Background ( ) , "bucket1" , "mpartObj1" , opts )
uploadID , err := objLayer . NewMultipartUpload ( GlobalContext , "bucket1" , "mpartObj1" , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
fiveMBBytes := bytes . Repeat ( [ ] byte ( "a" ) , 5 * humanize . MiByte )
fiveMBBytes := bytes . Repeat ( [ ] byte ( "a" ) , 5 * humanize . MiByte )
md5Hex := getMD5Hash ( fiveMBBytes )
md5Hex := getMD5Hash ( fiveMBBytes )
_ , err = objLayer . PutObjectPart ( context . Background ( ) , "bucket1" , "mpartObj1" , uploadID , 1 , mustGetPutObjReader ( t , bytes . NewReader ( fiveMBBytes ) , 5 * humanize . MiByte , md5Hex , "" ) , opts )
_ , err = objLayer . PutObjectPart ( GlobalContext , "bucket1" , "mpartObj1" , uploadID , 1 , mustGetPutObjReader ( t , bytes . NewReader ( fiveMBBytes ) , 5 * humanize . MiByte , md5Hex , "" ) , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
// PutObjectPart should succeed even if part already exists. ref: https://github.com/minio/minio/issues/1930
// PutObjectPart should succeed even if part already exists. ref: https://github.com/minio/minio/issues/1930
_ , err = objLayer . PutObjectPart ( context . Background ( ) , "bucket1" , "mpartObj1" , uploadID , 1 , mustGetPutObjReader ( t , bytes . NewReader ( fiveMBBytes ) , 5 * humanize . MiByte , md5Hex , "" ) , opts )
_ , err = objLayer . PutObjectPart ( GlobalContext , "bucket1" , "mpartObj1" , uploadID , 1 , mustGetPutObjReader ( t , bytes . NewReader ( fiveMBBytes ) , 5 * humanize . MiByte , md5Hex , "" ) , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -90,18 +89,18 @@ func TestXLDeleteObjectBasic(t *testing.T) {
t . Fatal ( err )
t . Fatal ( err )
}
}
err = xl . MakeBucketWithLocation ( context . Background ( ) , "bucket" , "" )
err = xl . MakeBucketWithLocation ( GlobalContext , "bucket" , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
// Create object "dir/obj" under bucket "bucket" for Test 7 to pass
// Create object "dir/obj" under bucket "bucket" for Test 7 to pass
_ , err = xl . PutObject ( context . Background ( ) , "bucket" , "dir/obj" , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , ObjectOptions { } )
_ , err = xl . PutObject ( GlobalContext , "bucket" , "dir/obj" , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , ObjectOptions { } )
if err != nil {
if err != nil {
t . Fatalf ( "XL Object upload failed: <ERROR> %s" , err )
t . Fatalf ( "XL Object upload failed: <ERROR> %s" , err )
}
}
for i , test := range testCases {
for i , test := range testCases {
actualErr := xl . DeleteObject ( context . Background ( ) , test . bucket , test . object )
actualErr := xl . DeleteObject ( GlobalContext , test . bucket , test . object )
if test . expectedErr != nil && actualErr != test . expectedErr {
if test . expectedErr != nil && actualErr != test . expectedErr {
t . Errorf ( "Test %d: Expected to fail with %s, but failed with %s" , i + 1 , test . expectedErr , actualErr )
t . Errorf ( "Test %d: Expected to fail with %s, but failed with %s" , i + 1 , test . expectedErr , actualErr )
}
}
@ -145,13 +144,13 @@ func TestXLDeleteObjectsXLSet(t *testing.T) {
{ bucketName , "obj_4" } ,
{ bucketName , "obj_4" } ,
}
}
err := xlSets . MakeBucketWithLocation ( context . Background ( ) , bucketName , "" )
err := xlSets . MakeBucketWithLocation ( GlobalContext , bucketName , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
for _ , testCase := range testCases {
for _ , testCase := range testCases {
_ , err = xlSets . PutObject ( context . Background ( ) , testCase . bucket , testCase . object ,
_ , err = xlSets . PutObject ( GlobalContext , testCase . bucket , testCase . object ,
mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , ObjectOptions { } )
mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , ObjectOptions { } )
if err != nil {
if err != nil {
t . Fatalf ( "XL Object upload failed: <ERROR> %s" , err )
t . Fatalf ( "XL Object upload failed: <ERROR> %s" , err )
@ -167,7 +166,7 @@ func TestXLDeleteObjectsXLSet(t *testing.T) {
}
}
objectNames := toObjectNames ( testCases )
objectNames := toObjectNames ( testCases )
delErrs , err := xlSets . DeleteObjects ( context . Background ( ) , bucketName , objectNames )
delErrs , err := xlSets . DeleteObjects ( GlobalContext , bucketName , objectNames )
if err != nil {
if err != nil {
t . Errorf ( "Failed to call DeleteObjects with the error: `%v`" , err )
t . Errorf ( "Failed to call DeleteObjects with the error: `%v`" , err )
}
}
@ -179,7 +178,7 @@ func TestXLDeleteObjectsXLSet(t *testing.T) {
}
}
for _ , test := range testCases {
for _ , test := range testCases {
_ , statErr := xlSets . GetObjectInfo ( context . Background ( ) , test . bucket , test . object , ObjectOptions { } )
_ , statErr := xlSets . GetObjectInfo ( GlobalContext , test . bucket , test . object , ObjectOptions { } )
switch statErr . ( type ) {
switch statErr . ( type ) {
case ObjectNotFound :
case ObjectNotFound :
default :
default :
@ -201,7 +200,7 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
xl := z . zones [ 0 ] . sets [ 0 ]
xl := z . zones [ 0 ] . sets [ 0 ]
// Create "bucket"
// Create "bucket"
err = obj . MakeBucketWithLocation ( context . Background ( ) , "bucket" , "" )
err = obj . MakeBucketWithLocation ( GlobalContext , "bucket" , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -210,7 +209,7 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
object := "object"
object := "object"
opts := ObjectOptions { }
opts := ObjectOptions { }
// Create object "obj" under bucket "bucket".
// Create object "obj" under bucket "bucket".
_ , err = obj . PutObject ( context . Background ( ) , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
_ , err = obj . PutObject ( GlobalContext , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -225,13 +224,13 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
return xlDisks
return xlDisks
}
}
z . zones [ 0 ] . xlDisksMu . Unlock ( )
z . zones [ 0 ] . xlDisksMu . Unlock ( )
err = obj . DeleteObject ( context . Background ( ) , bucket , object )
err = obj . DeleteObject ( GlobalContext , bucket , object )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
// Create "obj" under "bucket".
// Create "obj" under "bucket".
_ , err = obj . PutObject ( context . Background ( ) , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
_ , err = obj . PutObject ( GlobalContext , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -245,7 +244,7 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
return xlDisks
return xlDisks
}
}
z . zones [ 0 ] . xlDisksMu . Unlock ( )
z . zones [ 0 ] . xlDisksMu . Unlock ( )
err = obj . DeleteObject ( context . Background ( ) , bucket , object )
err = obj . DeleteObject ( GlobalContext , bucket , object )
// since majority of disks are not available, metaquorum is not achieved and hence errXLReadQuorum error
// since majority of disks are not available, metaquorum is not achieved and hence errXLReadQuorum error
if err != toObjectErr ( errXLReadQuorum , bucket , object ) {
if err != toObjectErr ( errXLReadQuorum , bucket , object ) {
t . Errorf ( "Expected deleteObject to fail with %v, but failed with %v" , toObjectErr ( errXLReadQuorum , bucket , object ) , err )
t . Errorf ( "Expected deleteObject to fail with %v, but failed with %v" , toObjectErr ( errXLReadQuorum , bucket , object ) , err )
@ -265,7 +264,7 @@ func TestGetObjectNoQuorum(t *testing.T) {
xl := z . zones [ 0 ] . sets [ 0 ]
xl := z . zones [ 0 ] . sets [ 0 ]
// Create "bucket"
// Create "bucket"
err = obj . MakeBucketWithLocation ( context . Background ( ) , "bucket" , "" )
err = obj . MakeBucketWithLocation ( GlobalContext , "bucket" , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -274,7 +273,7 @@ func TestGetObjectNoQuorum(t *testing.T) {
object := "object"
object := "object"
opts := ObjectOptions { }
opts := ObjectOptions { }
// Create "object" under "bucket".
// Create "object" under "bucket".
_ , err = obj . PutObject ( context . Background ( ) , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
_ , err = obj . PutObject ( GlobalContext , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -303,7 +302,7 @@ func TestGetObjectNoQuorum(t *testing.T) {
}
}
z . zones [ 0 ] . xlDisksMu . Unlock ( )
z . zones [ 0 ] . xlDisksMu . Unlock ( )
// Fetch object from store.
// Fetch object from store.
err = xl . GetObject ( context . Background ( ) , bucket , object , 0 , int64 ( len ( "abcd" ) ) , ioutil . Discard , "" , opts )
err = xl . GetObject ( GlobalContext , bucket , object , 0 , int64 ( len ( "abcd" ) ) , ioutil . Discard , "" , opts )
if err != toObjectErr ( errXLReadQuorum , bucket , object ) {
if err != toObjectErr ( errXLReadQuorum , bucket , object ) {
t . Errorf ( "Expected putObject to fail with %v, but failed with %v" , toObjectErr ( errXLWriteQuorum , bucket , object ) , err )
t . Errorf ( "Expected putObject to fail with %v, but failed with %v" , toObjectErr ( errXLWriteQuorum , bucket , object ) , err )
}
}
@ -324,7 +323,7 @@ func TestPutObjectNoQuorum(t *testing.T) {
xl := z . zones [ 0 ] . sets [ 0 ]
xl := z . zones [ 0 ] . sets [ 0 ]
// Create "bucket"
// Create "bucket"
err = obj . MakeBucketWithLocation ( context . Background ( ) , "bucket" , "" )
err = obj . MakeBucketWithLocation ( GlobalContext , "bucket" , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -333,7 +332,7 @@ func TestPutObjectNoQuorum(t *testing.T) {
object := "object"
object := "object"
opts := ObjectOptions { }
opts := ObjectOptions { }
// Create "object" under "bucket".
// Create "object" under "bucket".
_ , err = obj . PutObject ( context . Background ( ) , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
_ , err = obj . PutObject ( GlobalContext , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -362,7 +361,7 @@ func TestPutObjectNoQuorum(t *testing.T) {
}
}
z . zones [ 0 ] . xlDisksMu . Unlock ( )
z . zones [ 0 ] . xlDisksMu . Unlock ( )
// Upload new content to same object "object"
// Upload new content to same object "object"
_ , err = obj . PutObject ( context . Background ( ) , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
_ , err = obj . PutObject ( GlobalContext , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( [ ] byte ( "abcd" ) ) , int64 ( len ( "abcd" ) ) , "" , "" ) , opts )
if err != toObjectErr ( errXLWriteQuorum , bucket , object ) {
if err != toObjectErr ( errXLWriteQuorum , bucket , object ) {
t . Errorf ( "Expected putObject to fail with %v, but failed with %v" , toObjectErr ( errXLWriteQuorum , bucket , object ) , err )
t . Errorf ( "Expected putObject to fail with %v, but failed with %v" , toObjectErr ( errXLWriteQuorum , bucket , object ) , err )
}
}
@ -381,7 +380,7 @@ func TestHealing(t *testing.T) {
xl := z . zones [ 0 ] . sets [ 0 ]
xl := z . zones [ 0 ] . sets [ 0 ]
// Create "bucket"
// Create "bucket"
err = obj . MakeBucketWithLocation ( context . Background ( ) , "bucket" , "" )
err = obj . MakeBucketWithLocation ( GlobalContext , "bucket" , "" )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -396,13 +395,13 @@ func TestHealing(t *testing.T) {
t . Fatal ( err )
t . Fatal ( err )
}
}
_ , err = obj . PutObject ( context . Background ( ) , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( data ) , length , "" , "" ) , ObjectOptions { } )
_ , err = obj . PutObject ( GlobalContext , bucket , object , mustGetPutObjReader ( t , bytes . NewReader ( data ) , length , "" , "" ) , ObjectOptions { } )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
disk := xl . getDisks ( ) [ 0 ]
disk := xl . getDisks ( ) [ 0 ]
xlMetaPreHeal , err := readXLMeta ( context . Background ( ) , disk , bucket , object )
xlMetaPreHeal , err := readXLMeta ( GlobalContext , disk , bucket , object )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -414,12 +413,12 @@ func TestHealing(t *testing.T) {
t . Fatal ( err )
t . Fatal ( err )
}
}
_ , err = xl . HealObject ( context . Background ( ) , bucket , object , madmin . HealOpts { ScanMode : madmin . HealNormalScan } )
_ , err = xl . HealObject ( GlobalContext , bucket , object , madmin . HealOpts { ScanMode : madmin . HealNormalScan } )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
xlMetaPostHeal , err := readXLMeta ( context . Background ( ) , disk , bucket , object )
xlMetaPostHeal , err := readXLMeta ( GlobalContext , disk , bucket , object )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -438,17 +437,17 @@ func TestHealing(t *testing.T) {
// gone down when an object was replaced by a new object.
// gone down when an object was replaced by a new object.
xlMetaOutDated := xlMetaPreHeal
xlMetaOutDated := xlMetaPreHeal
xlMetaOutDated . Stat . ModTime = time . Now ( )
xlMetaOutDated . Stat . ModTime = time . Now ( )
err = writeXLMetadata ( context . Background ( ) , disk , bucket , object , xlMetaOutDated )
err = writeXLMetadata ( GlobalContext , disk , bucket , object , xlMetaOutDated )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
_ , err = xl . HealObject ( context . Background ( ) , bucket , object , madmin . HealOpts { ScanMode : madmin . HealDeepScan } )
_ , err = xl . HealObject ( GlobalContext , bucket , object , madmin . HealOpts { ScanMode : madmin . HealDeepScan } )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
xlMetaPostHeal , err = readXLMeta ( context . Background ( ) , disk , bucket , object )
xlMetaPostHeal , err = readXLMeta ( GlobalContext , disk , bucket , object )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -465,7 +464,7 @@ func TestHealing(t *testing.T) {
t . Fatal ( err )
t . Fatal ( err )
}
}
// This would create the bucket.
// This would create the bucket.
_ , err = xl . HealBucket ( context . Background ( ) , bucket , false , false )
_ , err = xl . HealBucket ( GlobalContext , bucket , false , false )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
@ -492,41 +491,41 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
xl := z . zones [ 0 ] . sets [ 0 ]
xl := z . zones [ 0 ] . sets [ 0 ]
xlDisks := xl . getDisks ( )
xlDisks := xl . getDisks ( )
err := obj . MakeBucketWithLocation ( context . Background ( ) , bucket , globalMinioDefaultRegion )
err := obj . MakeBucketWithLocation ( GlobalContext , bucket , globalMinioDefaultRegion )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to make a bucket %v" , err )
t . Fatalf ( "Failed to make a bucket %v" , err )
}
}
// Object for test case 1 - No StorageClass defined, no MetaData in PutObject
// Object for test case 1 - No StorageClass defined, no MetaData in PutObject
object1 := "object1"
object1 := "object1"
_ , err = obj . PutObject ( context . Background ( ) , bucket , object1 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , opts )
_ , err = obj . PutObject ( GlobalContext , bucket , object1 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , opts )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts1 , errs1 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object1 )
parts1 , errs1 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object1 )
// Object for test case 2 - No StorageClass defined, MetaData in PutObject requesting RRS Class
// Object for test case 2 - No StorageClass defined, MetaData in PutObject requesting RRS Class
object2 := "object2"
object2 := "object2"
metadata2 := make ( map [ string ] string )
metadata2 := make ( map [ string ] string )
metadata2 [ "x-amz-storage-class" ] = storageclass . RRS
metadata2 [ "x-amz-storage-class" ] = storageclass . RRS
_ , err = obj . PutObject ( context . Background ( ) , bucket , object2 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata2 } )
_ , err = obj . PutObject ( GlobalContext , bucket , object2 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata2 } )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts2 , errs2 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object2 )
parts2 , errs2 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object2 )
// Object for test case 3 - No StorageClass defined, MetaData in PutObject requesting Standard Storage Class
// Object for test case 3 - No StorageClass defined, MetaData in PutObject requesting Standard Storage Class
object3 := "object3"
object3 := "object3"
metadata3 := make ( map [ string ] string )
metadata3 := make ( map [ string ] string )
metadata3 [ "x-amz-storage-class" ] = storageclass . STANDARD
metadata3 [ "x-amz-storage-class" ] = storageclass . STANDARD
_ , err = obj . PutObject ( context . Background ( ) , bucket , object3 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata3 } )
_ , err = obj . PutObject ( GlobalContext , bucket , object3 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata3 } )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts3 , errs3 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object3 )
parts3 , errs3 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object3 )
// Object for test case 4 - Standard StorageClass defined as Parity 6, MetaData in PutObject requesting Standard Storage Class
// Object for test case 4 - Standard StorageClass defined as Parity 6, MetaData in PutObject requesting Standard Storage Class
object4 := "object4"
object4 := "object4"
@ -538,12 +537,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
} ,
} ,
}
}
_ , err = obj . PutObject ( context . Background ( ) , bucket , object4 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata4 } )
_ , err = obj . PutObject ( GlobalContext , bucket , object4 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata4 } )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts4 , errs4 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object4 )
parts4 , errs4 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object4 )
// Object for test case 5 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting RRS Class
// Object for test case 5 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting RRS Class
// Reset global storage class flags
// Reset global storage class flags
@ -556,12 +555,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
} ,
} ,
}
}
_ , err = obj . PutObject ( context . Background ( ) , bucket , object5 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata5 } )
_ , err = obj . PutObject ( GlobalContext , bucket , object5 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata5 } )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts5 , errs5 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object5 )
parts5 , errs5 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object5 )
// Object for test case 6 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting Standard Storage Class
// Object for test case 6 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting Standard Storage Class
object6 := "object6"
object6 := "object6"
@ -573,12 +572,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
} ,
} ,
}
}
_ , err = obj . PutObject ( context . Background ( ) , bucket , object6 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata6 } )
_ , err = obj . PutObject ( GlobalContext , bucket , object6 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata6 } )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts6 , errs6 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object6 )
parts6 , errs6 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object6 )
// Object for test case 7 - Standard StorageClass defined as Parity 5, MetaData in PutObject requesting RRS Class
// Object for test case 7 - Standard StorageClass defined as Parity 5, MetaData in PutObject requesting RRS Class
// Reset global storage class flags
// Reset global storage class flags
@ -591,12 +590,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
} ,
} ,
}
}
_ , err = obj . PutObject ( context . Background ( ) , bucket , object7 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata7 } )
_ , err = obj . PutObject ( GlobalContext , bucket , object7 , mustGetPutObjReader ( t , bytes . NewReader ( data ) , int64 ( len ( data ) ) , "" , "" ) , ObjectOptions { UserDefined : metadata7 } )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to putObject %v" , err )
t . Fatalf ( "Failed to putObject %v" , err )
}
}
parts7 , errs7 := readAllXLMetadata ( context . Background ( ) , xlDisks , bucket , object7 )
parts7 , errs7 := readAllXLMetadata ( GlobalContext , xlDisks , bucket , object7 )
tests := [ ] struct {
tests := [ ] struct {
parts [ ] xlMetaV1
parts [ ] xlMetaV1
@ -614,7 +613,7 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
{ parts7 , errs7 , 14 , 15 , nil } ,
{ parts7 , errs7 , 14 , 15 , nil } ,
}
}
for i , tt := range tests {
for i , tt := range tests {
actualReadQuorum , actualWriteQuorum , err := objectQuorumFromMeta ( context . Background ( ) , * xl , tt . parts , tt . errs )
actualReadQuorum , actualWriteQuorum , err := objectQuorumFromMeta ( GlobalContext , * xl , tt . parts , tt . errs )
if tt . expectedError != nil && err == nil {
if tt . expectedError != nil && err == nil {
t . Errorf ( "Test %d, Expected %s, got %s" , i + 1 , tt . expectedError , err )
t . Errorf ( "Test %d, Expected %s, got %s" , i + 1 , tt . expectedError , err )
return
return