From 7d12b440ba2e5326721c247944f0eb3f0690c5a6 Mon Sep 17 00:00:00 2001 From: Ze Qian Zhang Date: Thu, 26 Aug 2021 22:10:24 -0700 Subject: [PATCH] Fix CI data race --- azblob/zt_url_service_test.go | 20 ++++++++++++++++---- azure-pipelines.yml | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/azblob/zt_url_service_test.go b/azblob/zt_url_service_test.go index 83f3e20..0af57a9 100644 --- a/azblob/zt_url_service_test.go +++ b/azblob/zt_url_service_test.go @@ -206,7 +206,7 @@ func (s *aztestsSuite) TestAccountListContainersMaxResultsSufficient(c *chk.C) { c.Assert(len(response.ContainerItems) >= 2, chk.Equals, true) } -func CreateBlobWithRetentionPolicy(c *chk.C) (BlockBlobURL, ContainerURL) { +func CreateBlobWithRetentionPolicy(c *chk.C) (BlockBlobURL, ContainerURL, ServiceURL) { bsu, err := getAlternateBSU() c.Assert(err, chk.IsNil) @@ -228,11 +228,11 @@ func CreateBlobWithRetentionPolicy(c *chk.C) (BlockBlobURL, ContainerURL) { c.Assert(err, chk.IsNil) c.Assert(cResp.StatusCode(), chk.Equals, 201) - return blobURL, containerURL + return blobURL, containerURL, bsu } func (s *aztestsSuite) TestUndelete(c *chk.C) { - blobURL, containerURL := CreateBlobWithRetentionPolicy(c) + blobURL, containerURL, bsu := CreateBlobWithRetentionPolicy(c) defer deleteContainer(c, containerURL) // Soft delete blob @@ -251,10 +251,16 @@ func (s *aztestsSuite) TestUndelete(c *chk.C) { blobProp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{}) c.Assert(blobProp.StatusCode(), chk.Equals, 200) + + _, err = bsu.SetProperties(ctx, StorageServiceProperties{DeleteRetentionPolicy: &RetentionPolicy{Enabled: false}}) + c.Assert(err, chk.IsNil) + + // From FE, 30 seconds is guaranteed to be enough. + time.Sleep(time.Second * 30) } func (s *aztestsSuite) TestPermanentDelete(c *chk.C) { - blobURL, containerURL := CreateBlobWithRetentionPolicy(c) + blobURL, containerURL, bsu := CreateBlobWithRetentionPolicy(c) defer deleteContainer(c, containerURL) // Create snapshot for second blob @@ -293,6 +299,12 @@ func (s *aztestsSuite) TestPermanentDelete(c *chk.C) { c.Assert(err, chk.IsNil) c.Assert(listBlobResp3.Segment.BlobItems, chk.HasLen, 1) c.Assert(listBlobResp3.Segment.BlobItems[0].Deleted, chk.Equals, false) + + _, err = bsu.SetProperties(ctx, StorageServiceProperties{DeleteRetentionPolicy: &RetentionPolicy{Enabled: false}}) + c.Assert(err, chk.IsNil) + + // From FE, 30 seconds is guaranteed to be enough. + time.Sleep(time.Second * 30) } func (s *aztestsSuite) TestAccountDeleteRetentionPolicy(c *chk.C) { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d4b77ee..9fec7ff 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,7 +8,7 @@ pool: steps: - task: GoTool@0 inputs: - version: '1.15' + version: '1.17' - script: | go build ./azblob displayName: 'Compile the SDK'