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

Function testReplaceObjectWithChecksums

functional_tests.go:9348–9468  ·  view source on GitHub ↗

Tests replacing an object with CopyObject and a new Checksum type

()

Source from the content-addressed store, hash-verified

9346
9347// Tests replacing an object with CopyObject and a new Checksum type
9348func testReplaceObjectWithChecksums() {
9349 startTime := time.Now()
9350 testName := getFuncName()
9351 function := "CopyObjectWithChecksums(destination, source)"
9352 args := map[string]interface{}{}
9353
9354 c, err := NewClient(ClientConfig{CredsV2: true})
9355 if err != nil {
9356 logError(testName, function, args, startTime, "", "MinIO v2 client object creation failed", err)
9357 return
9358 }
9359
9360 // Generate a new random bucket name.
9361 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
9362
9363 // Make a new bucket in 'us-east-1' (source bucket).
9364 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
9365 if err != nil {
9366 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
9367 return
9368 }
9369 defer cleanupBucket(bucketName, c)
9370
9371 tests := []struct {
9372 csType minio.ChecksumType
9373 cs wantChecksums
9374 }{
9375 {csType: minio.ChecksumCRC64NVME, cs: wantChecksums{minio.ChecksumCRC64NVME: "iRtfQH3xflQ="}},
9376 {csType: minio.ChecksumCRC32C, cs: wantChecksums{minio.ChecksumCRC32C: "aHnJMw=="}},
9377 {csType: minio.ChecksumCRC32, cs: wantChecksums{minio.ChecksumCRC32: "tIZ8hA=="}},
9378 {csType: minio.ChecksumSHA1, cs: wantChecksums{minio.ChecksumSHA1: "6YIIbcWH1iLaCFqs5vwq5Rwvm+o="}},
9379 {csType: minio.ChecksumSHA256, cs: wantChecksums{minio.ChecksumSHA256: "GKeJTopbMGPs3h4fAw4oe0R2QnnmFVJeIWkqCkp28Yo="}},
9380 // In S3, all copied objects without checksums and specified destination checksum algorithms
9381 // automatically gain a CRC-64NVME checksum algorithm. Use ChecksumNone for this case.
9382 {csType: minio.ChecksumNone, cs: wantChecksums{minio.ChecksumCRC64NVME: "iRtfQH3xflQ="}},
9383 }
9384
9385 for _, test := range tests {
9386 args := map[string]interface{}{}
9387 args["section"] = "setup"
9388 args["destOpts"] = ""
9389 args["checksum"] = test.csType.String()
9390
9391 bufSize := dataFileMap["datafile-33-kB"]
9392 reader := getDataReader("datafile-33-kB")
9393 defer reader.Close()
9394
9395 // PutObject to upload the object to the bucket
9396 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
9397 _, err = c.PutObject(context.Background(), bucketName, objectName, reader, int64(bufSize), minio.PutObjectOptions{ContentType: "binary/octet-stream"})
9398 if err != nil {
9399 logError(testName, function, args, startTime, "", "PutObject failed", err)
9400 return
9401 }
9402 // GetObject to obtain the eTag
9403 r, err := c.GetObject(context.Background(), bucketName, objectName, minio.GetObjectOptions{})
9404 if err != nil {
9405 logError(testName, function, args, startTime, "", "GetObject failed", err)

Callers 1

mainFunction · 0.85

Calls 15

MakeBucketMethod · 0.95
PutObjectMethod · 0.95
GetObjectMethod · 0.95
CopyObjectMethod · 0.95
StatObjectMethod · 0.95
getFuncNameFunction · 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