Skip to content

Commit 412be1e

Browse files
authored
[Storage] Fix flaky tests. (Azure#22984)
* unflaky tag tests. * fix length check. * fix test. * pr feedback.
1 parent aa31fa0 commit 412be1e

File tree

190 files changed

+9084
-16480
lines changed

Some content is hidden

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

190 files changed

+9084
-16480
lines changed

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ import java.util.stream.Collectors
4242

4343
class ContainerAPITest extends APISpec {
4444

45+
String tagKey
46+
String tagValue
47+
48+
def setup() {
49+
tagKey = namer.getRandomName(20)
50+
tagValue = namer.getRandomName(20)
51+
}
52+
4553
def "Create all null"() {
4654
setup:
4755
// Overwrite the existing cc, which has already been created
@@ -726,7 +734,7 @@ class ContainerAPITest extends APISpec {
726734

727735
def tagsBlob = cc.getBlobClient(tagsName).getPageBlobClient()
728736
def tags = new HashMap<String, String>()
729-
tags.put("tag", "value")
737+
tags.put(tagKey, tagValue)
730738
tagsBlob.createWithResponse(new PageBlobCreateOptions(512).setTags(tags), null, null)
731739

732740
def uncommittedBlob = cc.getBlobClient(uncommittedName).getBlockBlobClient()
@@ -813,7 +821,7 @@ class ContainerAPITest extends APISpec {
813821
blobs.get(1).getProperties().getCopyCompletionTime() == null
814822
blobs.get(2).getName() == metadataName
815823
blobs.get(2).getMetadata() == null
816-
blobs.get(3).getTags().get("tag") == "value"
824+
blobs.get(3).getTags().get(tagKey) == tagValue
817825
blobs.get(3).getProperties().getTagCount() == 1
818826
blobs.size() == 4 // Normal, copy, metadata, tags
819827
}
@@ -1241,7 +1249,7 @@ class ContainerAPITest extends APISpec {
12411249
blobs.get(1).getProperties().getCopyCompletionTime() == null
12421250
blobs.get(2).getName() == metadataName
12431251
blobs.get(2).getMetadata() == null
1244-
blobs.get(3).getTags().get("tag") == "value"
1252+
blobs.get(3).getTags().get(tagKey) == tagValue
12451253
blobs.get(3).getProperties().getTagCount() == 1
12461254
blobs.size() == 4 // Normal, copy, metadata, tags
12471255
}

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ import java.time.OffsetDateTime
4747
@ResourceLock("ServiceProperties")
4848
class ServiceAPITest extends APISpec {
4949

50-
BlobServiceClient anonymousClient;
50+
BlobServiceClient anonymousClient
51+
String tagKey
52+
String tagValue
5153

5254
def setup() {
5355
setup:
@@ -67,6 +69,9 @@ class ServiceAPITest extends APISpec {
6769
.setLogging(new BlobAnalyticsLogging().setVersion("1.0")
6870
.setRetentionPolicy(disabled))
6971
.setDefaultServiceVersion("2018-03-28"))
72+
73+
tagKey = namer.getRandomName(20)
74+
tagValue = namer.getRandomName(20)
7075
}
7176

7277
def cleanup() {
@@ -370,22 +375,22 @@ class ServiceAPITest extends APISpec {
370375
def "Find blobs marker"() {
371376
setup:
372377
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
373-
def tags = Collections.singletonMap("tag", "value")
378+
def tags = Collections.singletonMap(tagKey, tagValue)
374379
for (int i = 0; i < 10; i++) {
375380
cc.getBlobClient(generateBlobName()).uploadWithResponse(
376381
new BlobParallelUploadOptions(data.defaultInputStream, data.defaultDataSize).setTags(tags), null, null)
377382
}
378383

379384
sleepIfRecord(10 * 1000) // To allow tags to index
380385

381-
def firstPage = primaryBlobServiceClient.findBlobsByTags(new FindBlobsOptions("\"tag\"='value'")
386+
def firstPage = primaryBlobServiceClient.findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue))
382387
.setMaxResultsPerPage(5), null, Context.NONE)
383388
.iterableByPage().iterator().next()
384389
def marker = firstPage.getContinuationToken()
385390
def firstBlobName = firstPage.getValue().first().getName()
386391

387392
def secondPage = primaryBlobServiceClient.findBlobsByTags(
388-
new FindBlobsOptions("\"tag\"='value'").setMaxResultsPerPage(5), null, Context.NONE)
393+
new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), null, Context.NONE)
389394
.iterableByPage(marker).iterator().next()
390395

391396
expect:
@@ -402,7 +407,7 @@ class ServiceAPITest extends APISpec {
402407
def NUM_BLOBS = 7
403408
def PAGE_RESULTS = 3
404409
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
405-
def tags = Collections.singletonMap("tag", "value")
410+
def tags = Collections.singletonMap(tagKey, tagValue)
406411

407412
for (i in (1..NUM_BLOBS)) {
408413
cc.getBlobClient(generateBlobName()).uploadWithResponse(
@@ -412,7 +417,7 @@ class ServiceAPITest extends APISpec {
412417
expect:
413418
for (ContinuablePage page :
414419
primaryBlobServiceClient.findBlobsByTags(
415-
new FindBlobsOptions("\"tag\"='value'").setMaxResultsPerPage(PAGE_RESULTS), null, Context.NONE)
420+
new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(PAGE_RESULTS), null, Context.NONE)
416421
.iterableByPage()) {
417422
assert page.iterator().size() <= PAGE_RESULTS
418423
}
@@ -427,7 +432,7 @@ class ServiceAPITest extends APISpec {
427432
def NUM_BLOBS = 7
428433
def PAGE_RESULTS = 3
429434
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
430-
def tags = Collections.singletonMap("tag", "value")
435+
def tags = Collections.singletonMap(tagKey, tagValue)
431436

432437
for (i in (1..NUM_BLOBS)) {
433438
cc.getBlobClient(generateBlobName()).uploadWithResponse(
@@ -437,7 +442,7 @@ class ServiceAPITest extends APISpec {
437442
expect:
438443
for (ContinuablePage page :
439444
primaryBlobServiceClient.findBlobsByTags(
440-
new FindBlobsOptions("\"tag\"='value'"), null, Context.NONE)
445+
new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)), null, Context.NONE)
441446
.iterableByPage(PAGE_RESULTS)) {
442447
assert page.iterator().size() <= PAGE_RESULTS
443448
}
@@ -469,15 +474,15 @@ class ServiceAPITest extends APISpec {
469474
def NUM_BLOBS = 5
470475
def PAGE_RESULTS = 3
471476
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
472-
def tags = Collections.singletonMap("tag", "value")
477+
def tags = Collections.singletonMap(tagKey, tagValue)
473478

474479
for (i in (1..NUM_BLOBS)) {
475480
cc.getBlobClient(generateBlobName()).uploadWithResponse(
476481
new BlobParallelUploadOptions(data.defaultInputStream, data.defaultDataSize).setTags(tags), null, null)
477482
}
478483

479484
when: "Consume results by page"
480-
primaryBlobServiceClient.findBlobsByTags(new FindBlobsOptions("\"tag\"='value'")
485+
primaryBlobServiceClient.findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue))
481486
.setMaxResultsPerPage(PAGE_RESULTS), Duration.ofSeconds(10), Context.NONE)
482487
.streamByPage().count()
483488

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAPITest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class BlockBlobAPITest extends APISpec {
787787
@LiveOnly
788788
def "Upload from file with tags"() {
789789
given:
790-
def tags = Collections.singletonMap("tag", "value")
790+
def tags = Collections.singletonMap(namer.getRandomName(20), namer.getRandomName(20))
791791
def file = getRandomFile(Constants.KB)
792792
def outStream = new ByteArrayOutputStream()
793793

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ class HelperTest extends APISpec {
173173

174174
then:
175175
StepVerifier.create(flux)
176-
.assertNext(){buffer -> assert buffer.compareTo(ByteBuffer.wrap(data, 0, 9)) == 0}
177176
.verifyError(IllegalStateException.class)
178177
}
179178

Lines changed: 39 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,106 @@
11
{
22
"networkCallRecords" : [ {
33
"Method" : "PUT",
4-
"Uri" : "https://REDACTED.blob.core.windows.net/4aae84e204aae84e28f9364711d274cff7927418abdb?restype=container",
4+
"Uri" : "https://REDACTED.blob.core.windows.net/4aae84e204aae84e2fad59110c3263b2de2244db8bad?restype=container",
55
"Headers" : {
6-
"x-ms-version" : "2020-06-12",
7-
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
8-
"x-ms-client-request-id" : "847ac51f-59a7-443a-a715-16f3ca46d793"
6+
"x-ms-version" : "2020-10-02",
7+
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
8+
"x-ms-client-request-id" : "4e20c39a-d9d0-4558-869e-e227900d2e34"
99
},
1010
"Response" : {
1111
"content-length" : "0",
12-
"x-ms-version" : "2020-06-12",
12+
"x-ms-version" : "2020-10-02",
1313
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
14-
"eTag" : "0x8D90F538BFCB50D",
15-
"Last-Modified" : "Tue, 04 May 2021 23:22:55 GMT",
14+
"eTag" : "0x8D947B7B4FC84A3",
15+
"Last-Modified" : "Thu, 15 Jul 2021 17:40:59 GMT",
1616
"retry-after" : "0",
1717
"StatusCode" : "201",
18-
"x-ms-request-id" : "07eb63f5-501e-0019-7b3c-414a0a000000",
19-
"x-ms-client-request-id" : "847ac51f-59a7-443a-a715-16f3ca46d793",
20-
"Date" : "Tue, 04 May 2021 23:22:55 GMT"
18+
"x-ms-request-id" : "aa022f04-601e-004f-0ba0-79bbe5000000",
19+
"x-ms-client-request-id" : "4e20c39a-d9d0-4558-869e-e227900d2e34",
20+
"Date" : "Thu, 15 Jul 2021 17:40:58 GMT"
2121
},
2222
"Exception" : null
2323
}, {
2424
"Method" : "GET",
2525
"Uri" : "https://REDACTED.blob.core.windows.net/$root?restype=container",
2626
"Headers" : {
27-
"x-ms-version" : "2020-06-12",
28-
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
29-
"x-ms-client-request-id" : "1612b2ad-3a8e-4328-bda1-0cabb8b9a06d"
27+
"x-ms-version" : "2020-10-02",
28+
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
29+
"x-ms-client-request-id" : "393407cb-62e3-4e09-8a36-119a77a0da94"
3030
},
3131
"Response" : {
3232
"content-length" : "0",
33-
"x-ms-version" : "2020-06-12",
33+
"x-ms-version" : "2020-10-02",
3434
"x-ms-lease-status" : "unlocked",
35+
"x-ms-immutable-storage-with-versioning-enabled" : "false",
3536
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
3637
"x-ms-lease-state" : "available",
3738
"x-ms-deny-encryption-scope-override" : "false",
3839
"Last-Modified" : "Tue, 04 May 2021 23:22:53 GMT",
3940
"retry-after" : "0",
4041
"StatusCode" : "200",
4142
"x-ms-has-legal-hold" : "false",
42-
"Date" : "Tue, 04 May 2021 23:22:54 GMT",
43+
"Date" : "Thu, 15 Jul 2021 17:40:58 GMT",
4344
"x-ms-default-encryption-scope" : "$account-encryption-key",
4445
"x-ms-has-immutability-policy" : "false",
46+
"Vary" : "Origin",
4547
"eTag" : "0x8D90F538AA49CDE",
46-
"x-ms-request-id" : "8783dac2-c01e-0079-423c-413695000000",
47-
"x-ms-client-request-id" : "1612b2ad-3a8e-4328-bda1-0cabb8b9a06d"
48+
"x-ms-request-id" : "f6e8f8ba-501e-0019-36a0-794a0a000000",
49+
"x-ms-client-request-id" : "393407cb-62e3-4e09-8a36-119a77a0da94"
4850
},
4951
"Exception" : null
5052
}, {
5153
"Method" : "PUT",
5254
"Uri" : "https://REDACTED.blob.core.windows.net/$root/rootblob",
5355
"Headers" : {
54-
"x-ms-version" : "2020-06-12",
55-
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
56-
"x-ms-client-request-id" : "4164acde-d8d3-44e1-8e74-0e8ada18bb52"
56+
"x-ms-version" : "2020-10-02",
57+
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
58+
"x-ms-client-request-id" : "7f4028c9-3697-417e-bf6f-979d2d2b64d6"
5759
},
5860
"Response" : {
5961
"content-length" : "0",
60-
"x-ms-version" : "2020-06-12",
62+
"x-ms-version" : "2020-10-02",
6163
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
62-
"eTag" : "0x8D90F538C12D69E",
63-
"Last-Modified" : "Tue, 04 May 2021 23:22:55 GMT",
64+
"eTag" : "0x8D947B7B5253E04",
65+
"Last-Modified" : "Thu, 15 Jul 2021 17:40:59 GMT",
6466
"retry-after" : "0",
6567
"StatusCode" : "201",
66-
"x-ms-request-id" : "55bbaf08-f01e-0010-293c-410fd9000000",
68+
"x-ms-request-id" : "c88ef9fb-a01e-0022-30a0-790fae000000",
6769
"x-ms-request-server-encrypted" : "true",
68-
"x-ms-client-request-id" : "4164acde-d8d3-44e1-8e74-0e8ada18bb52",
69-
"Date" : "Tue, 04 May 2021 23:22:55 GMT"
70+
"x-ms-client-request-id" : "7f4028c9-3697-417e-bf6f-979d2d2b64d6",
71+
"Date" : "Thu, 15 Jul 2021 17:40:58 GMT"
7072
},
7173
"Exception" : null
7274
}, {
7375
"Method" : "HEAD",
7476
"Uri" : "https://REDACTED.blob.core.windows.net/$root/rootblob",
7577
"Headers" : {
76-
"x-ms-version" : "2020-06-12",
77-
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
78-
"x-ms-client-request-id" : "68b96a37-d2b8-4073-a00f-4bf017ddf7f6"
78+
"x-ms-version" : "2020-10-02",
79+
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
80+
"x-ms-client-request-id" : "3e7f1d02-df5d-4293-b2e5-bc2d3312835a"
7981
},
8082
"Response" : {
8183
"content-length" : "0",
82-
"x-ms-version" : "2020-06-12",
84+
"x-ms-version" : "2020-10-02",
8385
"x-ms-lease-status" : "unlocked",
8486
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
8587
"x-ms-lease-state" : "available",
8688
"x-ms-blob-committed-block-count" : "0",
87-
"Last-Modified" : "Tue, 04 May 2021 23:22:55 GMT",
89+
"Last-Modified" : "Thu, 15 Jul 2021 17:40:59 GMT",
8890
"retry-after" : "0",
8991
"StatusCode" : "200",
90-
"Date" : "Tue, 04 May 2021 23:22:55 GMT",
92+
"Date" : "Thu, 15 Jul 2021 17:40:59 GMT",
9193
"x-ms-blob-type" : "AppendBlob",
9294
"Accept-Ranges" : "bytes",
9395
"x-ms-server-encrypted" : "true",
96+
"Vary" : "Origin",
9497
"x-ms-creation-time" : "Tue, 04 May 2021 23:22:53 GMT",
95-
"eTag" : "0x8D90F538C12D69E",
96-
"x-ms-request-id" : "fe6d4a48-501e-0044-4d3c-41408e000000",
97-
"x-ms-client-request-id" : "68b96a37-d2b8-4073-a00f-4bf017ddf7f6",
98+
"eTag" : "0x8D947B7B52A6F16",
99+
"x-ms-request-id" : "ae05e8fc-d01e-0017-13a0-7963ba000000",
100+
"x-ms-client-request-id" : "3e7f1d02-df5d-4293-b2e5-bc2d3312835a",
98101
"Content-Type" : "application/octet-stream"
99102
},
100103
"Exception" : null
101-
}, {
102-
"Method" : "GET",
103-
"Uri" : "https://REDACTED.blob.core.windows.net?comp=list&prefix=4aae84e2",
104-
"Headers" : {
105-
"x-ms-version" : "2020-06-12",
106-
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
107-
"x-ms-client-request-id" : "ac161a73-b841-47f7-87dd-fc5b40e29935"
108-
},
109-
"Response" : {
110-
"Transfer-Encoding" : "chunked",
111-
"x-ms-version" : "2020-06-12",
112-
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
113-
"retry-after" : "0",
114-
"StatusCode" : "200",
115-
"x-ms-request-id" : "a671d6a9-601e-0070-043c-417346000000",
116-
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://kasobolcanadacentral.blob.core.windows.net/\"><Prefix>4aae84e2</Prefix><Containers><Container><Name>4aae84e204aae84e28f9364711d274cff7927418abdb</Name><Properties><Last-Modified>Tue, 04 May 2021 23:22:55 GMT</Last-Modified><Etag>\"0x8D90F538BFCB50D\"</Etag><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><DefaultEncryptionScope>$account-encryption-key</DefaultEncryptionScope><DenyEncryptionScopeOverride>false</DenyEncryptionScopeOverride><HasImmutabilityPolicy>false</HasImmutabilityPolicy><HasLegalHold>false</HasLegalHold></Properties></Container></Containers><NextMarker /></EnumerationResults>",
117-
"x-ms-client-request-id" : "ac161a73-b841-47f7-87dd-fc5b40e29935",
118-
"Date" : "Tue, 04 May 2021 23:22:55 GMT",
119-
"Content-Type" : "application/xml"
120-
},
121-
"Exception" : null
122-
}, {
123-
"Method" : "DELETE",
124-
"Uri" : "https://REDACTED.blob.core.windows.net/4aae84e204aae84e28f9364711d274cff7927418abdb?restype=container",
125-
"Headers" : {
126-
"x-ms-version" : "2020-06-12",
127-
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
128-
"x-ms-client-request-id" : "a128e0f3-f294-4fd6-94d6-2c8caf8cc4ee"
129-
},
130-
"Response" : {
131-
"content-length" : "0",
132-
"x-ms-version" : "2020-06-12",
133-
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
134-
"retry-after" : "0",
135-
"StatusCode" : "202",
136-
"x-ms-request-id" : "2e9fc8b2-701e-006c-163c-412126000000",
137-
"x-ms-client-request-id" : "a128e0f3-f294-4fd6-94d6-2c8caf8cc4ee",
138-
"Date" : "Tue, 04 May 2021 23:22:55 GMT"
139-
},
140-
"Exception" : null
141104
} ],
142-
"variables" : [ "4aae84e204aae84e28f9364711d274cff7927418abdb" ]
105+
"variables" : [ "4aae84e204aae84e2fad59110c3263b2de2244db8bad", "4aae84e23272910e", "4aae84e21808189a" ]
143106
}

0 commit comments

Comments
 (0)