Browse Source

update batch

tags/v0.7.3
jojoliang 5 years ago
parent
commit
699fef2159
  1. 20
      batch_test.go
  2. 6
      costesting/ci_test.go
  3. 9
      example/batch/create_job.go

20
batch_test.go

@ -8,7 +8,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/uuid"
"github.com/google/uuid"
) )
func TestBatchService_CreateJob(t *testing.T) { func TestBatchService_CreateJob(t *testing.T) {
@ -21,7 +21,7 @@ func TestBatchService_CreateJob(t *testing.T) {
Manifest: &BatchJobManifest{ Manifest: &BatchJobManifest{
Location: &BatchJobManifestLocation{ Location: &BatchJobManifestLocation{
ETag: "15150651828fa9cdcb8356b6d1c7638b", ETag: "15150651828fa9cdcb8356b6d1c7638b",
ObjectArn: "qcs::cos:ap-chengdu::sourcebucket-1250000000/manifests/batch-copy-manifest.csv",
ObjectArn: "qcs::cos:ap-chengdu:uid/1250000000:sourcebucket-1250000000/manifests/batch-copy-manifest.csv",
}, },
Spec: &BatchJobManifestSpec{ Spec: &BatchJobManifestSpec{
Fields: []string{"Bucket", "Key"}, Fields: []string{"Bucket", "Key"},
@ -30,12 +30,12 @@ func TestBatchService_CreateJob(t *testing.T) {
}, },
Operation: &BatchJobOperation{ Operation: &BatchJobOperation{
PutObjectCopy: &BatchJobOperationCopy{ PutObjectCopy: &BatchJobOperationCopy{
TargetResource: "qcs::cos:ap-chengdu::destinationbucket-1250000000",
TargetResource: "qcs::cos:ap-chengdu:uid/1250000000:destinationbucket-1250000000",
}, },
}, },
Priority: 1, Priority: 1,
Report: &BatchJobReport{ Report: &BatchJobReport{
Bucket: "qcs::cos:ap-chengdu::sourcebucket-1250000000",
Bucket: "qcs::cos:ap-chengdu:uid/1250000000:sourcebucket-1250000000",
Enabled: "true", Enabled: "true",
Format: "Report_CSV_V1", Format: "Report_CSV_V1",
Prefix: "job-result", Prefix: "job-result",
@ -104,7 +104,7 @@ func TestBatchService_DescribeJob(t *testing.T) {
<Manifest> <Manifest>
<Location> <Location>
<ETag>&quot;15150651828fa9cdcb8356b6d1c7638b&quot;</ETag> <ETag>&quot;15150651828fa9cdcb8356b6d1c7638b&quot;</ETag>
<ObjectArn>qcs::cos:ap-chengdu::sourcebucket-1250000000/manifests/batch-copy-manifest.csv</ObjectArn>
<ObjectArn>qcs::cos:ap-chengdu:uid/1250000000:sourcebucket-1250000000/manifests/batch-copy-manifest.csv</ObjectArn>
</Location> </Location>
<Spec> <Spec>
<Fields> <Fields>
@ -116,7 +116,7 @@ func TestBatchService_DescribeJob(t *testing.T) {
</Manifest> </Manifest>
<Operation> <Operation>
<COSPutObjectCopy> <COSPutObjectCopy>
<TargetResource>qcs::cos:ap-chengdu::destinationbucket-1250000000</TargetResource>
<TargetResource>qcs::cos:ap-chengdu:uid/1250000000:destinationbucket-1250000000</TargetResource>
</COSPutObjectCopy> </COSPutObjectCopy>
</Operation> </Operation>
<Priority>10</Priority> <Priority>10</Priority>
@ -126,7 +126,7 @@ func TestBatchService_DescribeJob(t *testing.T) {
<TotalNumberOfTasks>10</TotalNumberOfTasks> <TotalNumberOfTasks>10</TotalNumberOfTasks>
</ProgressSummary> </ProgressSummary>
<Report> <Report>
<Bucket>qcs::cos:ap-chengdu::sourcebucket-1250000000</Bucket>
<Bucket>qcs::cos:ap-chengdu:uid/1250000000:sourcebucket-1250000000</Bucket>
<Enabled>true</Enabled> <Enabled>true</Enabled>
<Format>Report_CSV_V1</Format> <Format>Report_CSV_V1</Format>
<Prefix>job-result</Prefix> <Prefix>job-result</Prefix>
@ -159,7 +159,7 @@ func TestBatchService_DescribeJob(t *testing.T) {
Manifest: &BatchJobManifest{ Manifest: &BatchJobManifest{
Location: &BatchJobManifestLocation{ Location: &BatchJobManifestLocation{
ETag: "\"15150651828fa9cdcb8356b6d1c7638b\"", ETag: "\"15150651828fa9cdcb8356b6d1c7638b\"",
ObjectArn: "qcs::cos:ap-chengdu::sourcebucket-1250000000/manifests/batch-copy-manifest.csv",
ObjectArn: "qcs::cos:ap-chengdu:uid/1250000000:sourcebucket-1250000000/manifests/batch-copy-manifest.csv",
}, },
Spec: &BatchJobManifestSpec{ Spec: &BatchJobManifestSpec{
Fields: []string{"Bucket", "Key"}, Fields: []string{"Bucket", "Key"},
@ -168,7 +168,7 @@ func TestBatchService_DescribeJob(t *testing.T) {
}, },
Operation: &BatchJobOperation{ Operation: &BatchJobOperation{
PutObjectCopy: &BatchJobOperationCopy{ PutObjectCopy: &BatchJobOperationCopy{
TargetResource: "qcs::cos:ap-chengdu::destinationbucket-1250000000",
TargetResource: "qcs::cos:ap-chengdu:uid/1250000000:destinationbucket-1250000000",
}, },
}, },
Priority: 10, Priority: 10,
@ -178,7 +178,7 @@ func TestBatchService_DescribeJob(t *testing.T) {
TotalNumberOfTasks: 10, TotalNumberOfTasks: 10,
}, },
Report: &BatchJobReport{ Report: &BatchJobReport{
Bucket: "qcs::cos:ap-chengdu::sourcebucket-1250000000",
Bucket: "qcs::cos:ap-chengdu:uid/1250000000:sourcebucket-1250000000",
Enabled: "true", Enabled: "true",
Format: "Report_CSV_V1", Format: "Report_CSV_V1",
Prefix: "job-result", Prefix: "job-result",

6
costesting/ci_test.go

@ -751,7 +751,7 @@ func (s *CosTestSuite) TestBatch() {
Manifest: &cos.BatchJobManifest{ Manifest: &cos.BatchJobManifest{
Location: &cos.BatchJobManifestLocation{ Location: &cos.BatchJobManifestLocation{
ETag: etag, ETag: etag,
ObjectArn: "qcs::cos:" + kBatchRegion + "::" + kBatchBucket + "/" + manifest_name,
ObjectArn: "qcs::cos:" + kBatchRegion + ":uid/" + s.Appid + ":" + kBatchBucket + "/" + manifest_name,
}, },
Spec: &cos.BatchJobManifestSpec{ Spec: &cos.BatchJobManifestSpec{
Fields: []string{"Bucket", "Key"}, Fields: []string{"Bucket", "Key"},
@ -760,12 +760,12 @@ func (s *CosTestSuite) TestBatch() {
}, },
Operation: &cos.BatchJobOperation{ Operation: &cos.BatchJobOperation{
PutObjectCopy: &cos.BatchJobOperationCopy{ PutObjectCopy: &cos.BatchJobOperationCopy{
TargetResource: "qcs::cos:" + kBatchRegion + "::" + kTargetBatchBucket,
TargetResource: "qcs::cos:" + kBatchRegion + ":uid/" + s.Appid + ":" + kTargetBatchBucket,
}, },
}, },
Priority: 1, Priority: 1,
Report: &cos.BatchJobReport{ Report: &cos.BatchJobReport{
Bucket: "qcs::cos:" + kBatchRegion + "::" + kBatchBucket,
Bucket: "qcs::cos:" + kBatchRegion + ":uid/" + s.Appid + ":" + kBatchBucket,
Enabled: "true", Enabled: "true",
Format: "Report_CSV_V1", Format: "Report_CSV_V1",
Prefix: "job-result", Prefix: "job-result",

9
example/batch/create_job.go

@ -2,20 +2,21 @@ package main
import ( import (
"context" "context"
"fmt"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"strconv"
"strings" "strings"
"fmt"
"github.com/google/uuid"
"github.com/tencentyun/cos-go-sdk-v5" "github.com/tencentyun/cos-go-sdk-v5"
"github.com/tencentyun/cos-go-sdk-v5/debug" "github.com/tencentyun/cos-go-sdk-v5/debug"
"github.com/google/uuid"
) )
func main() { func main() {
test_batch_bucket := "testcd-1259654469" test_batch_bucket := "testcd-1259654469"
target_batch_bucket := "targetcd-1259654469"
target_batch_bucket := "cosgosdkreptest-1259654469"
appid := 1259654469 appid := 1259654469
uin := "100010805041" uin := "100010805041"
region := "ap-chengdu" region := "ap-chengdu"
@ -73,7 +74,7 @@ func main() {
}, },
Operation: &cos.BatchJobOperation{ Operation: &cos.BatchJobOperation{
PutObjectCopy: &cos.BatchJobOperationCopy{ PutObjectCopy: &cos.BatchJobOperationCopy{
TargetResource: "qcs::cos:" + region + "::" + target_batch_bucket,
TargetResource: "qcs::cos:" + region + ":uid/" + strconv.Itoa(appid) + ":" + target_batch_bucket,
}, },
}, },
Priority: 1, Priority: 1,

Loading…
Cancel
Save