Skip to content

Commit b286031

Browse files
committed
5.0 API and updated tests
1 parent a984d37 commit b286031

File tree

83 files changed

+679
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+679
-237
lines changed

ds3/ds3Client_test.go

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ func TestGetObjectRange(t *testing.T) {
387387
func TestGetObjectsDetailsSpectraS3(t *testing.T) {
388388
bucketId := "a24d14f3-e2f0-4bfb-ab71-f99d5ef43745"
389389
stringResponse := "<Data><S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.694Z</CreationDate><Id>e37c3ce0-12aa-4f54-87e3-42532aca0e5e</Id><Name>beowulf.txt</Name><Type>DATA</Type><Version>1</Version></S3Object>" +
390-
"<S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.779Z</CreationDate><Id>dc628815-c723-4c4e-b68b-5f5d10f38af5</Id><Name>sherlock_holmes.txt</Name><Type>DATA</Type><Version>1</Version></S3Object>" +
391-
"<S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.772Z</CreationDate><Id>4f6985fd-fbae-4421-ba27-66fdb96187c5</Id><Name>tale_of_two_cities.txt</Name><Type>DATA</Type><Version>1</Version></S3Object>" +
392-
"<S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.696Z</CreationDate><Id>82c18910-fadb-4461-a152-bf714ae91b55</Id><Name>ulysses.txt</Name><Type>DATA</Type><Version>1</Version></S3Object></Data>"
390+
"<S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.779Z</CreationDate><Id>dc628815-c723-4c4e-b68b-5f5d10f38af5</Id><Name>sherlock_holmes.txt</Name><Type>DATA</Type></S3Object>" +
391+
"<S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.772Z</CreationDate><Id>4f6985fd-fbae-4421-ba27-66fdb96187c5</Id><Name>tale_of_two_cities.txt</Name><Type>DATA</Type></S3Object>" +
392+
"<S3Object><BucketId>a24d14f3-e2f0-4bfb-ab71-f99d5ef43745</BucketId><CreationDate>2015-09-21T20:06:47.696Z</CreationDate><Id>82c18910-fadb-4461-a152-bf714ae91b55</Id><Name>ulysses.txt</Name><Type>DATA</Type></S3Object></Data>"
393393

394394
request := models.NewGetObjectsDetailsSpectraS3Request().WithBucketId(bucketId)
395395

@@ -428,7 +428,6 @@ func TestGetObjectsDetailsSpectraS3(t *testing.T) {
428428
if object.Type != models.S3_OBJECT_TYPE_DATA {
429429
t.Fatalf("Expected type of '%d' but was '%d'.", models.S3_OBJECT_TYPE_DATA, object.Type)
430430
}
431-
ds3Testing.AssertInt64(t, "Version", 1, object.Version)
432431
}
433432
}
434433

@@ -1528,6 +1527,27 @@ func TestClearSuspectBlobS3TargetsSpectraS3(t *testing.T) {
15281527
}
15291528
}
15301529

1530+
1531+
func TestClearSuspectBlobDs3TargetsSpectraS3(t *testing.T) {
1532+
expectedRequest := "<Ids><Id>id1</Id><Id>id2</Id><Id>id3</Id></Ids>"
1533+
1534+
// Create and run the mocked client.
1535+
ids := []string {"id1", "id2", "id3"}
1536+
1537+
response, err := mockedClient(t).
1538+
Expecting(HTTP_VERB_DELETE, "/_rest_/suspect_blob_ds3_target", &url.Values{}, &http.Header{}, &expectedRequest).
1539+
Returning(204, "", nil).
1540+
ClearSuspectBlobDs3TargetsSpectraS3(models.NewClearSuspectBlobDs3TargetsSpectraS3Request(ids))
1541+
1542+
// Check the error result.
1543+
ds3Testing.AssertNilError(t, err)
1544+
1545+
// Check the response value.
1546+
if response == nil {
1547+
t.Fatalf("Response was unexpectedly nil.")
1548+
}
1549+
}
1550+
15311551
func TestClearSuspectBlobTapesSpectraS3(t *testing.T) {
15321552
expectedRequest := "<Ids><Id>id1</Id><Id>id2</Id><Id>id3</Id></Ids>"
15331553

@@ -1560,13 +1580,13 @@ func TestEjectStorageDomainBlobsSpectraS3(t *testing.T) {
15601580
"operation": []string{"eject"},
15611581
"blobs": []string{""},
15621582
"bucket_id": []string{bucketId},
1563-
"storage_domain_id": []string{storageDomainId},
1583+
"storage_domain": []string{storageDomainId},
15641584
}
15651585

15661586
response, err := mockedClient(t).
15671587
Expecting(HTTP_VERB_PUT, "/_rest_/tape", qp, &http.Header{}, &expectedRequest).
15681588
Returning(204, "", nil).
1569-
EjectStorageDomainBlobsSpectraS3(models.NewEjectStorageDomainBlobsSpectraS3Request(bucketId, objectNames, storageDomainId))
1589+
EjectStorageDomainBlobsSpectraS3(models.NewEjectStorageDomainBlobsSpectraS3Request(bucketId, storageDomainId, objectNames))
15701590

15711591
// Check the error result.
15721592
ds3Testing.AssertNilError(t, err)
@@ -1640,7 +1660,7 @@ func TestGetBlobsOnTapeSpectraS3(t *testing.T) {
16401660
type getBlobsTest func(*Client) (models.BulkObjectList, error)
16411661

16421662
func runGetBlobsTest(t *testing.T, path string, callToTest getBlobsTest) {
1643-
expectedResponse := "<Data><Object Bucket=\"default_bucket_name\" Id=\"1bd77dbf-500a-45a1-86ac-d065f026882c\" Latest=\"true\" Length=\"10\" Name=\"obj1\" Offset=\"0\" Version=\"1\"/><Object Bucket=\"default_bucket_name\" Id=\"9afa66e7-3f5a-4913-bae2-ba7c86e4c4f7\" Latest=\"true\" Length=\"10\" Name=\"obj2\" Offset=\"0\" Version=\"1\"/></Data>"
1663+
expectedResponse := "<Data><Object Bucket=\"default_bucket_name\" Id=\"1bd77dbf-500a-45a1-86ac-d065f026882c\" Latest=\"true\" Length=\"10\" Name=\"obj1\" Offset=\"0\" /><Object Bucket=\"default_bucket_name\" Id=\"9afa66e7-3f5a-4913-bae2-ba7c86e4c4f7\" Latest=\"true\" Length=\"10\" Name=\"obj2\" Offset=\"0\" /></Data>"
16441664

16451665
// Create and run the mocked client.
16461666
qp := &url.Values{ "operation": []string{"get_physical_placement"} }
@@ -1662,7 +1682,6 @@ func runGetBlobsTest(t *testing.T, path string, callToTest getBlobsTest) {
16621682
ds3Testing.AssertInt64(t, "Length", 10, obj1.Length)
16631683
ds3Testing.AssertNonNilStringPtr(t, "Name", "obj1", obj1.Name)
16641684
ds3Testing.AssertInt64(t, "Offset", 0, obj1.Offset)
1665-
ds3Testing.AssertInt64(t, "Version", 1, obj1.Version)
16661685
if obj1.PhysicalPlacement != nil {
16671686
t.Fatalf("Expected nil Physical Placement, but was '%v'.", obj1.PhysicalPlacement)
16681687
}
@@ -1675,7 +1694,6 @@ func runGetBlobsTest(t *testing.T, path string, callToTest getBlobsTest) {
16751694
ds3Testing.AssertInt64(t, "Length", 10, obj2.Length)
16761695
ds3Testing.AssertNonNilStringPtr(t, "Name", "obj2", obj2.Name)
16771696
ds3Testing.AssertInt64(t, "Offset", 0, obj2.Offset)
1678-
ds3Testing.AssertInt64(t, "Version", 1, obj2.Version)
16791697
if obj2.PhysicalPlacement != nil {
16801698
t.Fatalf("Expected nil Physical Placement, but was '%v'.", obj2.PhysicalPlacement)
16811699
}
@@ -1865,7 +1883,6 @@ func TestVerifyPhysicalPlacementForObjectsWithFullDetailsSpectraS3(t *testing.T)
18651883
ds3Testing.AssertInt64(t, "Length", 10, object.Length)
18661884
ds3Testing.AssertNonNilStringPtr(t, "Name", "o1", object.Name)
18671885
ds3Testing.AssertInt64(t, "Offset", 0, object.Offset)
1868-
ds3Testing.AssertInt64(t, "Version", 1, object.Version)
18691886
if object.PhysicalPlacement == nil {
18701887
t.Fatal("Expected PhysicalPlacement to not be nil")
18711888
}
@@ -1902,7 +1919,7 @@ func TestVerifyPhysicalPlacementForObjectsWithFullDetailsSpectraS3(t *testing.T)
19021919
if tape.State != models.TAPE_STATE_PENDING_INSPECTION {
19031920
t.Fatalf("Expected tape state 'TAPE_STATE_PENDING_INSPECTION' but got '%s'.", tape.State.String())
19041921
}
1905-
ds3Testing.AssertStringPtrIsNil(t, "StorageDomainId", tape.StorageDomainId)
1922+
ds3Testing.AssertStringPtrIsNil(t, "StorageDomainId", tape.StorageDomainMemberId)
19061923
ds3Testing.AssertBool(t, "TakeOwnershipPending", false, tape.TakeOwnershipPending)
19071924
ds3Testing.AssertNonNilInt64Ptr(t, "TotalRawCapacity", 20000, tape.TotalRawCapacity)
19081925
ds3Testing.AssertString(t, "TapeType", "LTO5", tape.Type)
@@ -1939,3 +1956,29 @@ func TestHeadObject(t *testing.T) {
19391956
ds3Testing.AssertString(t, "checksum at offset '10485760'", "965Aa0/n8DlO1IwXYFh4bg==", response.BlobChecksums[10485760])
19401957
ds3Testing.AssertString(t, "checksum at offset '20971520'", "iV2OqJaXJ/jmqgRSb1HmFA==", response.BlobChecksums[20971520])
19411958
}
1959+
1960+
func TestStageObjectsJob(t *testing.T) {
1961+
expectedRequest := "<Objects><Object Name=\"o1\"></Object><Object Name=\"o2\" Length=\"10\" Offset=\"20\"></Object></Objects>"
1962+
responsePayload := "<MasterObjectList><Objects><Object Name='file2' Length='1202'/><Object Name='file1' Length='256'/><Object Name='file3' Length='2523'/></Objects></MasterObjectList>"
1963+
1964+
// Create and run the mocked client.
1965+
bucketName := "b1"
1966+
objects := []models.Ds3GetObject { models.NewDs3GetObject("o1"), models.NewPartialDs3GetObject("o2", 10, 20) }
1967+
1968+
qp := &url.Values{ "operation": []string{"start_bulk_stage"} }
1969+
1970+
response, err := mockedClient(t).
1971+
Expecting(HTTP_VERB_PUT, "/_rest_/bucket/" + bucketName, qp, &http.Header{}, &expectedRequest).
1972+
Returning(200, responsePayload, nil).
1973+
StageObjectsJobSpectraS3(models.NewStageObjectsJobSpectraS3RequestWithPartialObjects(bucketName, objects))
1974+
1975+
// Check the error result.
1976+
ds3Testing.AssertNilError(t, err)
1977+
1978+
// Check the response value.
1979+
if response == nil {
1980+
t.Fatalf("Response was unexpectedly nil.")
1981+
}
1982+
ds3Testing.AssertInt(t, "Number of objects", 1, len(response.MasterObjectList.Objects))
1983+
ds3Testing.AssertInt(t, "Number of blobs", 3, len(response.MasterObjectList.Objects[0].Objects))
1984+
}

ds3/ds3Deletes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (client *Client) DeleteObject(request *models.DeleteObjectRequest) (*models
7070
httpRequest, err := networking.NewHttpRequestBuilder().
7171
WithHttpVerb(HTTP_VERB_DELETE).
7272
WithPath("/" + request.BucketName + "/" + request.ObjectName).
73-
WithOptionalVoidQueryParam("roll_back", request.RollBack).
73+
WithOptionalQueryParam("version_id", request.VersionId).
7474
Build(client.connectionInfo)
7575

7676
if err != nil {
@@ -1016,7 +1016,6 @@ func (client *Client) DeleteFolderRecursivelySpectraS3(request *models.DeleteFol
10161016
WithPath("/_rest_/folder/" + request.Folder).
10171017
WithQueryParam("bucket_id", request.BucketId).
10181018
WithQueryParam("recursive", "").
1019-
WithOptionalVoidQueryParam("roll_back", request.RollBack).
10201019
Build(client.connectionInfo)
10211020

10221021
if err != nil {

ds3/ds3Gets.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func (client *Client) GetObject(request *models.GetObjectRequest) (*models.GetOb
2525
WithPath("/" + request.BucketName + "/" + request.ObjectName).
2626
WithOptionalQueryParam("job", request.Job).
2727
WithOptionalQueryParam("offset", networking.Int64PtrToStrPtr(request.Offset)).
28+
WithOptionalQueryParam("version_id", request.VersionId).
2829
WithChecksum(request.Checksum).
2930
WithHeaders(request.Metadata).
3031
Build(client.connectionInfo)
@@ -55,6 +56,7 @@ func (client *Client) GetBucket(request *models.GetBucketRequest) (*models.GetBu
5556
WithOptionalQueryParam("marker", request.Marker).
5657
WithOptionalQueryParam("max_keys", networking.IntPtrToStrPtr(request.MaxKeys)).
5758
WithOptionalQueryParam("prefix", request.Prefix).
59+
WithOptionalVoidQueryParam("versions", request.Versions).
5860
Build(client.connectionInfo)
5961

6062
if err != nil {
@@ -1232,7 +1234,7 @@ func (client *Client) GetSuspectObjectsWithFullDetailsSpectraS3(request *models.
12321234
WithPath("/_rest_/suspect_object").
12331235
WithQueryParam("full_details", "").
12341236
WithOptionalQueryParam("bucket_id", request.BucketId).
1235-
WithOptionalQueryParam("storage_domain_id", request.StorageDomainId).
1237+
WithOptionalQueryParam("storage_domain", request.StorageDomain).
12361238
Build(client.connectionInfo)
12371239

12381240
if err != nil {
@@ -2543,14 +2545,15 @@ func (client *Client) GetObjectsDetailsSpectraS3(request *models.GetObjectsDetai
25432545
WithHttpVerb(HTTP_VERB_GET).
25442546
WithPath("/_rest_/object").
25452547
WithOptionalQueryParam("bucket_id", request.BucketId).
2548+
WithOptionalQueryParam("end_date", networking.Int64PtrToStrPtr(request.EndDate)).
25462549
WithOptionalVoidQueryParam("last_page", request.LastPage).
25472550
WithOptionalQueryParam("latest", networking.BoolPtrToStrPtr(request.Latest)).
25482551
WithOptionalQueryParam("name", request.Name).
25492552
WithOptionalQueryParam("page_length", networking.IntPtrToStrPtr(request.PageLength)).
25502553
WithOptionalQueryParam("page_offset", networking.IntPtrToStrPtr(request.PageOffset)).
25512554
WithOptionalQueryParam("page_start_marker", request.PageStartMarker).
2555+
WithOptionalQueryParam("start_date", networking.Int64PtrToStrPtr(request.StartDate)).
25522556
WithOptionalQueryParam("type", networking.InterfaceToStrPtr(request.S3ObjectType)).
2553-
WithOptionalQueryParam("version", networking.Int64PtrToStrPtr(request.Version)).
25542557
Build(client.connectionInfo)
25552558

25562559
if err != nil {
@@ -2577,15 +2580,16 @@ func (client *Client) GetObjectsWithFullDetailsSpectraS3(request *models.GetObje
25772580
WithPath("/_rest_/object").
25782581
WithQueryParam("full_details", "").
25792582
WithOptionalQueryParam("bucket_id", request.BucketId).
2583+
WithOptionalQueryParam("end_date", networking.Int64PtrToStrPtr(request.EndDate)).
25802584
WithOptionalVoidQueryParam("include_physical_placement", request.IncludePhysicalPlacement).
25812585
WithOptionalVoidQueryParam("last_page", request.LastPage).
25822586
WithOptionalQueryParam("latest", networking.BoolPtrToStrPtr(request.Latest)).
25832587
WithOptionalQueryParam("name", request.Name).
25842588
WithOptionalQueryParam("page_length", networking.IntPtrToStrPtr(request.PageLength)).
25852589
WithOptionalQueryParam("page_offset", networking.IntPtrToStrPtr(request.PageOffset)).
25862590
WithOptionalQueryParam("page_start_marker", request.PageStartMarker).
2591+
WithOptionalQueryParam("start_date", networking.Int64PtrToStrPtr(request.StartDate)).
25872592
WithOptionalQueryParam("type", networking.InterfaceToStrPtr(request.S3ObjectType)).
2588-
WithOptionalQueryParam("version", networking.Int64PtrToStrPtr(request.Version)).
25892593
Build(client.connectionInfo)
25902594

25912595
if err != nil {
@@ -2610,9 +2614,9 @@ func (client *Client) VerifyPhysicalPlacementForObjectsSpectraS3(request *models
26102614
httpRequest, err := networking.NewHttpRequestBuilder().
26112615
WithHttpVerb(HTTP_VERB_GET).
26122616
WithPath("/_rest_/bucket/" + request.BucketName).
2613-
WithOptionalQueryParam("storage_domain_id", request.StorageDomainId).
2617+
WithOptionalQueryParam("storage_domain", request.StorageDomain).
26142618
WithQueryParam("operation", "verify_physical_placement").
2615-
WithReadCloser(buildDs3ObjectStreamFromNames(request.ObjectNames)).
2619+
WithReadCloser(buildDs3GetObjectListStream(request.Objects)).
26162620
Build(client.connectionInfo)
26172621

26182622
if err != nil {
@@ -2638,9 +2642,9 @@ func (client *Client) VerifyPhysicalPlacementForObjectsWithFullDetailsSpectraS3(
26382642
WithHttpVerb(HTTP_VERB_GET).
26392643
WithPath("/_rest_/bucket/" + request.BucketName).
26402644
WithQueryParam("full_details", "").
2641-
WithOptionalQueryParam("storage_domain_id", request.StorageDomainId).
2645+
WithOptionalQueryParam("storage_domain", request.StorageDomain).
26422646
WithQueryParam("operation", "verify_physical_placement").
2643-
WithReadCloser(buildDs3ObjectStreamFromNames(request.ObjectNames)).
2647+
WithReadCloser(buildDs3GetObjectListStream(request.Objects)).
26442648
Build(client.connectionInfo)
26452649

26462650
if err != nil {
@@ -2812,7 +2816,7 @@ func (client *Client) GetPoolsSpectraS3(request *models.GetPoolsSpectraS3Request
28122816
WithOptionalQueryParam("partition_id", request.PartitionId).
28132817
WithOptionalQueryParam("powered_on", networking.BoolPtrToStrPtr(request.PoweredOn)).
28142818
WithOptionalQueryParam("state", networking.InterfaceToStrPtr(request.State)).
2815-
WithOptionalQueryParam("storage_domain_id", request.StorageDomainId).
2819+
WithOptionalQueryParam("storage_domain_member_id", request.StorageDomainMemberId).
28162820
WithOptionalQueryParam("type", networking.InterfaceToStrPtr(request.PoolType)).
28172821
Build(client.connectionInfo)
28182822

@@ -3096,6 +3100,10 @@ func (client *Client) GetBlobsOnTapeSpectraS3(request *models.GetBlobsOnTapeSpec
30963100
httpRequest, err := networking.NewHttpRequestBuilder().
30973101
WithHttpVerb(HTTP_VERB_GET).
30983102
WithPath("/_rest_/tape/" + request.TapeId).
3103+
WithOptionalVoidQueryParam("last_page", request.LastPage).
3104+
WithOptionalQueryParam("page_length", networking.IntPtrToStrPtr(request.PageLength)).
3105+
WithOptionalQueryParam("page_offset", networking.IntPtrToStrPtr(request.PageOffset)).
3106+
WithOptionalQueryParam("page_start_marker", request.PageStartMarker).
30993107
WithQueryParam("operation", "get_physical_placement").
31003108
Build(client.connectionInfo)
31013109

@@ -3511,7 +3519,7 @@ func (client *Client) GetTapesSpectraS3(request *models.GetTapesSpectraS3Request
35113519
WithOptionalQueryParam("serial_number", request.SerialNumber).
35123520
WithOptionalQueryParam("sort_by", request.SortBy).
35133521
WithOptionalQueryParam("state", networking.InterfaceToStrPtr(request.State)).
3514-
WithOptionalQueryParam("storage_domain_id", request.StorageDomainId).
3522+
WithOptionalQueryParam("storage_domain_member_id", request.StorageDomainMemberId).
35153523
WithOptionalQueryParam("type", request.String).
35163524
WithOptionalQueryParam("verify_pending", networking.InterfaceToStrPtr(request.VerifyPending)).
35173525
WithOptionalQueryParam("write_protected", networking.BoolPtrToStrPtr(request.WriteProtected)).

ds3/ds3Posts.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func (client *Client) DeleteObjects(request *models.DeleteObjectsRequest) (*mode
4949
WithHttpVerb(HTTP_VERB_POST).
5050
WithPath("/" + request.BucketName).
5151
WithQueryParam("delete", "").
52-
WithOptionalVoidQueryParam("roll_back", request.RollBack).
5352
WithReadCloser(buildDeleteObjectsPayload(request.ObjectNames)).
5453
Build(client.connectionInfo)
5554

@@ -392,6 +391,7 @@ func (client *Client) PutDataPolicySpectraS3(request *models.PutDataPolicySpectr
392391
WithOptionalQueryParam("default_verify_after_write", networking.BoolPtrToStrPtr(request.DefaultVerifyAfterWrite)).
393392
WithOptionalQueryParam("default_verify_job_priority", networking.InterfaceToStrPtr(request.DefaultVerifyJobPriority)).
394393
WithOptionalQueryParam("end_to_end_crc_required", networking.BoolPtrToStrPtr(request.EndToEndCrcRequired)).
394+
WithOptionalQueryParam("max_versions_to_keep", networking.IntPtrToStrPtr(request.MaxVersionsToKeep)).
395395
WithOptionalQueryParam("rebuild_priority", networking.InterfaceToStrPtr(request.RebuildPriority)).
396396
WithOptionalQueryParam("versioning", networking.InterfaceToStrPtr(request.Versioning)).
397397
Build(client.connectionInfo)
@@ -1019,6 +1019,7 @@ func (client *Client) PutTapeStorageDomainMemberSpectraS3(request *models.PutTap
10191019
WithQueryParam("storage_domain_id", request.StorageDomainId).
10201020
WithQueryParam("tape_partition_id", request.TapePartitionId).
10211021
WithQueryParam("tape_type", request.TapeType).
1022+
WithOptionalQueryParam("auto_compaction_threshold", networking.IntPtrToStrPtr(request.AutoCompactionThreshold)).
10221023
WithOptionalQueryParam("write_preference", networking.InterfaceToStrPtr(request.WritePreference)).
10231024
Build(client.connectionInfo)
10241025

0 commit comments

Comments
 (0)