MCPcopy
hub / github.com/minio/minio-go / testTrailingChecksums

Function testTrailingChecksums

functional_tests.go:2953–3160  ·  view source on GitHub ↗

Test PutObject with trailing checksums.

()

Source from the content-addressed store, hash-verified

2951
2952// Test PutObject with trailing checksums.
2953func testTrailingChecksums() {
2954 // initialize logging params
2955 startTime := time.Now()
2956 testName := getFuncName()
2957 function := "PutObject(bucketName, objectName, reader,size, opts)"
2958 args := map[string]interface{}{
2959 "bucketName": "",
2960 "objectName": "",
2961 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Progress: progress}",
2962 }
2963
2964 if !isFullMode() {
2965 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
2966 return
2967 }
2968
2969 c, err := NewClient(ClientConfig{TrailingHeaders: true})
2970 if err != nil {
2971 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
2972 return
2973 }
2974
2975 // Generate a new random bucket name.
2976 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
2977 args["bucketName"] = bucketName
2978
2979 // Make a new bucket.
2980 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
2981 if err != nil {
2982 logError(testName, function, args, startTime, "", "Make bucket failed", err)
2983 return
2984 }
2985
2986 hashMultiPart := func(b []byte, partSize int, hasher hash.Hash) (oparts []minio.ObjectPart) {
2987 r := bytes.NewReader(b)
2988 tmp := make([]byte, partSize)
2989 parts := 0
2990 for {
2991 n, err := io.ReadFull(r, tmp)
2992 if err != nil && err != io.ErrUnexpectedEOF {
2993 logError(testName, function, args, startTime, "", "Calc crc failed", err)
2994 }
2995 if n == 0 {
2996 break
2997 }
2998 parts++
2999 hasher.Reset()
3000 hasher.Write(tmp[:n])
3001 oparts = append(oparts, minio.ObjectPart{
3002 PartNumber: parts,
3003 Size: int64(n),
3004 ChecksumCRC32C: base64.StdEncoding.EncodeToString(hasher.Sum(nil)),
3005 })
3006 if err != nil {
3007 break
3008 }
3009 }
3010 return oparts

Callers 1

mainFunction · 0.85

Calls 15

MakeBucketMethod · 0.95
PutObjectMethod · 0.95
GetObjectMethod · 0.95
getFuncNameFunction · 0.85
isFullModeFunction · 0.85
logIgnoredFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85
getDataReaderFunction · 0.85
cmpChecksumFunction · 0.85
logSuccessFunction · 0.85

Tested by

no test coverage detected