2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ *  
						 
					
						
							
								
									
										
										
											
												objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
											 
										 
										
											2016-04-03 16:34:20 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 *  Minio  Cloud  Storage ,  ( C )  2015 ,  2016  Minio ,  Inc . 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Licensed  under  the  Apache  License ,  Version  2.0  ( the  "License" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  you  may  not  use  this  file  except  in  compliance  with  the  License . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  You  may  obtain  a  copy  of  the  License  at 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *      http : //www.apache.org/licenses/LICENSE-2.0
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Unless  required  by  applicable  law  or  agreed  to  in  writing ,  software 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  distributed  under  the  License  is  distributed  on  an  "AS IS"  BASIS , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  WITHOUT  WARRANTIES  OR  CONDITIONS  OF  ANY  KIND ,  either  express  or  implied . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  See  the  License  for  the  specific  language  governing  permissions  and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  limitations  under  the  License . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-19 07:23:42 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  cmd  
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"bytes" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"crypto/md5" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"encoding/hex" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"io" 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"math/rand" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"strconv" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									.  "gopkg.in/check.v1" 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Return pointer to testOneByteReadEOF{}
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  newTestReaderEOF ( data  [ ] byte )  io . Reader  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  & testOneByteReadEOF { false ,  data } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// OneByteReadEOF - implements io.Reader which returns 1 byte along with io.EOF error.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  testOneByteReadEOF  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									eof   bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									data  [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( r  * testOneByteReadEOF )  Read ( p  [ ] byte )  ( n  int ,  err  error )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  r . eof  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  0 ,  io . EOF 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									n  =  copy ( p ,  r . data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . eof  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  n ,  io . EOF 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Return pointer to testOneByteReadNoEOF{}
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  newTestReaderNoEOF ( data  [ ] byte )  io . Reader  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  & testOneByteReadNoEOF { false ,  data } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// testOneByteReadNoEOF - implements io.Reader which returns 1 byte and nil error, but
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// returns io.EOF on the next Read().
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  testOneByteReadNoEOF  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									eof   bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									data  [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( r  * testOneByteReadNoEOF )  Read ( p  [ ] byte )  ( n  int ,  err  error )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  r . eof  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  0 ,  io . EOF 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									n  =  copy ( p ,  r . data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . eof  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  n ,  nil 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								type  ObjectLayerAPISuite  struct { }  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var  _  =  Suite ( & ObjectLayerAPISuite { } )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testMakeBucket for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestMakeBucket ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testMakeBucket ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate bucket creation.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testMakeBucket ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-23 07:19:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket-unknown" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testMultipartObjectCreation for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestMultipartObjectCreation ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testMultipartObjectCreation ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate creation of part files during Multipart operation.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testMultipartObjectCreation ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-19 10:54:25 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									uploadID ,  err  :=  obj . NewMultipartUpload ( "bucket" ,  "key" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-09 03:06:05 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Create a byte array of 5MB.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									data  :=  bytes . Repeat ( [ ] byte ( "0123456789abcdef" ) ,  5 * 1024 * 1024 / 16 ) 
							 
						 
					
						
							
								
									
										
										
											
												objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
											 
										 
										
											2016-04-03 16:34:20 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									completedParts  :=  completeMultipartUpload { } 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  i  :=  1 ;  i  <=  10 ;  i ++  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										hasher  :=  md5 . New ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-09 03:06:05 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										hasher . Write ( data ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-13 08:08:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										expectedMD5Sumhex  :=  hex . EncodeToString ( hasher . Sum ( nil ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-13 08:08:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										var  calculatedMD5sum  string 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										calculatedMD5sum ,  err  =  obj . PutObjectPart ( "bucket" ,  "key" ,  uploadID ,  i ,  int64 ( len ( data ) ) ,  bytes . NewBuffer ( data ) ,  expectedMD5Sumhex ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  calculatedMD5sum  !=  expectedMD5Sumhex  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "MD5 Mismatch" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
											
												objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
											 
										 
										
											2016-04-03 16:34:20 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										completedParts . Parts  =  append ( completedParts . Parts ,  completePart { PartNumber :  i ,  ETag :  calculatedMD5sum } ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-17 03:48:41 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									md5Sum ,  err  :=  obj . CompleteMultipartUpload ( "bucket" ,  "key" ,  uploadID ,  completedParts . Parts ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  md5Sum  !=  "7d364cb728ce42a74a96d22949beefb2-10"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "Md5 mismtch" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testMultipartObjectAbort for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestMultipartObjectAbort ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testMultipartObjectAbort ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate abortion of Multipart operation.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testMultipartObjectAbort ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-19 10:54:25 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									uploadID ,  err  :=  obj . NewMultipartUpload ( "bucket" ,  "key" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									parts  :=  make ( map [ int ] string ) 
							 
						 
					
						
							
								
									
										
										
											
												objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
											 
										 
										
											2016-04-03 16:34:20 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									metadata  :=  make ( map [ string ] string ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  i  :=  1 ;  i  <=  10 ;  i ++  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										randomPerm  :=  rand . Perm ( 10 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										randomString  :=  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  num  :=  range  randomPerm  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											randomString  =  randomString  +  strconv . Itoa ( num ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										hasher  :=  md5 . New ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										hasher . Write ( [ ] byte ( randomString ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-13 08:08:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										expectedMD5Sumhex  :=  hex . EncodeToString ( hasher . Sum ( nil ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
											
												objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
											 
										 
										
											2016-04-03 16:34:20 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										metadata [ "md5" ]  =  expectedMD5Sumhex 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-13 08:08:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										var  calculatedMD5sum  string 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										calculatedMD5sum ,  err  =  obj . PutObjectPart ( "bucket" ,  "key" ,  uploadID ,  i ,  int64 ( len ( randomString ) ) ,  bytes . NewBufferString ( randomString ) ,  expectedMD5Sumhex ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  calculatedMD5sum  !=  expectedMD5Sumhex  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "Md5 Mismatch" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-13 08:08:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										parts [ i ]  =  expectedMD5Sumhex 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . AbortMultipartUpload ( "bucket" ,  "key" ,  uploadID ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testMultipleObjectCreation for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestMultipleObjectCreation ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testMultipleObjectCreation ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate object creation.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testMultipleObjectCreation ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									objects  :=  make ( map [ string ] [ ] byte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  i  :=  0 ;  i  <  10 ;  i ++  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-23 09:16:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										randomPerm  :=  rand . Perm ( 100 ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										randomString  :=  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  num  :=  range  randomPerm  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											randomString  =  randomString  +  strconv . Itoa ( num ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										hasher  :=  md5 . New ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										hasher . Write ( [ ] byte ( randomString ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-13 08:08:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										expectedMD5Sumhex  :=  hex . EncodeToString ( hasher . Sum ( nil ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										key  :=  "obj"  +  strconv . Itoa ( i ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objects [ key ]  =  [ ] byte ( randomString ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												fs: Break fs package to top-level and introduce ObjectAPI interface.
ObjectAPI interface brings in changes needed for XL ObjectAPI layer.
The new interface for any ObjectAPI layer is as below
```
// ObjectAPI interface.
type ObjectAPI interface {
        // Bucket resource API.
        DeleteBucket(bucket string) *probe.Error
        ListBuckets() ([]BucketInfo, *probe.Error)
        MakeBucket(bucket string) *probe.Error
        GetBucketInfo(bucket string) (BucketInfo, *probe.Error)
        // Bucket query API.
        ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsResult, *probe.Error)
        ListMultipartUploads(bucket string, resources BucketMultipartResourcesMetadata) (BucketMultipartResourcesMetadata, *probe.Error)
        // Object resource API.
        GetObject(bucket, object string, startOffset int64) (io.ReadCloser, *probe.Error)
        GetObjectInfo(bucket, object string) (ObjectInfo, *probe.Error)
        PutObject(bucket string, object string, size int64, data io.Reader, metadata map[string]string) (ObjectInfo, *probe.Error)
        DeleteObject(bucket, object string) *probe.Error
        // Object query API.
        NewMultipartUpload(bucket, object string) (string, *probe.Error)
        PutObjectPart(bucket, object, uploadID string, partID int, size int64, data io.Reader, md5Hex string) (string, *probe.Error)
        ListObjectParts(bucket, object string, resources ObjectResourcesMetadata) (ObjectResourcesMetadata, *probe.Error)
        CompleteMultipartUpload(bucket string, object string, uploadID string, parts []CompletePart) (ObjectInfo, *probe.Error)
        AbortMultipartUpload(bucket, object, uploadID string) *probe.Error
}
```
											 
										 
										
											2016-03-31 07:15:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										metadata  :=  make ( map [ string ] string ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										metadata [ "md5Sum" ]  =  expectedMD5Sumhex 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-03 03:18:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  objInfo  ObjectInfo 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										objInfo ,  err  =  obj . PutObject ( "bucket" ,  key ,  int64 ( len ( randomString ) ) ,  bytes . NewBufferString ( randomString ) ,  metadata ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-03 03:18:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  objInfo . MD5Sum  !=  expectedMD5Sumhex  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "Md5 Mismatch" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  key ,  value  :=  range  objects  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  byteBuffer  bytes . Buffer 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-29 06:13:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										err  =  obj . GetObject ( "bucket" ,  key ,  0 ,  int64 ( len ( value ) ) ,  & byteBuffer ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ! bytes . Equal ( byteBuffer . Bytes ( ) ,  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Mismatch of GetObject data with the expected one." ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										objInfo ,  err  :=  obj . GetObjectInfo ( "bucket" ,  key ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  objInfo . Size  !=  int64 ( len ( value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Size mismatch of the GetObject data." ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling TestPaging for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestPaging ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testPaging ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate creation of objects and the order of listing using various filters for ListObjects operation.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testPaging ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									result ,  err  :=  obj . ListObjects ( "bucket" ,  "" ,  "" ,  "" ,  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( result . Objects )  !=  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Number of objects in the result different from expected value." ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  result . IsTruncated  !=  false  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected IsTruncated to be `false`, but instead found it to be `%v`" ,  instanceType ,  result . IsTruncated ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uploadContent  :=  "The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed." 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check before paging occurs.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  i  :=  0 ;  i  <  5 ;  i ++  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										key  :=  "obj"  +  strconv . Itoa ( i ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( "bucket" ,  key ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-27 01:35:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "" ,  "" ,  "" ,  5 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  len ( result . Objects )  !=  i + 1  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected length of objects to be %d, instead found to be %d" ,  instanceType ,  len ( result . Objects ) ,  i + 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . IsTruncated  !=  false  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected IsTruncated to be `false`, but instead found it to be `%v`" ,  instanceType ,  result . IsTruncated ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check after paging occurs pages work.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  i  :=  6 ;  i  <=  10 ;  i ++  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										key  :=  "obj"  +  strconv . Itoa ( i ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( "bucket" ,  key ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-27 01:35:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "obj" ,  "" ,  "" ,  5 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  len ( result . Objects )  !=  5  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected length of objects to be %d, instead found to be %d" ,  instanceType ,  5 ,  len ( result . Objects ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . IsTruncated  !=  true  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected IsTruncated to be `true`, but instead found it to be `%v`" ,  instanceType ,  result . IsTruncated ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check paging with prefix at end returns less objects.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( "bucket" ,  "newPrefix" ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( "bucket" ,  "newPrefix2" ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-27 01:35:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "new" ,  "" ,  "" ,  5 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  len ( result . Objects )  !=  2  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected length of objects to be %d, instead found to be %d" ,  instanceType ,  2 ,  len ( result . Objects ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check ordering of pages.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "" ,  "" ,  "" ,  1000 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 0 ] . Name  !=  "newPrefix"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 1 ] . Name  !=  "newPrefix2"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 1 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 2 ] . Name  !=  "obj0"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 2 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 3 ] . Name  !=  "obj1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 3 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 4 ] . Name  !=  "obj10"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 4 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check delimited results with delimiter and prefix.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( "bucket" ,  "this/is/delimited" ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( "bucket" ,  "this/is/also/a/delimited/file" ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "this/is/" ,  "" ,  "/" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  len ( result . Objects )  !=  1  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the number of objects in the result to be %d, but instead found %d" ,  instanceType ,  1 ,  len ( result . Objects ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Prefixes [ 0 ]  !=  "this/is/also/"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected prefix to be `%s`, but instead found `%s`" ,  instanceType ,  "this/is/also/" ,  result . Prefixes [ 0 ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check delimited results with delimiter without prefix.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "" ,  "" ,  "/" ,  1000 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 0 ] . Name  !=  "newPrefix"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 1 ] . Name  !=  "newPrefix2"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 1 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 2 ] . Name  !=  "obj0"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 2 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 3 ] . Name  !=  "obj1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 3 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 4 ] . Name  !=  "obj10"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 4 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Prefixes [ 0 ]  !=  "this/"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the prefix to be `%s`, but instead found `%s`" ,  instanceType ,  "this/" ,  result . Prefixes [ 0 ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check results with Marker.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-27 01:35:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "" ,  "newPrefix" ,  "" ,  3 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 0 ] . Name  !=  "newPrefix2"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix2" ,  result . Objects [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 1 ] . Name  !=  "obj0"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj0" ,  result . Objects [ 1 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 2 ] . Name  !=  "obj1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj1" ,  result . Objects [ 2 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check ordering of results with prefix.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "obj" ,  "" ,  "" ,  1000 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 0 ] . Name  !=  "obj0"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj0" ,  result . Objects [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 1 ] . Name  !=  "obj1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj1" ,  result . Objects [ 1 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 2 ] . Name  !=  "obj10"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj10" ,  result . Objects [ 2 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 3 ] . Name  !=  "obj2"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj2" ,  result . Objects [ 3 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 4 ] . Name  !=  "obj3"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "obj3" ,  result . Objects [ 4 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// check ordering of results with prefix and no paging.
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										result ,  err  =  obj . ListObjects ( "bucket" ,  "new" ,  "" ,  "" ,  5 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 0 ] . Name  !=  "newPrefix"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix" ,  result . Objects [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  result . Objects [ 1 ] . Name  !=  "newPrefix2"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name to be `%s`, but instead found `%s`" ,  instanceType ,  "newPrefix2" ,  result . Objects [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testObjectOverwriteWorks for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestObjectOverwriteWorks ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testObjectOverwriteWorks ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate overwriting of an existing object.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testObjectOverwriteWorks ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "object" ,  int64 ( len ( "The list of parts was not in ascending order. The parts list must be specified in order by part number." ) ) ,  bytes . NewBufferString ( "The list of parts was not in ascending order. The parts list must be specified in order by part number." ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									uploadContent  :=  "The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									length  :=  int64 ( len ( uploadContent ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "object" ,  length ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  bytesBuffer  bytes . Buffer 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-29 06:13:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . GetObject ( "bucket" ,  "object" ,  0 ,  length ,  & bytesBuffer ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  string ( bytesBuffer . Bytes ( ) )  !=  "The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed."  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Invalid upload ID error mismatch." ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testNonExistantBucketOperations for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestNonExistantBucketOperations ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testNonExistantBucketOperations ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate that bucket operation on non-existent bucket fails.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testNonExistantBucketOperations ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  :=  obj . PutObject ( "bucket1" ,  "object" ,  int64 ( len ( "one" ) ) ,  bytes . NewBufferString ( "one" ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatal ( "Expected error but found nil" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err . Error ( )  !=  "Bucket not found: bucket1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected the error msg to be `%s`, but instead found `%s`" ,  instanceType ,  "Bucket not found: bucket1" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testBucketRecreateFails for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestBucketRecreateFails ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testBucketRecreateFails ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate that recreation of the bucket fails.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testBucketRecreateFails ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "string" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . MakeBucket ( "string" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: Expected error but found nil." ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err . Error ( )  !=  "Bucket exists: string"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "Bucket exists: string" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testPutObject for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestPutObject ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testPutObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate PutObject without prefix.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testPutObject ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									content  :=  [ ] byte ( "testcontent" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									length  :=  int64 ( len ( content ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									readerEOF  :=  newTestReaderEOF ( content ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									readerNoEOF  :=  newTestReaderNoEOF ( content ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  bytesBuffer1  bytes . Buffer 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "object" ,  length ,  readerEOF ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . GetObject ( "bucket" ,  "object" ,  0 ,  length ,  & bytesBuffer1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( bytesBuffer1 . Bytes ( ) )  !=  len ( content )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected content length to be `%d`, but instead found `%d`" ,  instanceType ,  len ( content ) ,  len ( bytesBuffer1 . Bytes ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  bytesBuffer2  bytes . Buffer 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "object" ,  length ,  readerNoEOF ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . GetObject ( "bucket" ,  "object" ,  0 ,  length ,  & bytesBuffer2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( bytesBuffer2 . Bytes ( ) )  !=  len ( content )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected content length to be `%d`, but instead found `%d`" ,  instanceType ,  len ( content ) ,  len ( bytesBuffer2 . Bytes ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testPutObjectInSubdir for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestPutObjectInSubdir ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testPutObjectInSubdir ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-09 13:00:31 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate PutObject with subdirectory prefix.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testPutObjectInSubdir ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									uploadContent  :=  ` The  specified  multipart  upload  does  not  exist .  The  upload  ID  might  be  invalid ,  or  the  multipart 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 upload  might  have  been  aborted  or  completed . ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									length  :=  int64 ( len ( uploadContent ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "dir1/dir2/object" ,  length ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  bytesBuffer  bytes . Buffer 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-29 06:13:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . GetObject ( "bucket" ,  "dir1/dir2/object" ,  0 ,  length ,  & bytesBuffer ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( bytesBuffer . Bytes ( ) )  !=  len ( uploadContent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected length of downloaded data to be `%d`, but instead found `%d`" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											instanceType ,  len ( uploadContent ) ,  len ( bytesBuffer . Bytes ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testListBuckets for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestListBuckets ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testListBuckets ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate ListBuckets.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testListBuckets ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// test empty list.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									buckets ,  err  :=  obj . ListBuckets ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( buckets )  !=  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected number of bucket to be `%d`, but instead found `%d`" ,  instanceType ,  0 ,  len ( buckets ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// add one and test exists.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . MakeBucket ( "bucket1" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									buckets ,  err  =  obj . ListBuckets ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( buckets )  !=  1  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected number of bucket to be `%d`, but instead found `%d`" ,  instanceType ,  1 ,  len ( buckets ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// add two and test exists.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . MakeBucket ( "bucket2" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									buckets ,  err  =  obj . ListBuckets ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( buckets )  !=  2  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected number of bucket to be `%d`, but instead found `%d`" ,  instanceType ,  2 ,  len ( buckets ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// add three and test exists + prefix.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . MakeBucket ( "bucket22" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-02 14:10:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									buckets ,  err  =  obj . ListBuckets ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( buckets )  !=  3  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected number of bucket to be `%d`, but instead found `%d`" ,  instanceType ,  3 ,  len ( buckets ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testListBucketsOrder for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestListBucketsOrder ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testListBucketsOrder ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate the order of result of ListBuckets.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testListBucketsOrder ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// if implementation contains a map, order of map keys will vary.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// this ensures they return in the same order each time.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 19:21:52 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// add one and test exists.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket1" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 19:21:52 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  =  obj . MakeBucket ( "bucket2" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 19:21:52 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									buckets ,  err  :=  obj . ListBuckets ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( buckets )  !=  2  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected number of bucket to be `%d`, but instead found `%d`" ,  instanceType ,  2 ,  len ( buckets ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  buckets [ 0 ] . Name  !=  "bucket1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected bucket name to be `%s`, but instead found `%s`" ,  instanceType ,  "bucket1" ,  buckets [ 0 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  buckets [ 1 ] . Name  !=  "bucket2"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected bucket name to be `%s`, but instead found `%s`" ,  instanceType ,  "bucket2" ,  buckets [ 1 ] . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testListObjectsTestsForNonExistantBucket for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestListObjectsTestsForNonExistantBucket ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testListObjectsTestsForNonExistantBucket ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate that ListObjects operation on a non-existent bucket fails as expected.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testListObjectsTestsForNonExistantBucket ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									result ,  err  :=  obj . ListObjects ( "bucket" ,  "" ,  "" ,  "" ,  1000 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: Expected error but found nil." ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( result . Objects )  !=  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: Expected number of objects in the result to be `%d`, but instead found `%d`" ,  instanceType ,  0 ,  len ( result . Objects ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  result . IsTruncated  !=  false  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: Expected IsTruncated to be `false`, but instead found it to be `%v`" ,  instanceType ,  result . IsTruncated ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err . Error ( )  !=  "Bucket not found: bucket"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected the error msg to be `%s`, but instead found `%s`" ,  instanceType ,  "Bucket not found: bucket" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testNonExistantObjectInBucket for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestNonExistantObjectInBucket ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testNonExistantObjectInBucket ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate that GetObject fails on a non-existent bucket as expected.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testNonExistantObjectInBucket ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-18 02:57:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_ ,  err  =  obj . GetObjectInfo ( "bucket" ,  "dir1" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: Expected error but found nil" ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-26 00:39:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  =  errorCause ( err ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-30 05:24:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									switch  err  :=  err . ( type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									case  ObjectNotFound : 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err . Error ( )  !=  "Object not found: bucket#dir1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the Error message to be `%s`, but instead found `%s`" ,  instanceType ,  "Object not found: bucket#dir1" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									default : 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err . Error ( )  !=  "fails"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the Error message to be `%s`, but instead found it to be `%s`" ,  instanceType ,  "fails" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testGetDirectoryReturnsObjectNotFound for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestGetDirectoryReturnsObjectNotFound ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testGetDirectoryReturnsObjectNotFound ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Tests validate that GetObject on an existing directory fails as expected.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testGetDirectoryReturnsObjectNotFound ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-04-13 03:45:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "dir1/dir3/object" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int64 ( len ( "The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed." ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										bytes . NewBufferString ( "One or more of the specified parts could not be found. The part might not have been uploaded, or the specified entity tag might not have matched the part's entity tag." ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-18 02:57:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_ ,  err  =  obj . GetObjectInfo ( "bucket" ,  "dir1" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-26 00:39:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  =  errorCause ( err ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-30 05:24:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									switch  err  :=  err . ( type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-26 01:39:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									case  ObjectNotFound : 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err . Bucket  !=  "bucket"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the bucket name in the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "bucket" ,  err . Bucket ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err . Object  !=  "dir1"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name in the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "dir1" ,  err . Object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									default : 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err . Error ( )  !=  "ObjectNotFound"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "ObjectNotFound" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-18 02:57:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_ ,  err  =  obj . GetObjectInfo ( "bucket" ,  "dir1/" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-26 00:39:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  =  errorCause ( err ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-30 05:24:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									switch  err  :=  err . ( type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-14 02:43:06 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									case  ObjectNameInvalid : 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err . Bucket  !=  "bucket"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the bucket name in the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "bucket" ,  err . Bucket ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err . Object  !=  "dir1/"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the object name in the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "dir1/" ,  err . Object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									default : 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// force a failure with a line number.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err . Error ( )  !=  "ObjectNotFound"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											c . Errorf ( "%s: Expected the error message to be `%s`, but instead found `%s`" ,  instanceType ,  "ObjectNotFound" ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Wrapper for calling testContentType for both XL and FS.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  ( s  * ObjectLayerAPISuite )  TestContentType ( c  * C )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerTest ( c ,  testContentType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// Test content-type.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  testContentType ( obj  ObjectLayer ,  instanceType  string ,  c  TestErrHandler )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									err  :=  obj . MakeBucket ( "bucket" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uploadContent  :=  "The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed." 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 10:28:13 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Test empty.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( "bucket" ,  "minio.png" ,  int64 ( len ( uploadContent ) ) ,  bytes . NewBufferString ( uploadContent ) ,  nil ,  "" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-17 12:42:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									objInfo ,  err  :=  obj . GetObjectInfo ( "bucket" ,  "minio.png" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Fatalf ( "%s: <ERROR> %s" ,  instanceType ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  objInfo . ContentType  !=  "image/png"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . Errorf ( "%s: Expected Content type to be `%s`, but instead found `%s`" ,  instanceType ,  "image/png" ,  objInfo . ContentType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 02:26:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}