2021-04-19 03:41:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Copyright (c) 2015-2021 MinIO, Inc.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// This file is part of MinIO Object Storage stack
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// This program is free software: you can redistribute it and/or modify
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// it under the terms of the GNU Affero General Public License as published by
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// the Free Software Foundation, either version 3 of the License, or
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// (at your option) any later version.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// This program is distributed in the hope that it will be useful
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// but WITHOUT ANY WARRANTY; without even the implied warranty of
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// GNU Affero General Public License for more details.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// You should have received a copy of the GNU Affero General Public License
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-19 07:23:42 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  cmd  
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"bytes" 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-16 04:27:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"context" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"crypto/md5" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"encoding/hex" 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 01:12:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"errors" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"io/ioutil" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"os" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"path" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"testing" 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									humanize  "github.com/dustin/go-humanize" 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-02 05:59:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/internal/hash" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  md5Header ( data  [ ] byte )  map [ string ] string  {  
						 
					
						
							
								
									
										
										
										
											2021-05-25 00:28:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  map [ string ] string { "etag" :  getMD5Hash ( data ) } 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling PutObject tests for both Erasure multiple disks and single node setup.
  
						 
					
						
							
								
									
										
										
										
											2017-10-22 13:30:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  TestObjectAPIPutObjectSingle ( t  * testing . T )  {  
						 
					
						
							
								
									
										
										
										
											2021-01-06 12:08:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExecExtendedObjectLayerTest ( t ,  testObjectAPIPutObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Tests validate correctness of PutObject.
  
						 
					
						
							
								
									
										
										
										
											2016-07-08 06:05:51 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  testObjectAPIPutObject ( obj  ObjectLayer ,  instanceType  string ,  t  TestErrHandler )  {  
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Generating cases for which the PutObject fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucket  :=  "minio-bucket" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									object  :=  "minio-object" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucket ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create newbucket, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Creating a dummy bucket for tests.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  =  obj . MakeBucketWithLocation ( context . Background ( ) ,  "unused-bucket" ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create newbucket, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									var  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nilBytes     [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										data         =  [ ] byte ( "hello" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										fiveMBBytes  =  bytes . Repeat ( [ ] byte ( "a" ) ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 05:51:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									invalidMD5  :=  getMD5Hash ( [ ] byte ( "meh" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									invalidMD5Header  :=  md5Header ( [ ] byte ( "meh" ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									testCases  :=  [ ] struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucketName      string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objName         string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										inputData       [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										inputMeta       map [ string ] string 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										inputSHA256     string 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										intputDataSize  int64 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// expected error output.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedMd5    string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedError  error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case  1-4.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Cases with invalid bucket name.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 11:27:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ ".test" ,  "obj" ,  [ ] byte ( "" ) ,  nil ,  "" ,  0 ,  "" ,  BucketNotFound { Bucket :  ".test" } } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ "------" ,  "obj" ,  [ ] byte ( "" ) ,  nil ,  "" ,  0 ,  "" ,  BucketNotFound { Bucket :  "------" } } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											"$this-is-not-valid-too" ,  "obj" ,  [ ] byte ( "" ) ,  nil ,  "" ,  0 ,  "" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											BucketNotFound { Bucket :  "$this-is-not-valid-too" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 11:27:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ "a" ,  "obj" ,  [ ] byte ( "" ) ,  nil ,  "" ,  0 ,  "" ,  BucketNotFound { Bucket :  "a" } } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Test case - 5.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Case with invalid object names.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  "" ,  [ ] byte ( "" ) ,  nil ,  "" ,  0 ,  "" ,  ObjectNameInvalid { Bucket :  bucket ,  Object :  "" } } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Test case - 6.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Valid object and bucket names but non-existent bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ "abc" ,  "def" ,  [ ] byte ( "" ) ,  nil ,  "" ,  0 ,  "" ,  BucketNotFound { Bucket :  "abc" } } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Test case - 7.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Input to replicate Md5 mismatch.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  [ ] byte ( "" ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											map [ string ] string { "etag" :  "d41d8cd98f00b204e9800998ecf8427f" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											"" ,  0 ,  "" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . BadDigest { ExpectedMD5 :  "d41d8cd98f00b204e9800998ecf8427f" ,  CalculatedMD5 :  "d41d8cd98f00b204e9800998ecf8427e" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Test case - 8.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// With incorrect sha256.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  [ ] byte ( "abcd" ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											map [ string ] string { "etag" :  "e2fc714c4727ee9395f324cd2e7f331f" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-22 13:30:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											"88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031580" ,  int64 ( len ( "abcd" ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											"" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . SHA256Mismatch { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												ExpectedSHA256 :    "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031580" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												CalculatedSHA256 :  "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case - 9.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Input with size more than the size of actual data inside the reader.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  [ ] byte ( "abcd" ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											map [ string ] string { "etag" :  "e2fc714c4727ee9395f324cd2e7f331e" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											"" ,  int64 ( len ( "abcd" )  +  1 ) ,  "" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . BadDigest { ExpectedMD5 :  "e2fc714c4727ee9395f324cd2e7f331e" ,  CalculatedMD5 :  "e2fc714c4727ee9395f324cd2e7f331f" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 10.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Input with size less than the size of actual data inside the reader.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  [ ] byte ( "abcd" ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											map [ string ] string { "etag" :  "900150983cd24fb0d6963f7d28e17f73" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											"" ,  int64 ( len ( "abcd" )  -  1 ) ,  "" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . BadDigest { ExpectedMD5 :  "900150983cd24fb0d6963f7d28e17f73" ,  CalculatedMD5 :  "900150983cd24fb0d6963f7d28e17f72" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case - 11-14.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// Validating for success cases.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-15 03:05:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "abcd" ) ,  map [ string ] string { "etag" :  "e2fc714c4727ee9395f324cd2e7f331f" } ,  "" ,  int64 ( len ( "abcd" ) ) ,  "" ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "efgh" ) ,  map [ string ] string { "etag" :  "1f7690ebdd9b4caf8fab49ca1757bf27" } ,  "" ,  int64 ( len ( "efgh" ) ) ,  "" ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "ijkl" ) ,  map [ string ] string { "etag" :  "09a0877d04abf8759f99adec02baf579" } ,  "" ,  int64 ( len ( "ijkl" ) ) ,  "" ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "mnop" ) ,  map [ string ] string { "etag" :  "e132e96a5ddad6da8b07bba6f6131fef" } ,  "" ,  int64 ( len ( "mnop" ) ) ,  "" ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case 15-17.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// With no metadata
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 05:51:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  data ,  nil ,  "" ,  int64 ( len ( data ) ) ,  getMD5Hash ( data ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  nilBytes ,  nil ,  "" ,  int64 ( len ( nilBytes ) ) ,  getMD5Hash ( nilBytes ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  fiveMBBytes ,  nil ,  "" ,  int64 ( len ( fiveMBBytes ) ) ,  getMD5Hash ( fiveMBBytes ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case 18-20.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// With arbitrary metadata
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 05:51:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  data ,  map [ string ] string { "answer" :  "42" } ,  "" ,  int64 ( len ( data ) ) ,  getMD5Hash ( data ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  nilBytes ,  map [ string ] string { "answer" :  "42" } ,  "" ,  int64 ( len ( nilBytes ) ) ,  getMD5Hash ( nilBytes ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  fiveMBBytes ,  map [ string ] string { "answer" :  "42" } ,  "" ,  int64 ( len ( fiveMBBytes ) ) ,  getMD5Hash ( fiveMBBytes ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case 21-23.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// With valid md5sum and sha256.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 05:51:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  data ,  md5Header ( data ) ,  getSHA256Hash ( data ) ,  int64 ( len ( data ) ) ,  getMD5Hash ( data ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  nilBytes ,  md5Header ( nilBytes ) ,  getSHA256Hash ( nilBytes ) ,  int64 ( len ( nilBytes ) ) ,  getMD5Hash ( nilBytes ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  fiveMBBytes ,  md5Header ( fiveMBBytes ) ,  getSHA256Hash ( fiveMBBytes ) ,  int64 ( len ( fiveMBBytes ) ) ,  getMD5Hash ( fiveMBBytes ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case 24-26.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// data with invalid md5sum in header
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 01:15:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  data ,  invalidMD5Header ,  "" ,  int64 ( len ( data ) ) ,  getMD5Hash ( data ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . BadDigest { ExpectedMD5 :  invalidMD5 ,  CalculatedMD5 :  getMD5Hash ( data ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  nilBytes ,  invalidMD5Header ,  "" ,  int64 ( len ( nilBytes ) ) ,  getMD5Hash ( nilBytes ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . BadDigest { ExpectedMD5 :  invalidMD5 ,  CalculatedMD5 :  getMD5Hash ( nilBytes ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bucket ,  object ,  fiveMBBytes ,  invalidMD5Header ,  "" ,  int64 ( len ( fiveMBBytes ) ) ,  getMD5Hash ( fiveMBBytes ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hash . BadDigest { ExpectedMD5 :  invalidMD5 ,  CalculatedMD5 :  getMD5Hash ( fiveMBBytes ) } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case 27-29.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// data with size different from the actual number of bytes available in the reader
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 05:51:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  data ,  nil ,  "" ,  int64 ( len ( data )  -  1 ) ,  getMD5Hash ( data [ : len ( data ) - 1 ] ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 05:22:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  nilBytes ,  nil ,  "" ,  int64 ( len ( nilBytes )  +  1 ) ,  getMD5Hash ( nilBytes ) ,  IncompleteBody { Bucket :  bucket ,  Object :  object } } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-25 01:20:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  fiveMBBytes ,  nil ,  "" ,  0 ,  getMD5Hash ( fiveMBBytes ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-17 04:06:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Test case 30
 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-17 04:06:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// valid data with X-Amz-Meta- meta
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 05:51:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  data ,  map [ string ] string { "X-Amz-Meta-AppID" :  "a42" } ,  "" ,  int64 ( len ( data ) ) ,  getMD5Hash ( data ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 07:37:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case 31
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Put an empty object with a trailing slash
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  "emptydir/" ,  [ ] byte { } ,  nil ,  "" ,  0 ,  getMD5Hash ( [ ] byte { } ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case 32
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Put an object inside the empty directory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  "emptydir/"  +  object ,  data ,  nil ,  "" ,  int64 ( len ( data ) ) ,  getMD5Hash ( data ) ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test case 33
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Put the empty object with a trailing slash again (refer to Test case 31), this needs to succeed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  "emptydir/" ,  [ ] byte { } ,  nil ,  "" ,  0 ,  getMD5Hash ( [ ] byte { } ) ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  i ,  testCase  :=  range  testCases  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-15 05:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										in  :=  mustGetPutObjReader ( t ,  bytes . NewReader ( testCase . inputData ) ,  testCase . intputDataSize ,  testCase . inputMeta [ "etag" ] ,  testCase . inputSHA256 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objInfo ,  actualErr  :=  obj . PutObject ( context . Background ( ) ,  testCase . bucketName ,  testCase . objName ,  in ,  ObjectOptions { UserDefined :  testCase . inputMeta } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  actualErr  !=  nil  &&  testCase . expectedError  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to pass, but failed with: error %s." ,  i + 1 ,  instanceType ,  actualErr . Error ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-15 05:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  actualErr  ==  nil  &&  testCase . expectedError  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with error \"%s\", but passed instead." ,  i + 1 ,  instanceType ,  testCase . expectedError . Error ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-15 05:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed as expected, but does it fail for the expected reason.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-26 00:39:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  actualErr  !=  nil  &&  actualErr  !=  testCase . expectedError  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 07:37:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with error \"%v\", but instead failed with error \"%v\" instead." ,  i + 1 ,  instanceType ,  testCase . expectedError ,  actualErr ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-15 05:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test passes as expected, but the output values are verified for correctness here.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  actualErr  ==  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											// Asserting whether the md5 output is correct.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-15 03:05:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  expectedMD5 ,  ok  :=  testCase . inputMeta [ "etag" ] ;  ok  &&  expectedMD5  !=  objInfo . ETag  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Calculated Md5 different from the actual one %s." ,  i + 1 ,  instanceType ,  objInfo . ETag ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-15 05:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												continue 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling PutObject tests for both Erasure multiple disks case
  
						 
					
						
							
								
									
										
										
										
											2016-06-28 14:54:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// when quorum is not available.
  
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  TestObjectAPIPutObjectDiskNotFound ( t  * testing . T )  {  
						 
					
						
							
								
									
										
										
										
											2017-03-08 06:48:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExecObjectLayerDiskAlteredTest ( t ,  testObjectAPIPutObjectDiskNotFound ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Tests validate correctness of PutObject.
  
						 
					
						
							
								
									
										
										
										
											2017-03-08 06:48:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  testObjectAPIPutObjectDiskNotFound ( obj  ObjectLayer ,  instanceType  string ,  disks  [ ] string ,  t  * testing . T )  {  
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Generating cases for which the PutObject fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucket  :=  "minio-bucket" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									object  :=  "minio-object" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucket ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create newbucket, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Creating a dummy bucket for tests.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  =  obj . MakeBucketWithLocation ( context . Background ( ) ,  "unused-bucket" ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create newbucket, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 04:08:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Take 4 disks down, 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-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									testCases  :=  [ ] struct  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										bucketName      string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objName         string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										inputData       [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										inputMeta       map [ string ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										intputDataSize  int64 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// flag indicating whether the test should pass.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shouldPass  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// expected error output.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedMd5    string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedError  error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Validating for success cases.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-15 03:05:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "abcd" ) ,  map [ string ] string { "etag" :  "e2fc714c4727ee9395f324cd2e7f331f" } ,  int64 ( len ( "abcd" ) ) ,  true ,  "" ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "efgh" ) ,  map [ string ] string { "etag" :  "1f7690ebdd9b4caf8fab49ca1757bf27" } ,  int64 ( len ( "efgh" ) ) ,  true ,  "" ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "ijkl" ) ,  map [ string ] string { "etag" :  "09a0877d04abf8759f99adec02baf579" } ,  int64 ( len ( "ijkl" ) ) ,  true ,  "" ,  nil } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ bucket ,  object ,  [ ] byte ( "mnop" ) ,  map [ string ] string { "etag" :  "e132e96a5ddad6da8b07bba6f6131fef" } ,  int64 ( len ( "mnop" ) ) ,  true ,  "" ,  nil } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									sha256sum  :=  "" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  i ,  testCase  :=  range  testCases  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										objInfo ,  actualErr  :=  obj . PutObject ( context . Background ( ) ,  testCase . bucketName ,  testCase . objName ,  mustGetPutObjReader ( t ,  bytes . NewReader ( testCase . inputData ) ,  testCase . intputDataSize ,  testCase . inputMeta [ "etag" ] ,  sha256sum ) ,  ObjectOptions { UserDefined :  testCase . inputMeta } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  actualErr  !=  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to pass, but failed with: <ERROR> %s." ,  i + 1 ,  instanceType ,  actualErr . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  actualErr  ==  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with <ERROR> \"%s\", but passed instead." ,  i + 1 ,  instanceType ,  testCase . expectedError . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed as expected, but does it fail for the expected reason.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  actualErr  !=  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  testCase . expectedError . Error ( )  !=  actualErr . Error ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead." ,  i + 1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													instanceType ,  testCase . expectedError . Error ( ) ,  actualErr . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Test passes as expected, but the output values are verified for correctness here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  actualErr  ==  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Asserting whether the md5 output is correct.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-15 03:05:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  testCase . inputMeta [ "etag" ]  !=  objInfo . ETag  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												t . Errorf ( "Test %d: %s: Calculated Md5 different from the actual one %s." ,  i + 1 ,  instanceType ,  objInfo . ETag ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// This causes quorum failure verify.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-13 10:25:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									os . RemoveAll ( disks [ len ( disks ) - 1 ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Validate the last test.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									testCase  :=  struct  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										bucketName      string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										objName         string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										inputData       [ ] byte 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										inputMeta       map [ string ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										intputDataSize  int64 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										// flag indicating whether the test should pass.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shouldPass  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// expected error output.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedMd5    string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										expectedError  error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bucket , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										object , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 04:15:54 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										[ ] byte ( "mnop" ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-15 03:05:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										map [ string ] string { "etag" :  "e132e96a5ddad6da8b07bba6f6131fef" } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										int64 ( len ( "mnop" ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										"" , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 01:12:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										errErasureWriteQuorum , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  actualErr  :=  obj . PutObject ( context . Background ( ) ,  testCase . bucketName ,  testCase . objName ,  mustGetPutObjReader ( t ,  bytes . NewReader ( testCase . inputData ) ,  testCase . intputDataSize ,  testCase . inputMeta [ "etag" ] ,  sha256sum ) ,  ObjectOptions { UserDefined :  testCase . inputMeta } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  actualErr  !=  nil  &&  testCase . shouldPass  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Errorf ( "Test %d: %s: Expected to pass, but failed with: <ERROR> %s." ,  len ( testCases ) + 1 ,  instanceType ,  actualErr . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Failed as expected, but does it fail for the expected reason.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  actualErr  !=  nil  &&  ! testCase . shouldPass  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 01:12:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ! errors . Is ( actualErr ,  testCase . expectedError )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 01:01:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead." ,  len ( testCases ) + 1 ,  instanceType ,  testCase . expectedError . Error ( ) ,  actualErr . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling PutObject tests for both Erasure multiple disks and single node setup.
  
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  TestObjectAPIPutObjectStaleFiles ( t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerStaleFilesTest ( t ,  testObjectAPIPutObjectStaleFiles ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Tests validate correctness of PutObject.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  testObjectAPIPutObjectStaleFiles ( obj  ObjectLayer ,  instanceType  string ,  disks  [ ] string ,  t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Generating cases for which the PutObject fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucket  :=  "minio-bucket" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									object  :=  "minio-object" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucket ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create newbucket, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									data  :=  [ ] byte ( "hello, world" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create object.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObject ( context . Background ( ) ,  bucket ,  object ,  mustGetPutObjReader ( t ,  bytes . NewReader ( data ) ,  int64 ( len ( data ) ) ,  "" ,  "" ) ,  ObjectOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create object, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  disk  :=  range  disks  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-21 06:25:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										tmpMetaDir  :=  path . Join ( disk ,  minioMetaTmpBucket ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-27 01:52:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										files ,  err  :=  ioutil . ReadDir ( tmpMetaDir ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Fatal ( err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  found  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  fi  :=  range  files  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  fi . Name ( )  ==  ".trash"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											found  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  found  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Fatalf ( "%s: expected: empty, got: non-empty %#v" ,  minioMetaTmpBucket ,  files ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Wrapper for calling Multipart PutObject tests for both Erasure multiple disks and single node setup.
  
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  TestObjectAPIMultipartPutObjectStaleFiles ( t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExecObjectLayerStaleFilesTest ( t ,  testObjectAPIMultipartPutObjectStaleFiles ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Tests validate correctness of PutObject.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  testObjectAPIMultipartPutObjectStaleFiles ( obj  ObjectLayer ,  instanceType  string ,  disks  [ ] string ,  t  * testing . T )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Generating cases for which the PutObject fails.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bucket  :=  "minio-bucket" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									object  :=  "minio-object" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  :=  obj . MakeBucketWithLocation ( context . Background ( ) ,  bucket ,  BucketOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create newbucket, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 00:42:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									opts  :=  ObjectOptions { } 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Initiate Multipart Upload on the above created bucket.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-09 13:31:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uploadID ,  err  :=  obj . NewMultipartUpload ( context . Background ( ) ,  bucket ,  object ,  opts ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to create NewMultipartUpload, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Upload part1.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									fiveMBBytes  :=  bytes . Repeat ( [ ] byte ( "a" ) ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									md5Writer  :=  md5 . New ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									md5Writer . Write ( fiveMBBytes ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									etag1  :=  hex . EncodeToString ( md5Writer . Sum ( nil ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-03 06:51:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									sha256sum  :=  "" 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-15 09:36:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObjectPart ( context . Background ( ) ,  bucket ,  object ,  uploadID ,  1 ,  mustGetPutObjReader ( t ,  bytes . NewReader ( fiveMBBytes ) ,  int64 ( len ( fiveMBBytes ) ) ,  etag1 ,  sha256sum ) ,  opts ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to upload object part, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Upload part2.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									data  :=  [ ] byte ( "hello, world" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									md5Writer  =  md5 . New ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									md5Writer . Write ( data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									etag2  :=  hex . EncodeToString ( md5Writer . Sum ( nil ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-15 09:36:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . PutObjectPart ( context . Background ( ) ,  bucket ,  object ,  uploadID ,  2 ,  mustGetPutObjReader ( t ,  bytes . NewReader ( data ) ,  int64 ( len ( data ) ) ,  etag2 ,  sha256sum ) ,  opts ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to upload object part, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Complete multipart.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-14 16:25:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									parts  :=  [ ] CompletePart { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ ETag :  etag1 ,  PartNumber :  1 } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ ETag :  etag2 ,  PartNumber :  2 } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-15 09:36:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  err  =  obj . CompleteMultipartUpload ( context . Background ( ) ,  bucket ,  object ,  uploadID ,  parts ,  ObjectOptions { } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Failed to complete multipart upload, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										t . Fatalf ( "%s : %s" ,  instanceType ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  disk  :=  range  disks  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-21 06:25:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										tmpMetaDir  :=  path . Join ( disk ,  minioMetaTmpBucket ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										files ,  err  :=  ioutil . ReadDir ( tmpMetaDir ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Its OK to have non-existen tmpMetaDir.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 00:36:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  osIsNotExist ( err )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Print the error
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Errorf ( "%s" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-27 01:52:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  found  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  fi  :=  range  files  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  fi . Name ( )  ==  ".trash"  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											found  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  found  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											t . Fatalf ( "%s: expected: empty, got: non-empty. content: %#v" ,  tmpMetaDir ,  files ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 17:28:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Benchmarks for ObjectLayer.PutObject().
  
						 
					
						
							
								
									
										
										
										
											2016-08-15 17:44:48 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// The intent is to benchmark PutObject 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 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObjectVerySmallFS - Benchmark FS.PutObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObjectVerySmallFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObjectVerySmallErasure - Benchmark Erasure.PutObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObjectVerySmallErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject10KbFS - Benchmark FS.PutObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject10KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject10KbErasure - Benchmark Erasure.PutObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject10KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject100KbFS - Benchmark FS.PutObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject100KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject100KbErasure - Benchmark Erasure.PutObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject100KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject1MbFS - Benchmark FS.PutObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject1MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject1MbErasure - Benchmark Erasure.PutObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject1MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject5MbFS - Benchmark FS.PutObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject5MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject5MbErasure - Benchmark Erasure.PutObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject5MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject10MbFS - Benchmark FS.PutObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject10MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject10MbErasure - Benchmark Erasure.PutObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject10MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject25MbFS - Benchmark FS.PutObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject25MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject25MbErasure - Benchmark Erasure.PutObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject25MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "Erasure" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkPutObject50MbFS - Benchmark FS.PutObject() for object size of 50MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject50MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObject ( b ,  "FS" ,  50 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-09 15:45:49 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkPutObject50MbErasure - Benchmark Erasure.PutObject() for object size of 50MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkPutObject50MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObject ( 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.PutObject() .
  
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObjectVerySmallFS - BenchmarkParallel FS.PutObject() for object size of 10 bytes.
  
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObjectVerySmallFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-07-22 02:17:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObjectVerySmallErasure - BenchmarkParallel Erasure.PutObject() for object size of 10 bytes.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObjectVerySmallErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject10KbFS - BenchmarkParallel FS.PutObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject10KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject10KbErasure - BenchmarkParallel Erasure.PutObject() for object size of 10KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject10KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  10 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject100KbFS - BenchmarkParallel FS.PutObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject100KbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject100KbErasure - BenchmarkParallel Erasure.PutObject() for object size of 100KB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject100KbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  100 * humanize . KiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject1MbFS - BenchmarkParallel FS.PutObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject1MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject1MbErasure - BenchmarkParallel Erasure.PutObject() for object size of 1MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject1MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  1 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject5MbFS - BenchmarkParallel FS.PutObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject5MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject5MbErasure - BenchmarkParallel Erasure.PutObject() for object size of 5MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject5MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  5 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject10MbFS - BenchmarkParallel FS.PutObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject10MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject10MbErasure - BenchmarkParallel Erasure.PutObject() for object size of 10MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject10MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  10 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject25MbFS - BenchmarkParallel FS.PutObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject25MbFS ( b  * testing . B )  {  
						 
					
						
							
								
									
										
										
										
											2016-11-23 10:18:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "FS" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// BenchmarkParallelPutObject25MbErasure - BenchmarkParallel Erasure.PutObject() for object size of 25MB.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  BenchmarkParallelPutObject25MbErasure ( b  * testing . B )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									benchmarkPutObjectParallel ( b ,  "Erasure" ,  25 * humanize . MiByte ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-11 02:08:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}