From f646d4583dfff96049f22af8fcd114739cbc0702 Mon Sep 17 00:00:00 2001 From: siminsavani-msft <77068571+siminsavani-msft@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:40:26 -0400 Subject: [PATCH 1/6] Adding Cold Tier + tests --- sdk/storage/azblob/blob/client_test.go | 147 +++++++----------- sdk/storage/azblob/blob/constants.go | 1 + sdk/storage/azblob/blockblob/client_test.go | 89 ++++++++++- sdk/storage/azblob/container/client_test.go | 54 +++++++ .../internal/testcommon/clients_auth.go | 10 ++ 5 files changed, 209 insertions(+), 92 deletions(-) diff --git a/sdk/storage/azblob/blob/client_test.go b/sdk/storage/azblob/blob/client_test.go index 1d3040713a51..8d14714cc514 100644 --- a/sdk/storage/azblob/blob/client_test.go +++ b/sdk/storage/azblob/blob/client_test.go @@ -3274,95 +3274,64 @@ func (s *BlobRecordedTestsSuite) TestPermanentDeleteWithoutPermission() { return nil }*/ -// -////func (s *BlobRecordedTestsSuite) TestBlobTierInferred() { -//// svcClient, err := getPremiumserviceClient() -//// if err != nil { -//// c.Skip(err.Error()) -//// } -//// -//// containerClient, _ := testcommon.CreateNewContainer(c, svcClient) -//// defer testcommon.DeleteContainer(context.Background(), _require, containerClient) -//// bbClient, _ := createNewPageBlob(c, containerClient) -//// -//// resp, err := bbClient.GetProperties(context.Background(), nil) -//// _require.Nil(err) -//// _assert(resp.AccessTierInferred(), chk.Equals, "true") -//// -//// resp2, err := containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) -//// _require.Nil(err) -//// _assert(resp2.Segment.BlobItems[0].Properties.AccessTierInferred, chk.NotNil) -//// _assert(resp2.Segment.BlobItems[0].Properties.AccessTier, chk.Not(chk.Equals), "") -//// -//// _, err = bbClient.SetTier(ctx, AccessTierP4, LeaseAccessConditions{}) -//// _require.Nil(err) -//// -//// resp, err = bbClient.GetProperties(context.Background(), nil) -//// _require.Nil(err) -//// _assert(resp.AccessTierInferred(), chk.Equals, "") -//// -//// resp2, err = containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) -//// _require.Nil(err) -//// _assert(resp2.Segment.BlobItems[0].Properties.AccessTierInferred, chk.IsNil) // AccessTierInferred never returned if false -////} -//// -////func (s *BlobRecordedTestsSuite) TestBlobArchiveStatus() { -//// svcClient, err := getBlobStorageserviceClient() -//// if err != nil { -//// c.Skip(err.Error()) -//// } -//// -//// containerClient, _ := testcommon.CreateNewContainer(c, svcClient) -//// defer testcommon.DeleteContainer(context.Background(), _require, containerClient) -//// bbClient, _ := createNewBlockBlob(c, containerClient) -//// -//// _, err = bbClient.SetTier(ctx, AccessTierArchive, LeaseAccessConditions{}) -//// _require.Nil(err) -//// _, err = bbClient.SetTier(ctx, AccessTierCool, LeaseAccessConditions{}) -//// _require.Nil(err) -//// -//// resp, err := bbClient.GetProperties(context.Background(), nil) -//// _require.Nil(err) -//// _assert(resp.ArchiveStatus(), chk.Equals, string(ArchiveStatusRehydratePendingToCool)) -//// -//// resp2, err := containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) -//// _require.Nil(err) -//// _assert(resp2.Segment.BlobItems[0].Properties.ArchiveStatus, chk.Equals, ArchiveStatusRehydratePendingToCool) -//// -//// // delete first blob -//// _, err = bbClient.Delete(context.Background(), DeleteSnapshotsOptionNone, nil) -//// _require.Nil(err) -//// -//// bbClient, _ = createNewBlockBlob(c, containerClient) -//// -//// _, err = bbClient.SetTier(ctx, AccessTierArchive, LeaseAccessConditions{}) -//// _require.Nil(err) -//// _, err = bbClient.SetTier(ctx, AccessTierHot, LeaseAccessConditions{}) -//// _require.Nil(err) -//// -//// resp, err = bbClient.GetProperties(context.Background(), nil) -//// _require.Nil(err) -//// _assert(resp.ArchiveStatus(), chk.Equals, string(ArchiveStatusRehydratePendingToHot)) -//// -//// resp2, err = containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) -//// _require.Nil(err) -//// _assert(resp2.Segment.BlobItems[0].Properties.ArchiveStatus, chk.Equals, ArchiveStatusRehydratePendingToHot) -////} -//// -////func (s *BlobRecordedTestsSuite) TestBlobTierInvalidValue() { -//// svcClient, err := getBlobStorageserviceClient() -//// if err != nil { -//// c.Skip(err.Error()) -//// } -//// -//// containerClient, _ := testcommon.CreateNewContainer(c, svcClient) -//// defer testcommon.DeleteContainer(context.Background(), _require, containerClient) -//// bbClient, _ := createNewBlockBlob(c, containerClient) -//// -//// _, err = bbClient.SetTier(ctx, AccessTierType("garbage"), LeaseAccessConditions{}) -//// testcommon.ValidateBlobErrorCode(c, err, bloberror.InvalidHeaderValue) -////} -//// +// //func (s *BlobRecordedTestsSuite) TestBlobTierInferred() { +// // svcClient, err := getPremiumserviceClient() +// // if err != nil { +// // c.Skip(err.Error()) +// // } +// // +// // containerClient, _ := testcommon.CreateNewContainer(c, svcClient) +// // defer testcommon.DeleteContainer(context.Background(), _require, containerClient) +// // bbClient, _ := createNewPageBlob(c, containerClient) +// // +// // resp, err := bbClient.GetProperties(context.Background(), nil) +// // _require.Nil(err) +// // _assert(resp.AccessTierInferred(), chk.Equals, "true") +// // +// // resp2, err := containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) +// // _require.Nil(err) +// // _assert(resp2.Segment.BlobItems[0].Properties.AccessTierInferred, chk.NotNil) +// // _assert(resp2.Segment.BlobItems[0].Properties.AccessTier, chk.Not(chk.Equals), "") +// // +// // _, err = bbClient.SetTier(ctx, AccessTierP4, LeaseAccessConditions{}) +// // _require.Nil(err) +// // +// // resp, err = bbClient.GetProperties(context.Background(), nil) +// // _require.Nil(err) +// // _assert(resp.AccessTierInferred(), chk.Equals, "") +// // +// // resp2, err = containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) +// // _require.Nil(err) +// // _assert(resp2.Segment.BlobItems[0].Properties.AccessTierInferred, chk.IsNil) // AccessTierInferred never returned if false +// //} +// // + +func (s *BlobRecordedTestsSuite) TestBlobSetTierInvalidAndValid() { + _require := require.New(s.T()) + testName := s.T().Name() + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blockBlobName := testcommon.GenerateBlobName(testName) + bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient) + + _, err = bbClient.SetTier(context.Background(), blob.AccessTier("nothing"), nil) + _require.Error(err) + testcommon.ValidateBlobErrorCode(_require, err, bloberror.InvalidHeaderValue) + + for _, tier := range []blob.AccessTier{blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold, blob.AccessTierArchive} { + _, err = bbClient.SetTier(context.Background(), tier, nil) + _require.NoError(err) + + getResp, err := bbClient.GetProperties(context.Background(), nil) + _require.NoError(err) + _require.Equal(*getResp.AccessTier, string(tier)) + } +} func (s *BlobRecordedTestsSuite) TestBlobClientPartsSASQueryTimes() { _require := require.New(s.T()) diff --git a/sdk/storage/azblob/blob/constants.go b/sdk/storage/azblob/blob/constants.go index c15635448ef9..8a9107954381 100644 --- a/sdk/storage/azblob/blob/constants.go +++ b/sdk/storage/azblob/blob/constants.go @@ -53,6 +53,7 @@ type AccessTier = generated.AccessTier const ( AccessTierArchive AccessTier = generated.AccessTierArchive AccessTierCool AccessTier = generated.AccessTierCool + AccessTierCold AccessTier = generated.AccessTierCold AccessTierHot AccessTier = generated.AccessTierHot AccessTierP10 AccessTier = generated.AccessTierP10 AccessTierP15 AccessTier = generated.AccessTierP15 diff --git a/sdk/storage/azblob/blockblob/client_test.go b/sdk/storage/azblob/blockblob/client_test.go index edafdf0622b7..49f79556a4ac 100644 --- a/sdk/storage/azblob/blockblob/client_test.go +++ b/sdk/storage/azblob/blockblob/client_test.go @@ -1247,6 +1247,56 @@ func (s *BlockBlobRecordedTestsSuite) TestPutBlobFromURLCopySourceAuthNegative() testcommon.ValidateBlobErrorCode(_require, err, bloberror.CannotVerifyCopySource) } +func (s *BlockBlobUnrecordedTestsSuite) TestPutBlobFromURLWithTier() { + _require := require.New(s.T()) + testName := s.T().Name() + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + src := testcommon.GenerateBlobName("src" + testName) + srcBlob := testcommon.CreateNewBlockBlob(context.Background(), _require, src, containerClient) + + // Create SAS for source and get SAS URL + expiryTime := time.Now().UTC().Add(15 * time.Minute) + _require.Nil(err) + + credential, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDefault) + _require.NoError(err) + + sasQueryParams, err := sas.AccountSignatureValues{ + Protocol: sas.ProtocolHTTPS, + ExpiryTime: expiryTime, + Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(), + ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(), + }.SignWithSharedKey(credential) + _require.Nil(err) + + srcBlobParts, _ := blob.ParseURL(srcBlob.URL()) + srcBlobParts.SAS = sasQueryParams + srcBlobURLWithSAS := srcBlobParts.String() + + for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { + dest := testcommon.GenerateBlobName("dest" + string(tier) + testName) + destBlob := testcommon.CreateNewBlockBlob(context.Background(), _require, dest, containerClient) + + opts := blockblob.UploadBlobFromURLOptions{ + Tier: &tier, + } + // Invoke UploadBlobFromURL + pbResp, err := destBlob.UploadBlobFromURL(context.Background(), srcBlobURLWithSAS, &opts) + _require.NotNil(pbResp) + _require.NoError(err) + + getResp, err := destBlob.GetProperties(context.Background(), nil) + _require.Nil(err) + _require.Equal(*getResp.AccessTier, string(tier)) + } +} + func (s *BlockBlobRecordedTestsSuite) TestPutBlockListWithImmutabilityPolicy() { _require := require.New(s.T()) testName := s.T().Name() @@ -1909,7 +1959,7 @@ func (s *BlockBlobRecordedTestsSuite) TestSetTierOnBlobUpload() { containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) defer testcommon.DeleteContainer(context.Background(), _require, containerClient) - for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot} { + for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { blobName := strings.ToLower(string(tier)) + testcommon.GenerateBlobName(testName) bbClient := testcommon.GetBlockBlobClient(blobName, containerClient) @@ -1936,7 +1986,7 @@ func (s *BlockBlobRecordedTestsSuite) TestBlobSetTierOnCommit() { containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) defer testcommon.DeleteContainer(context.Background(), _require, containerClient) - for _, tier := range []blob.AccessTier{blob.AccessTierCool, blob.AccessTierHot} { + for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { blobName := strings.ToLower(string(tier)) + testcommon.GenerateBlobName(testName) bbClient := testcommon.GetBlockBlobClient(blobName, containerClient) @@ -1955,6 +2005,10 @@ func (s *BlockBlobRecordedTestsSuite) TestBlobSetTierOnCommit() { _require.NotNil(resp.BlockList.CommittedBlocks) _require.Nil(resp.BlockList.UncommittedBlocks) _require.Len(resp.BlockList.CommittedBlocks, 1) + + getResp, err := bbClient.GetProperties(context.Background(), nil) + _require.NoError(err) + _require.Equal(*getResp.AccessTier, string(tier)) } } @@ -1998,7 +2052,7 @@ func (s *BlockBlobUnrecordedTestsSuite) TestSetTierOnCopyBlockBlobFromURL() { srcBlobParts.SAS = sasQueryParams srcBlobURLWithSAS := srcBlobParts.String() - for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot} { + for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { destBlobName := strings.ToLower(string(tier)) + testcommon.GenerateBlobName(testName) destBlob := containerClient.NewBlockBlobClient(testcommon.GenerateBlobName(destBlobName)) @@ -2247,6 +2301,34 @@ func (s *BlockBlobRecordedTestsSuite) TestCopyBlobWithRehydratePriority() { _require.Equal(*getResp2.ArchiveStatus, string(blob.ArchiveStatusRehydratePendingToHot)) } +func (s *BlockBlobRecordedTestsSuite) TestCopyWithTier() { + _require := require.New(s.T()) + testName := s.T().Name() + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { + src := testcommon.GenerateBlobName("src" + string(tier) + testName) + srcBlob := testcommon.CreateNewBlockBlob(context.Background(), _require, src, containerClient) + + dest := testcommon.GenerateBlobName("dest" + string(tier) + testName) + destBlob := testcommon.CreateNewBlockBlob(context.Background(), _require, dest, containerClient) + + _, err = destBlob.StartCopyFromURL(context.Background(), srcBlob.URL(), &blob.StartCopyFromURLOptions{ + Tier: &tier, + }) + _require.NoError(err) + + getResp, err := destBlob.GetProperties(context.Background(), nil) + _require.Nil(err) + _require.Equal(*getResp.AccessTier, string(tier)) + } +} + func (s *BlockBlobRecordedTestsSuite) TestBlobServiceClientDelete() { _require := require.New(s.T()) svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) @@ -2279,6 +2361,7 @@ func (s *BlockBlobRecordedTestsSuite) TestBlobSetTierAllTiersOnBlockBlob() { blockBlobName := testcommon.GenerateBlobName(testName) bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient) + setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierCold) setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierHot) setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierCool) setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierArchive) diff --git a/sdk/storage/azblob/container/client_test.go b/sdk/storage/azblob/container/client_test.go index 21261c4e4931..83ae74707dd9 100644 --- a/sdk/storage/azblob/container/client_test.go +++ b/sdk/storage/azblob/container/client_test.go @@ -1344,6 +1344,60 @@ func (s *ContainerRecordedTestsSuite) TestBlobListWrapper() { _require.EqualValues(files, found) } +func (s *ContainerRecordedTestsSuite) TestBlobListColdTier() { + _require := require.New(s.T()) + testName := s.T().Name() + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.GetContainerClient(containerName, svcClient) + + _, err = containerClient.Create(context.Background(), nil) + _require.NoError(err) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + for _, tier := range []blob.AccessTier{blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold, blob.AccessTierArchive} { + files := []string{"a123", "b234", "c345"} + testcommon.CreateNewBlobsListTier(context.Background(), _require, files, containerClient, &tier) + + // List blobs flat + found := make([]string, 0) + pager := containerClient.NewListBlobsFlatPager(nil) + for pager.More() { + resp, err := pager.NextPage(context.Background()) + _require.NoError(err) + + for _, blob := range resp.Segment.BlobItems { + _require.Equal(blob.Properties.AccessTier, &tier) + found = append(found, *blob.Name) + } + } + + sort.Strings(files) + sort.Strings(found) + _require.EqualValues(files, found) + + // Try listing blobs with hierarchical listing + found = make([]string, 0) + pg := containerClient.NewListBlobsHierarchyPager("/", nil) + for pg.More() { + resp, err := pg.NextPage(context.Background()) + _require.NoError(err) + + for _, blob := range resp.Segment.BlobItems { + _require.Equal(blob.Properties.AccessTier, &tier) + found = append(found, *blob.Name) + } + } + + sort.Strings(files) + sort.Strings(found) + _require.EqualValues(files, found) + + } +} + func (s *ContainerRecordedTestsSuite) TestBlobListWrapperListingError() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azblob/internal/testcommon/clients_auth.go b/sdk/storage/azblob/internal/testcommon/clients_auth.go index 687c7e8a5fee..bb027c06d691 100644 --- a/sdk/storage/azblob/internal/testcommon/clients_auth.go +++ b/sdk/storage/azblob/internal/testcommon/clients_auth.go @@ -236,6 +236,16 @@ func CreateNewBlobs(ctx context.Context, _require *require.Assertions, blobNames } } +func CreateNewBlobsListTier(ctx context.Context, _require *require.Assertions, blobNames []string, containerClient *container.Client, tier *blob.AccessTier) { + var bbClientList []*blockblob.Client + for _, blobName := range blobNames { + bbClient := CreateNewBlockBlob(ctx, _require, blobName, containerClient) + _, err := bbClient.SetTier(ctx, *tier, nil) + _require.NoError(err) + bbClientList = append(bbClientList, bbClient) + } +} + func GetBlockBlobClient(blockBlobName string, containerClient *container.Client) *blockblob.Client { return containerClient.NewBlockBlobClient(blockBlobName) } From 7fa5473a7fb95271357669210ba3b8f98e8fed00 Mon Sep 17 00:00:00 2001 From: siminsavani-msft <77068571+siminsavani-msft@users.noreply.github.com> Date: Sun, 18 Jun 2023 23:37:20 -0400 Subject: [PATCH 2/6] Recorded tests --- sdk/storage/azblob/assets.json | 2 +- sdk/storage/azblob/blockblob/client_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azblob/assets.json b/sdk/storage/azblob/assets.json index 4db1d7209d92..3eb5d2db94d9 100644 --- a/sdk/storage/azblob/assets.json +++ b/sdk/storage/azblob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azblob", - "Tag": "go/storage/azblob_a772b9c866" + "Tag": "go/storage/azblob_ec88f3fc4f" } diff --git a/sdk/storage/azblob/blockblob/client_test.go b/sdk/storage/azblob/blockblob/client_test.go index 49f79556a4ac..691cbef49cb8 100644 --- a/sdk/storage/azblob/blockblob/client_test.go +++ b/sdk/storage/azblob/blockblob/client_test.go @@ -1986,7 +1986,7 @@ func (s *BlockBlobRecordedTestsSuite) TestBlobSetTierOnCommit() { containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) defer testcommon.DeleteContainer(context.Background(), _require, containerClient) - for _, tier := range []blob.AccessTier{blob.AccessTierArchive, blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { + for _, tier := range []blob.AccessTier{blob.AccessTierCool, blob.AccessTierHot, blob.AccessTierCold} { blobName := strings.ToLower(string(tier)) + testcommon.GenerateBlobName(testName) bbClient := testcommon.GetBlockBlobClient(blobName, containerClient) From 629f85a91d28fe25801db40fcff4ecae07836316 Mon Sep 17 00:00:00 2001 From: siminsavani-msft <77068571+siminsavani-msft@users.noreply.github.com> Date: Sun, 18 Jun 2023 23:48:46 -0400 Subject: [PATCH 3/6] Updated CHANGELOG.md --- sdk/storage/azblob/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index 567682e02c38..118a5bb0c99b 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.1.0-beta.2 (Unreleased) ### Features Added +* Added `AccessTierCold`. ### Breaking Changes From 7c2d270308e94acf8ac96e9c48d1a02a811a5000 Mon Sep 17 00:00:00 2001 From: siminsavani-msft <77068571+siminsavani-msft@users.noreply.github.com> Date: Mon, 19 Jun 2023 00:24:49 -0400 Subject: [PATCH 4/6] Fixing linting issues --- sdk/storage/azblob/internal/testcommon/clients_auth.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/storage/azblob/internal/testcommon/clients_auth.go b/sdk/storage/azblob/internal/testcommon/clients_auth.go index bb027c06d691..c4179f73d05d 100644 --- a/sdk/storage/azblob/internal/testcommon/clients_auth.go +++ b/sdk/storage/azblob/internal/testcommon/clients_auth.go @@ -237,12 +237,10 @@ func CreateNewBlobs(ctx context.Context, _require *require.Assertions, blobNames } func CreateNewBlobsListTier(ctx context.Context, _require *require.Assertions, blobNames []string, containerClient *container.Client, tier *blob.AccessTier) { - var bbClientList []*blockblob.Client for _, blobName := range blobNames { bbClient := CreateNewBlockBlob(ctx, _require, blobName, containerClient) _, err := bbClient.SetTier(ctx, *tier, nil) _require.NoError(err) - bbClientList = append(bbClientList, bbClient) } } From 686ea805923c4675c54d4da5578b258829d0d992 Mon Sep 17 00:00:00 2001 From: siminsavani-msft <77068571+siminsavani-msft@users.noreply.github.com> Date: Mon, 19 Jun 2023 13:44:00 -0400 Subject: [PATCH 5/6] Updating Cold tier test and recording --- sdk/storage/azblob/assets.json | 2 +- sdk/storage/azblob/blockblob/client_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/storage/azblob/assets.json b/sdk/storage/azblob/assets.json index 3eb5d2db94d9..2f2da0dc64dd 100644 --- a/sdk/storage/azblob/assets.json +++ b/sdk/storage/azblob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azblob", - "Tag": "go/storage/azblob_ec88f3fc4f" + "Tag": "go/storage/azblob_5cbc6d263b" } diff --git a/sdk/storage/azblob/blockblob/client_test.go b/sdk/storage/azblob/blockblob/client_test.go index 691cbef49cb8..981f0d9ec855 100644 --- a/sdk/storage/azblob/blockblob/client_test.go +++ b/sdk/storage/azblob/blockblob/client_test.go @@ -2361,7 +2361,6 @@ func (s *BlockBlobRecordedTestsSuite) TestBlobSetTierAllTiersOnBlockBlob() { blockBlobName := testcommon.GenerateBlobName(testName) bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient) - setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierCold) setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierHot) setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierCool) setAndCheckBlockBlobTier(_require, bbClient, blob.AccessTierArchive) From 594025216e1bfb245645fdf4b56ea3f1b8246512 Mon Sep 17 00:00:00 2001 From: siminsavani-msft <77068571+siminsavani-msft@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:46:03 -0400 Subject: [PATCH 6/6] Addressing commits --- sdk/storage/azblob/CHANGELOG.md | 2 +- sdk/storage/azblob/assets.json | 2 +- sdk/storage/azblob/blob/client_test.go | 32 ---------------------- sdk/storage/azblob/pageblob/client_test.go | 27 ++++++++++++++++++ 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index 118a5bb0c99b..497367954ab0 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.1.0-beta.2 (Unreleased) ### Features Added -* Added `AccessTierCold`. +* Added support for [Cold tier](https://learn.microsoft.com/azure/storage/blobs/access-tiers-overview?tabs=azure-portal). ### Breaking Changes diff --git a/sdk/storage/azblob/assets.json b/sdk/storage/azblob/assets.json index 2f2da0dc64dd..b9fb1441baa5 100644 --- a/sdk/storage/azblob/assets.json +++ b/sdk/storage/azblob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azblob", - "Tag": "go/storage/azblob_5cbc6d263b" + "Tag": "go/storage/azblob_1a8d8f30f5" } diff --git a/sdk/storage/azblob/blob/client_test.go b/sdk/storage/azblob/blob/client_test.go index 8d14714cc514..64bf13390f52 100644 --- a/sdk/storage/azblob/blob/client_test.go +++ b/sdk/storage/azblob/blob/client_test.go @@ -3274,38 +3274,6 @@ func (s *BlobRecordedTestsSuite) TestPermanentDeleteWithoutPermission() { return nil }*/ -// //func (s *BlobRecordedTestsSuite) TestBlobTierInferred() { -// // svcClient, err := getPremiumserviceClient() -// // if err != nil { -// // c.Skip(err.Error()) -// // } -// // -// // containerClient, _ := testcommon.CreateNewContainer(c, svcClient) -// // defer testcommon.DeleteContainer(context.Background(), _require, containerClient) -// // bbClient, _ := createNewPageBlob(c, containerClient) -// // -// // resp, err := bbClient.GetProperties(context.Background(), nil) -// // _require.Nil(err) -// // _assert(resp.AccessTierInferred(), chk.Equals, "true") -// // -// // resp2, err := containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) -// // _require.Nil(err) -// // _assert(resp2.Segment.BlobItems[0].Properties.AccessTierInferred, chk.NotNil) -// // _assert(resp2.Segment.BlobItems[0].Properties.AccessTier, chk.Not(chk.Equals), "") -// // -// // _, err = bbClient.SetTier(ctx, AccessTierP4, LeaseAccessConditions{}) -// // _require.Nil(err) -// // -// // resp, err = bbClient.GetProperties(context.Background(), nil) -// // _require.Nil(err) -// // _assert(resp.AccessTierInferred(), chk.Equals, "") -// // -// // resp2, err = containerClient.NewListBlobsFlatPager(ctx, Marker{}, ListBlobsSegmentOptions{}) -// // _require.Nil(err) -// // _assert(resp2.Segment.BlobItems[0].Properties.AccessTierInferred, chk.IsNil) // AccessTierInferred never returned if false -// //} -// // - func (s *BlobRecordedTestsSuite) TestBlobSetTierInvalidAndValid() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azblob/pageblob/client_test.go b/sdk/storage/azblob/pageblob/client_test.go index 7b659b4bf4ee..a7195b050644 100644 --- a/sdk/storage/azblob/pageblob/client_test.go +++ b/sdk/storage/azblob/pageblob/client_test.go @@ -154,6 +154,33 @@ func (s *PageBlobRecordedTestsSuite) TestPutGetPages() { } } +func (s *PageBlobRecordedTestsSuite) TestBlobTierInferred() { + _require := require.New(s.T()) + testName := s.T().Name() + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountPremium, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blockBlobName := testcommon.GenerateBlobName(testName) + pbClient := createNewPageBlob(context.Background(), _require, blockBlobName, containerClient) + + resp, err := pbClient.GetProperties(context.Background(), nil) + _require.Nil(err) + _require.Equal(*resp.AccessTierInferred, true) + _require.NotEqual(*resp.AccessTier, "") + + _, err = pbClient.SetTier(context.Background(), blob.AccessTierP4, nil) + _require.Nil(err) + + resp, err = pbClient.GetProperties(context.Background(), nil) + _require.Nil(err) + _require.Nil(resp.AccessTierInferred) + _require.NotEqual(*resp.AccessTier, "") +} + // func (s *PageBlobUnrecordedTestsSuite) TestUploadPagesFromURL() { // _require := require.New(s.T()) // testName := s.T().Name()