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

Function testTrailingChecksums

functional_tests.go:2849–3056  ·  view source on GitHub ↗

Test PutObject with trailing checksums.

()

Source from the content-addressed store, hash-verified

2847
2848// Test PutObject with trailing checksums.
2849func testTrailingChecksums() {
2850 // initialize logging params
2851 startTime := time.Now()
2852 testName := getFuncName()
2853 function := "PutObject(bucketName, objectName, reader,size, opts)"
2854 args := map[string]interface{}{
2855 "bucketName": "",
2856 "objectName": "",
2857 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Progress: progress}",
2858 }
2859
2860 if !isFullMode() {
2861 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
2862 return
2863 }
2864
2865 c, err := NewClient(ClientConfig{TrailingHeaders: true})
2866 if err != nil {
2867 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
2868 return
2869 }
2870
2871 // Generate a new random bucket name.
2872 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
2873 args["bucketName"] = bucketName
2874
2875 // Make a new bucket.
2876 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
2877 if err != nil {
2878 logError(testName, function, args, startTime, "", "Make bucket failed", err)
2879 return
2880 }
2881
2882 hashMultiPart := func(b []byte, partSize int, hasher hash.Hash) (oparts []minio.ObjectPart) {
2883 r := bytes.NewReader(b)
2884 tmp := make([]byte, partSize)
2885 parts := 0
2886 for {
2887 n, err := io.ReadFull(r, tmp)
2888 if err != nil && err != io.ErrUnexpectedEOF {
2889 logError(testName, function, args, startTime, "", "Calc crc failed", err)
2890 }
2891 if n == 0 {
2892 break
2893 }
2894 parts++
2895 hasher.Reset()
2896 hasher.Write(tmp[:n])
2897 oparts = append(oparts, minio.ObjectPart{
2898 PartNumber: parts,
2899 Size: int64(n),
2900 ChecksumCRC32C: base64.StdEncoding.EncodeToString(hasher.Sum(nil)),
2901 })
2902 if err != nil {
2903 break
2904 }
2905 }
2906 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