Skip to content

Commit

Permalink
[Storage] Fix flaky tests. (#22984)
Browse files Browse the repository at this point in the history
* unflaky tag tests.

* fix length check.

* fix test.

* pr feedback.
  • Loading branch information
kasobol-msft authored and gapra-msft committed Jul 22, 2021
1 parent 0d962c5 commit f6e1f3d
Show file tree
Hide file tree
Showing 190 changed files with 9,334 additions and 16,576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ import java.util.stream.Collectors

class ContainerAPITest extends APISpec {

String tagKey
String tagValue

def setup() {
tagKey = namer.getRandomName(20)
tagValue = namer.getRandomName(20)
}

def "Create all null"() {
setup:
// Overwrite the existing cc, which has already been created
Expand Down Expand Up @@ -732,7 +740,7 @@ class ContainerAPITest extends APISpec {

def tagsBlob = cc.getBlobClient(tagsName).getPageBlobClient()
def tags = new HashMap<String, String>()
tags.put("tag", "value")
tags.put(tagKey, tagValue)
tagsBlob.createWithResponse(new PageBlobCreateOptions(512).setTags(tags), null, null)

def uncommittedBlob = cc.getBlobClient(uncommittedName).getBlockBlobClient()
Expand Down Expand Up @@ -819,7 +827,7 @@ class ContainerAPITest extends APISpec {
blobs.get(1).getProperties().getCopyCompletionTime() == null
blobs.get(2).getName() == metadataName
blobs.get(2).getMetadata() == null
blobs.get(3).getTags().get("tag") == "value"
blobs.get(3).getTags().get(tagKey) == tagValue
blobs.get(3).getProperties().getTagCount() == 1
blobs.size() == 4 // Normal, copy, metadata, tags
}
Expand Down Expand Up @@ -1224,7 +1232,7 @@ class ContainerAPITest extends APISpec {
blobs.get(1).getProperties().getCopyCompletionTime() == null
blobs.get(2).getName() == metadataName
blobs.get(2).getMetadata() == null
blobs.get(3).getTags().get("tag") == "value"
blobs.get(3).getTags().get(tagKey) == tagValue
blobs.get(3).getProperties().getTagCount() == 1
blobs.size() == 4 // Normal, copy, metadata, tags
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ import java.time.OffsetDateTime
@ResourceLock("ServiceProperties")
class ServiceAPITest extends APISpec {

BlobServiceClient anonymousClient;
BlobServiceClient anonymousClient
String tagKey
String tagValue

def setup() {
setup:
Expand All @@ -67,6 +69,9 @@ class ServiceAPITest extends APISpec {
.setLogging(new BlobAnalyticsLogging().setVersion("1.0")
.setRetentionPolicy(disabled))
.setDefaultServiceVersion("2018-03-28"))

tagKey = namer.getRandomName(20)
tagValue = namer.getRandomName(20)
}

def cleanup() {
Expand Down Expand Up @@ -370,22 +375,22 @@ class ServiceAPITest extends APISpec {
def "Find blobs marker"() {
setup:
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
def tags = Collections.singletonMap("tag", "value")
def tags = Collections.singletonMap(tagKey, tagValue)
for (int i = 0; i < 10; i++) {
cc.getBlobClient(generateBlobName()).uploadWithResponse(
new BlobParallelUploadOptions(data.defaultInputStream, data.defaultDataSize).setTags(tags), null, null)
}

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

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

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

expect:
Expand All @@ -402,7 +407,7 @@ class ServiceAPITest extends APISpec {
def NUM_BLOBS = 7
def PAGE_RESULTS = 3
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
def tags = Collections.singletonMap("tag", "value")
def tags = Collections.singletonMap(tagKey, tagValue)

for (i in (1..NUM_BLOBS)) {
cc.getBlobClient(generateBlobName()).uploadWithResponse(
Expand All @@ -412,7 +417,7 @@ class ServiceAPITest extends APISpec {
expect:
for (ContinuablePage page :
primaryBlobServiceClient.findBlobsByTags(
new FindBlobsOptions("\"tag\"='value'").setMaxResultsPerPage(PAGE_RESULTS), null, Context.NONE)
new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(PAGE_RESULTS), null, Context.NONE)
.iterableByPage()) {
assert page.iterator().size() <= PAGE_RESULTS
}
Expand All @@ -427,7 +432,7 @@ class ServiceAPITest extends APISpec {
def NUM_BLOBS = 7
def PAGE_RESULTS = 3
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
def tags = Collections.singletonMap("tag", "value")
def tags = Collections.singletonMap(tagKey, tagValue)

for (i in (1..NUM_BLOBS)) {
cc.getBlobClient(generateBlobName()).uploadWithResponse(
Expand All @@ -437,7 +442,7 @@ class ServiceAPITest extends APISpec {
expect:
for (ContinuablePage page :
primaryBlobServiceClient.findBlobsByTags(
new FindBlobsOptions("\"tag\"='value'"), null, Context.NONE)
new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)), null, Context.NONE)
.iterableByPage(PAGE_RESULTS)) {
assert page.iterator().size() <= PAGE_RESULTS
}
Expand Down Expand Up @@ -469,15 +474,15 @@ class ServiceAPITest extends APISpec {
def NUM_BLOBS = 5
def PAGE_RESULTS = 3
def cc = primaryBlobServiceClient.createBlobContainer(generateContainerName())
def tags = Collections.singletonMap("tag", "value")
def tags = Collections.singletonMap(tagKey, tagValue)

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ class BlockBlobAPITest extends APISpec {
@LiveOnly
def "Upload from file with tags"() {
given:
def tags = Collections.singletonMap("tag", "value")
def tags = Collections.singletonMap(namer.getRandomName(20), namer.getRandomName(20))
def file = getRandomFile(Constants.KB)
def outStream = new ByteArrayOutputStream()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class HelperTest extends APISpec {

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,143 +1,106 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/4aae84e204aae84e28f9364711d274cff7927418abdb?restype=container",
"Uri" : "https://REDACTED.blob.core.windows.net/4aae84e204aae84e2fad59110c3263b2de2244db8bad?restype=container",
"Headers" : {
"x-ms-version" : "2020-06-12",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
"x-ms-client-request-id" : "847ac51f-59a7-443a-a715-16f3ca46d793"
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
"x-ms-client-request-id" : "4e20c39a-d9d0-4558-869e-e227900d2e34"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-06-12",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D90F538BFCB50D",
"Last-Modified" : "Tue, 04 May 2021 23:22:55 GMT",
"eTag" : "0x8D947B7B4FC84A3",
"Last-Modified" : "Thu, 15 Jul 2021 17:40:59 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "07eb63f5-501e-0019-7b3c-414a0a000000",
"x-ms-client-request-id" : "847ac51f-59a7-443a-a715-16f3ca46d793",
"Date" : "Tue, 04 May 2021 23:22:55 GMT"
"x-ms-request-id" : "aa022f04-601e-004f-0ba0-79bbe5000000",
"x-ms-client-request-id" : "4e20c39a-d9d0-4558-869e-e227900d2e34",
"Date" : "Thu, 15 Jul 2021 17:40:58 GMT"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/$root?restype=container",
"Headers" : {
"x-ms-version" : "2020-06-12",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
"x-ms-client-request-id" : "1612b2ad-3a8e-4328-bda1-0cabb8b9a06d"
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
"x-ms-client-request-id" : "393407cb-62e3-4e09-8a36-119a77a0da94"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-06-12",
"x-ms-version" : "2020-10-02",
"x-ms-lease-status" : "unlocked",
"x-ms-immutable-storage-with-versioning-enabled" : "false",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-lease-state" : "available",
"x-ms-deny-encryption-scope-override" : "false",
"Last-Modified" : "Tue, 04 May 2021 23:22:53 GMT",
"retry-after" : "0",
"StatusCode" : "200",
"x-ms-has-legal-hold" : "false",
"Date" : "Tue, 04 May 2021 23:22:54 GMT",
"Date" : "Thu, 15 Jul 2021 17:40:58 GMT",
"x-ms-default-encryption-scope" : "$account-encryption-key",
"x-ms-has-immutability-policy" : "false",
"Vary" : "Origin",
"eTag" : "0x8D90F538AA49CDE",
"x-ms-request-id" : "8783dac2-c01e-0079-423c-413695000000",
"x-ms-client-request-id" : "1612b2ad-3a8e-4328-bda1-0cabb8b9a06d"
"x-ms-request-id" : "f6e8f8ba-501e-0019-36a0-794a0a000000",
"x-ms-client-request-id" : "393407cb-62e3-4e09-8a36-119a77a0da94"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/$root/rootblob",
"Headers" : {
"x-ms-version" : "2020-06-12",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
"x-ms-client-request-id" : "4164acde-d8d3-44e1-8e74-0e8ada18bb52"
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
"x-ms-client-request-id" : "7f4028c9-3697-417e-bf6f-979d2d2b64d6"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-06-12",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D90F538C12D69E",
"Last-Modified" : "Tue, 04 May 2021 23:22:55 GMT",
"eTag" : "0x8D947B7B5253E04",
"Last-Modified" : "Thu, 15 Jul 2021 17:40:59 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "55bbaf08-f01e-0010-293c-410fd9000000",
"x-ms-request-id" : "c88ef9fb-a01e-0022-30a0-790fae000000",
"x-ms-request-server-encrypted" : "true",
"x-ms-client-request-id" : "4164acde-d8d3-44e1-8e74-0e8ada18bb52",
"Date" : "Tue, 04 May 2021 23:22:55 GMT"
"x-ms-client-request-id" : "7f4028c9-3697-417e-bf6f-979d2d2b64d6",
"Date" : "Thu, 15 Jul 2021 17:40:58 GMT"
},
"Exception" : null
}, {
"Method" : "HEAD",
"Uri" : "https://REDACTED.blob.core.windows.net/$root/rootblob",
"Headers" : {
"x-ms-version" : "2020-06-12",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
"x-ms-client-request-id" : "68b96a37-d2b8-4073-a00f-4bf017ddf7f6"
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
"x-ms-client-request-id" : "3e7f1d02-df5d-4293-b2e5-bc2d3312835a"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-06-12",
"x-ms-version" : "2020-10-02",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-lease-state" : "available",
"x-ms-blob-committed-block-count" : "0",
"Last-Modified" : "Tue, 04 May 2021 23:22:55 GMT",
"Last-Modified" : "Thu, 15 Jul 2021 17:40:59 GMT",
"retry-after" : "0",
"StatusCode" : "200",
"Date" : "Tue, 04 May 2021 23:22:55 GMT",
"Date" : "Thu, 15 Jul 2021 17:40:59 GMT",
"x-ms-blob-type" : "AppendBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"Vary" : "Origin",
"x-ms-creation-time" : "Tue, 04 May 2021 23:22:53 GMT",
"eTag" : "0x8D90F538C12D69E",
"x-ms-request-id" : "fe6d4a48-501e-0044-4d3c-41408e000000",
"x-ms-client-request-id" : "68b96a37-d2b8-4073-a00f-4bf017ddf7f6",
"eTag" : "0x8D947B7B52A6F16",
"x-ms-request-id" : "ae05e8fc-d01e-0017-13a0-7963ba000000",
"x-ms-client-request-id" : "3e7f1d02-df5d-4293-b2e5-bc2d3312835a",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net?comp=list&prefix=4aae84e2",
"Headers" : {
"x-ms-version" : "2020-06-12",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
"x-ms-client-request-id" : "ac161a73-b841-47f7-87dd-fc5b40e29935"
},
"Response" : {
"Transfer-Encoding" : "chunked",
"x-ms-version" : "2020-06-12",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"StatusCode" : "200",
"x-ms-request-id" : "a671d6a9-601e-0070-043c-417346000000",
"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>",
"x-ms-client-request-id" : "ac161a73-b841-47f7-87dd-fc5b40e29935",
"Date" : "Tue, 04 May 2021 23:22:55 GMT",
"Content-Type" : "application/xml"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://REDACTED.blob.core.windows.net/4aae84e204aae84e28f9364711d274cff7927418abdb?restype=container",
"Headers" : {
"x-ms-version" : "2020-06-12",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.1 (11.0.8; Windows 10; 10.0)",
"x-ms-client-request-id" : "a128e0f3-f294-4fd6-94d6-2c8caf8cc4ee"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-06-12",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"StatusCode" : "202",
"x-ms-request-id" : "2e9fc8b2-701e-006c-163c-412126000000",
"x-ms-client-request-id" : "a128e0f3-f294-4fd6-94d6-2c8caf8cc4ee",
"Date" : "Tue, 04 May 2021 23:22:55 GMT"
},
"Exception" : null
} ],
"variables" : [ "4aae84e204aae84e28f9364711d274cff7927418abdb" ]
"variables" : [ "4aae84e204aae84e2fad59110c3263b2de2244db8bad", "4aae84e23272910e", "4aae84e21808189a" ]
}
Loading

0 comments on commit f6e1f3d

Please sign in to comment.