2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ *  
						 
					
						
							
								
									
										
										
										
											2019-04-10 02:39:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  MinIO  Cloud  Storage ,  ( C )  2016 ,  2017  MinIO ,  Inc . 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +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  
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"bytes" 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-16 04:27:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"context" 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"fmt" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"io" 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"os" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"runtime" 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"strings" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"testing" 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									humanize  "github.com/dustin/go-humanize" 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling GetObject tests for both Erasure multiple disks and single node setup.
  
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  TestGetObject ( t  * testing . T )  {  
						 
					
						
							
								
									
										
										
										
											2021-01-06 12:08:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExecExtendedObjectLayerTest ( t ,  testGetObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// ObjectLayer.GetObject is called with series of cases for valid and erroneous inputs and the result is validated.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  testGetObject ( obj  ObjectLayer ,  instanceType  string ,  t  TestErrHandler )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Setup for the tests.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucketName  :=  getRandomBucketName ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									objectName  :=  "test-object" 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									emptyDirName  :=  "test-empty-dir/" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucketName ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Stop the test if creation of the bucket fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of byte data for PutObject.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-04 15:09:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// object has to be created before running tests for GetObject.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// this is required even to assert the GetObject data,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// since dataInserted === dataFetched back is a primary criteria for any object storage this assertion is critical.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bytesData  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										byteData  [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Regular data
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ generateBytesData ( 6  *  humanize . MiByte ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Empty data for empty directory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of inputs for uploading the objects before tests for downloading is done.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									putObjectInputs  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objectName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										contentLength  int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										textData       [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										metaData       map [ string ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// case - 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  bytesData [ 0 ] . byteData ,  make ( map [ string ] string ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucketName ,  emptyDirName ,  int64 ( len ( bytesData [ 1 ] . byteData ) ) ,  bytesData [ 1 ] . byteData ,  make ( map [ string ] string ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// iterate through the above set of inputs and upkoad the object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  input  :=  range  putObjectInputs  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// uploading the object.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( context . Background ( ) ,  input . bucketName ,  input . objectName ,  mustGetPutObjReader ( t ,  bytes . NewBuffer ( input . textData ) ,  input . contentLength ,  input . metaData [ "etag" ] ,  "" ) ,  ObjectOptions { UserDefined :  input . metaData } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// if object upload fails stop the test.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Fatalf ( "Put Object case %d:  Error uploading object: <ERROR> %v" ,  i + 1 ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of empty buffers used to fill GetObject data.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									buffers  :=  [ ] * bytes . Buffer { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										new ( bytes . Buffer ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										new ( bytes . Buffer ) , 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										new ( bytes . Buffer ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// test cases with set of inputs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									testCases  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objectName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										startOffset  int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										length       int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// data obtained/fetched from GetObject.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										getObjectData  * bytes . Buffer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// writer which governs the write into the `getObjectData`.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										writer  io . Writer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// flag indicating whether the test for given ase should pass.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shouldPass  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// expected Result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedData  [ ] byte 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										err           error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case 1-4.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Cases with invalid bucket names.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ ".test" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: .test" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "------" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: ------" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "$this-is-not-valid-too" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											[ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: $this-is-not-valid-too" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "a" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: a" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case - 5.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Case with invalid object names.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucketName ,  "" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Object name invalid: " + bucketName + "/" ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										//	Test case - 6.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  NewEOFWriter ( buffers [ 0 ] ,  100 ) ,  false ,  [ ] byte { } ,  io . EOF } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with start offset set to 0 and length set to size of the object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Fetching the entire object.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// 	Test case - 7.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case with `length` parameter set to a negative value.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 8.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( - 1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with content-range 1 to objectSize .
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 9.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  1 ,  int64 ( len ( bytesData [ 0 ] . byteData )  -  1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData [ 1 : ] ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with content-range 100 to objectSize - 100.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 10.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  100 ,  int64 ( len ( bytesData [ 0 ] . byteData )  -  200 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bytesData [ 0 ] . byteData [ 100  :  len ( bytesData [ 0 ] . byteData ) - 100 ] ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with offset greater than the size of the object
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 11.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											NewEOFWriter ( buffers [ 0 ] ,  100 ) ,  false ,  [ ] byte { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											InvalidRange { int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with offset greater than the size of the object.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 12.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  - 1 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  new ( bytes . Buffer ) ,  false ,  [ ] byte { } ,  errUnexpected } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case length parameter is more than the object size.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 13.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  false ,  bytesData [ 0 ] . byteData , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											InvalidRange { 0 ,  int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with offset + length > objectSize parameter set to a negative value.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 14.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  2 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  false ,  bytesData [ 0 ] . byteData , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											InvalidRange { 2 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with the writer set to nil.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 15.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 1 ] ,  nil ,  false ,  bytesData [ 0 ] . byteData ,  errUnexpected } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-06 07:38:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 16.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case when it is an empty directory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  emptyDirName ,  0 ,  int64 ( len ( bytesData [ 1 ] . byteData ) ) ,  buffers [ 2 ] ,  buffers [ 2 ] ,  true ,  bytesData [ 1 ] . byteData ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  testCase  :=  range  testCases  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 00:42:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										err  =  obj . GetObject ( context . Background ( ) ,  testCase . bucketName ,  testCase . objectName ,  testCase . startOffset ,  testCase . length ,  testCase . writer ,  "" ,  ObjectOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s:  Expected to pass, but failed with: <ERROR> %s" ,  i + 1 ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  ==  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with <ERROR> \"%s\", but passed instead." ,  i + 1 ,  instanceType ,  testCase . err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed as expected, but does it fail for the expected reason.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ! strings . Contains ( err . Error ( ) ,  testCase . err . Error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead." ,  i + 1 ,  instanceType ,  testCase . err . Error ( ) ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Since there are cases for which GetObject fails, this is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// necessary. Test passes as expected, but the output values
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// are verified for correctness here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  ==  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ! bytes . Equal ( testCase . expectedData ,  testCase . getObjectData . Bytes ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Data Mismatch: Expected data and the fetched data from GetObject doesn't match." ,  i + 1 ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// empty the buffer so that it can be used to further cases.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											testCase . getObjectData . Reset ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling GetObject with permission denied expected
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  TestGetObjectPermissionDenied ( t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Windows doesn't support Chmod under golang
 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-19 04:24:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  runtime . GOOS  !=  globalWindowsOSName  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ExecObjectLayerDiskAlteredTest ( t ,  testGetObjectPermissionDenied ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Test GetObject when we are allowed to access some dirs and objects
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  testGetObjectPermissionDenied ( obj  ObjectLayer ,  instanceType  string ,  disks  [ ] string ,  t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Setup for the tests.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucketName  :=  getRandomBucketName ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucketName ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Stop the test if creation of the bucket fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bytesData  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										byteData  [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ generateBytesData ( 6  *  humanize . MiByte ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of inputs for uploading the objects before tests for downloading is done.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									putObjectInputs  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objectName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										contentLength  int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										textData       [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										metaData       map [ string ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  "test-object1" ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  bytesData [ 0 ] . byteData ,  make ( map [ string ] string ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  "test-object2" ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  bytesData [ 0 ] . byteData ,  make ( map [ string ] string ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  "dir/test-object3" ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  bytesData [ 0 ] . byteData ,  make ( map [ string ] string ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// iterate through the above set of inputs and upkoad the object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  input  :=  range  putObjectInputs  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// uploading the object.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( context . Background ( ) ,  input . bucketName ,  input . objectName ,  mustGetPutObjReader ( t ,  bytes . NewBuffer ( input . textData ) ,  input . contentLength ,  input . metaData [ "etag" ] ,  "" ) ,  ObjectOptions { UserDefined :  input . metaData } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// if object upload fails stop the test.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Fatalf ( "Put Object case %d:  Error uploading object: <ERROR> %v" ,  i + 1 ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of empty buffers used to fill GetObject data.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									buffers  :=  [ ] * bytes . Buffer { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										new ( bytes . Buffer ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// test cases with set of inputs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									testCases  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objectName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										chmodPath    string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										startOffset  int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										length       int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// data obtained/fetched from GetObject.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										getObjectData  * bytes . Buffer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// writer which governs the write into the `getObjectData`.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										writer  io . Writer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// flag indicating whether the test for given ase should pass.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shouldPass  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// expected Result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedData  [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										err           error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test 1 - chmod 000 bucket/test-object1
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  "test-object1" ,  "test-object1" ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  buffers [ 0 ] ,  false ,  bytesData [ 0 ] . byteData ,  PrefixAccessDenied { Bucket :  bucketName ,  Object :  "test-object1" } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test 2 - chmod 000 bucket/dir/
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  "dir/test-object2" ,  "dir" ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  buffers [ 0 ] ,  false ,  bytesData [ 0 ] . byteData ,  PrefixAccessDenied { Bucket :  bucketName ,  Object :  "dir/test-object2" } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test 3 - chmod 000 bucket/
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  "test-object3" ,  "" ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  buffers [ 0 ] ,  false ,  bytesData [ 0 ] . byteData ,  PrefixAccessDenied { Bucket :  bucketName ,  Object :  "test-object3" } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  testCase  :=  range  testCases  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  d  :=  range  disks  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-07 03:08:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											err  =  os . Chmod ( d + SlashSeparator + testCase . bucketName + SlashSeparator + testCase . chmodPath ,  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Fatalf ( "Test %d, Unable to chmod: %v" ,  i + 1 ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 00:42:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										err  =  obj . GetObject ( context . Background ( ) ,  testCase . bucketName ,  testCase . objectName ,  testCase . startOffset ,  testCase . length ,  testCase . writer ,  "" ,  ObjectOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  err  !=  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s:  Expected to pass, but failed with: <ERROR> %s" ,  i + 1 ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  ==  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with <ERROR> \"%s\", but passed instead." ,  i + 1 ,  instanceType ,  testCase . err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed as expected, but does it fail for the expected reason.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ! strings . Contains ( err . Error ( ) ,  testCase . err . Error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead." ,  i + 1 ,  instanceType ,  testCase . err . Error ( ) ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Since there are cases for which GetObject fails, this is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// necessary. Test passes as expected, but the output values
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// are verified for correctness here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  ==  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ! bytes . Equal ( testCase . expectedData ,  testCase . getObjectData . Bytes ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Data Mismatch: Expected data and the fetched data from GetObject doesn't match." ,  i + 1 ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// empty the buffer so that it can be used to further cases.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											testCase . getObjectData . Reset ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling GetObject tests for both Erasure multiple disks and single node setup.
  
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  TestGetObjectDiskNotFound ( t  * testing . T )  {  
						 
					
						
							
								
									
										
										
										
											2016-10-21 07:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExecObjectLayerDiskAlteredTest ( t ,  testGetObjectDiskNotFound ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// ObjectLayer.GetObject is called with series of cases for valid and erroneous inputs and the result is validated.
  
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Before the Get Object call Erasure disks are moved so that the quorum just holds.
  
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testGetObjectDiskNotFound ( obj  ObjectLayer ,  instanceType  string ,  disks  [ ] string ,  t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Setup for the tests.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucketName  :=  getRandomBucketName ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									objectName  :=  "test-object" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucketName ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Stop the test if creation of the bucket fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of byte data for PutObject.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-04 15:09:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// object has to be created before running tests for GetObject.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// this is required even to assert the GetObject data,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// since dataInserted === dataFetched back is a primary criteria for any object storage this assertion is critical.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bytesData  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										byteData  [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ generateBytesData ( 6  *  humanize . MiByte ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of inputs for uploading the objects before tests for downloading is done.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									putObjectInputs  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objectName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										contentLength  int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										textData       [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										metaData       map [ string ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// case - 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  bytesData [ 0 ] . byteData ,  make ( map [ string ] string ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// iterate through the above set of inputs and upkoad the object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  input  :=  range  putObjectInputs  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// uploading the object.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_ ,  err  =  obj . PutObject ( context . Background ( ) ,  input . bucketName ,  input . objectName ,  mustGetPutObjReader ( t ,  bytes . NewBuffer ( input . textData ) ,  input . contentLength ,  input . metaData [ "etag" ] ,  "" ) ,  ObjectOptions { UserDefined :  input . metaData } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// if object upload fails stop the test.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Fatalf ( "Put Object case %d:  Error uploading object: <ERROR> %v" ,  i + 1 ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 04:08:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Take 4 disks down before GetObject is called, one more we loose quorum on 16 disk node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  disk  :=  range  disks [ : 4 ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-13 10:25:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										os . RemoveAll ( disk ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 10:06:50 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set of empty buffers used to fill GetObject data.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									buffers  :=  [ ] * bytes . Buffer { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										new ( bytes . Buffer ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										new ( bytes . Buffer ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// test cases with set of inputs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									testCases  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objectName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										startOffset  int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										length       int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// data obtained/fetched from GetObject.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										getObjectData  * bytes . Buffer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// writer which governs the write into the `getObjectData`.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										writer  io . Writer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// flag indicating whether the test for given ase should pass.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shouldPass  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// expected Result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedData  [ ] byte 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										err           error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case 1-4.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Cases with invalid bucket names.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ ".test" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: .test" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "------" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: ------" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "$this-is-not-valid-too" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											[ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: $this-is-not-valid-too" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "a" ,  "obj" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Bucket name invalid: a" ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case - 5.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Case with invalid object names.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucketName ,  "" ,  0 ,  0 ,  nil ,  nil ,  false ,  [ ] byte ( "" ) ,  fmt . Errorf ( "%s" ,  "Object name invalid: " + bucketName + "/" ) } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										//	Test case - 7.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  NewEOFWriter ( buffers [ 0 ] ,  100 ) ,  false ,  [ ] byte { } ,  io . EOF } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with start offset set to 0 and length set to size of the object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Fetching the entire object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// 	Test case - 8.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case with `length` parameter set to a negative value.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Test case - 9.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( - 1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with `length` parameter set to a negative value and offset is positive.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case - 10.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  1 ,  int64 ( - 1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData [ 1 : ] ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with content-range 1 to objectSize .
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case - 11.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  1 ,  int64 ( len ( bytesData [ 0 ] . byteData )  -  1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true ,  bytesData [ 0 ] . byteData [ 1 : ] ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with content-range 100 to objectSize - 100.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 12.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  100 ,  int64 ( len ( bytesData [ 0 ] . byteData )  -  200 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bytesData [ 0 ] . byteData [ 100  :  len ( bytesData [ 0 ] . byteData ) - 100 ] ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with offset greater than the size of the object
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 13.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											NewEOFWriter ( buffers [ 0 ] ,  100 ) ,  false ,  [ ] byte { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											InvalidRange { int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with offset greater than the size of the object.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 14.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  - 1 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 0 ] ,  new ( bytes . Buffer ) ,  false ,  [ ] byte { } ,  errUnexpected } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case length parameter is more than the object size.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 15.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  false ,  bytesData [ 0 ] . byteData , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											InvalidRange { 0 ,  int64 ( len ( bytesData [ 0 ] . byteData )  +  1 ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with offset + length > objectSize parameter set to a negative value.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 16.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  2 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 1 ] ,  buffers [ 1 ] ,  false ,  bytesData [ 0 ] . byteData , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											InvalidRange { 2 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case with the writer set to nil.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 03:29:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 17.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ bucketName ,  objectName ,  0 ,  int64 ( len ( bytesData [ 0 ] . byteData ) ) ,  buffers [ 1 ] ,  nil ,  false ,  bytesData [ 0 ] . byteData ,  errUnexpected } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  testCase  :=  range  testCases  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 00:42:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										err  =  obj . GetObject ( context . Background ( ) ,  testCase . bucketName ,  testCase . objectName ,  testCase . startOffset ,  testCase . length ,  testCase . writer ,  "" ,  ObjectOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 09:26:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s:  Expected to pass, but failed with: <ERROR> %s" ,  i + 1 ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  ==  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with <ERROR> \"%s\", but passed instead." ,  i + 1 ,  instanceType ,  testCase . err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed as expected, but does it fail for the expected reason.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ! strings . Contains ( err . Error ( ) ,  testCase . err . Error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead." ,  i + 1 ,  instanceType ,  testCase . err . Error ( ) ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Since there are cases for which GetObject fails, this is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// necessary. Test passes as expected, but the output values
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// are verified for correctness here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  ==  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ! bytes . Equal ( testCase . expectedData ,  testCase . getObjectData . Bytes ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Data Mismatch: Expected data and the fetched data from GetObject doesn't match." ,  i + 1 ,  instanceType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// empty the buffer so that it can be used to further cases.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											testCase . getObjectData . Reset ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Benchmarks for ObjectLayer.GetObject().
  
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// The intent is to benchmark GetObject for various sizes ranging from few bytes to 100MB.
  
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Also each of these Benchmarks are run both Erasure and FS backends.
  
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectVerySmallFS - Benchmark FS.GetObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectVerySmallFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectVerySmallErasure - Benchmark Erasure.GetObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectVerySmallErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject10KbFS - Benchmark FS.GetObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject10KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject10KbErasure - Benchmark Erasure.GetObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject10KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject100KbFS - Benchmark FS.GetObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject100KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject100KbErasure - Benchmark Erasure.GetObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject100KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject1MbFS - Benchmark FS.GetObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject1MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject1MbErasure - Benchmark Erasure.GetObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject1MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject5MbFS - Benchmark FS.GetObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject5MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject5MbErasure - Benchmark Erasure.GetObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject5MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject10MbFS - Benchmark FS.GetObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject10MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject10MbErasure - Benchmark Erasure.GetObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject10MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject25MbFS - Benchmark FS.GetObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject25MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject25MbErasure - Benchmark Erasure.GetObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject25MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObject50MbFS - Benchmark FS.GetObject() for object size of 50MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject50MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "FS" ,  50 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObject50MbErasure - Benchmark Erasure.GetObject() for object size of 50MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObject50MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObject ( b ,  "Erasure" ,  50 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// parallel benchmarks for ObjectLayer.GetObject() .
  
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallelVerySmallFS - Benchmark FS.GetObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallelVerySmallFS ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallelVerySmallErasure - Benchmark Erasure.GetObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallelVerySmallErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel10KbFS - Benchmark FS.GetObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel10KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel10KbErasure - Benchmark Erasure.GetObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel10KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel100KbFS - Benchmark FS.GetObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel100KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel100KbErasure - Benchmark Erasure.GetObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel100KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel1MbFS - Benchmark FS.GetObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel1MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel1MbErasure - Benchmark Erasure.GetObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel1MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel5MbFS - Benchmark FS.GetObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel5MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel5MbErasure - Benchmark Erasure.GetObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel5MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel10MbFS - Benchmark FS.GetObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel10MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel10MbErasure - Benchmark Erasure.GetObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel10MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel25MbFS - Benchmark FS.GetObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel25MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel25MbErasure - Benchmark Erasure.GetObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel25MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel50MbFS - Benchmark FS.GetObject() for object size of 50MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel50MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "FS" ,  50 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkGetObjectParallel50MbErasure - Benchmark Erasure.GetObject() for object size of 50MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkGetObjectParallel50MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkGetObjectParallel ( b ,  "Erasure" ,  50 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}