Skip to content

Commit cd5ecc5

Browse files
[Storage] Fix 100 Live Tests (#44108)
1 parent 0268857 commit cd5ecc5

File tree

9 files changed

+55
-30
lines changed

9 files changed

+55
-30
lines changed

sdk/storage/azure-storage-blob/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/storage/azure-storage-blob",
5-
"Tag": "python/storage/azure-storage-blob_c54a27449c"
5+
"Tag": "python/storage/azure-storage-blob_5a54b5cd9f"
66
}

sdk/storage/azure-storage-blob/tests/test_blob_tags.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,19 @@ def test_set_blob_tags_using_blob_sas(self, **kwargs):
529529
def test_blob_tags_conditional_headers(self, **kwargs):
530530
storage_account_name = kwargs.pop("storage_account_name")
531531
storage_account_key = kwargs.pop("storage_account_key")
532-
variables = kwargs.pop("variables", {})
533532

534533
self._setup(storage_account_name, storage_account_key)
535534

536535
blob_name = self._get_blob_reference()
537536
blob = self.bsc.get_blob_client(self.container_name, blob_name)
538537
first_resp = blob.upload_blob(b"abc123", overwrite=True)
539-
early = self.get_datetime_variable(
540-
variables, 'expiry_time', datetime.utcnow()
541-
)
538+
early = blob.get_blob_properties().last_modified
542539
first_tags = {"tag1": "firsttag", "tag2": "secondtag", "tag3": "thirdtag"}
543540
second_tags = {"tag4": "fourthtag", "tag5": "fifthtag", "tag6": "sixthtag"}
544541

542+
if self.is_live:
543+
sleep(10)
544+
545545
with pytest.raises(ResourceModifiedError):
546546
blob.set_blob_tags(first_tags, if_modified_since=early)
547547
with pytest.raises(ResourceModifiedError):
@@ -574,6 +574,4 @@ def test_blob_tags_conditional_headers(self, **kwargs):
574574
tags = blob.get_blob_tags(etag=first_resp['etag'], match_condition=MatchConditions.IfModified)
575575
assert tags == second_tags
576576

577-
return variables
578-
579577
#------------------------------------------------------------------------------

sdk/storage/azure-storage-blob/tests/test_blob_tags_async.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,19 +440,19 @@ async def test_filter_blobs(self, **kwargs):
440440
async def test_blob_tags_conditional_headers(self, **kwargs):
441441
storage_account_name = kwargs.pop("storage_account_name")
442442
storage_account_key = kwargs.pop("storage_account_key")
443-
variables = kwargs.pop("variables", {})
444443

445444
await self._setup(storage_account_name, storage_account_key)
446445

447446
blob_name = self._get_blob_reference()
448447
blob = self.bsc.get_blob_client(self.container_name, blob_name)
449448
first_resp = await blob.upload_blob(b"abc123", overwrite=True)
450-
early = self.get_datetime_variable(
451-
variables, 'expiry_time', datetime.utcnow()
452-
)
449+
early = (await blob.get_blob_properties()).last_modified
453450
first_tags = {"tag1": "firsttag", "tag2": "secondtag", "tag3": "thirdtag"}
454451
second_tags = {"tag4": "fourthtag", "tag5": "fifthtag", "tag6": "sixthtag"}
455452

453+
if self.is_live:
454+
sleep(10)
455+
456456
with pytest.raises(ResourceModifiedError):
457457
await blob.set_blob_tags(first_tags, if_modified_since=early)
458458
with pytest.raises(ResourceModifiedError):
@@ -485,6 +485,4 @@ async def test_blob_tags_conditional_headers(self, **kwargs):
485485
tags = await blob.get_blob_tags(etag=first_resp['etag'], match_condition=MatchConditions.IfModified)
486486
assert tags == second_tags
487487

488-
return variables
489-
490488
#------------------------------------------------------------------------------

sdk/storage/azure-storage-blob/tests/test_block_blob_async.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,10 @@ async def test_put_block_list_with_md5(self, **kwargs):
908908

909909
@BlobPreparer()
910910
@recorded_by_proxy_async
911-
async def test_put_block_list_with_blob_tier_specified(self, storage_account_name, storage_account_key):
911+
async def test_put_block_list_with_blob_tier_specified(self, **kwargs):
912+
storage_account_name = kwargs.pop("storage_account_name")
913+
storage_account_key = kwargs.pop("storage_account_key")
914+
912915
# Arrange
913916
await self._setup(storage_account_name, storage_account_key)
914917
blob_name = self._get_blob_reference()
@@ -929,7 +932,10 @@ async def test_put_block_list_with_blob_tier_specified(self, storage_account_nam
929932

930933
@BlobPreparer()
931934
@recorded_by_proxy_async
932-
async def test_put_block_list_with_blob_tier_specified_cold(self, storage_account_name, storage_account_key):
935+
async def test_put_block_list_with_blob_tier_specified_cold(self, **kwargs):
936+
storage_account_name = kwargs.pop("storage_account_name")
937+
storage_account_key = kwargs.pop("storage_account_key")
938+
933939
# Arrange
934940
await self._setup(storage_account_name, storage_account_key)
935941
blob_name = self._get_blob_reference()
@@ -1418,7 +1424,10 @@ async def test_create_blob_from_bytes_non_parallel(self, **kwargs):
14181424

14191425
@BlobPreparer()
14201426
@recorded_by_proxy_async
1421-
async def test_create_blob_from_bytes_with_blob_tier_specified(self, storage_account_name, storage_account_key):
1427+
async def test_create_blob_from_bytes_with_blob_tier_specified(self, **kwargs):
1428+
storage_account_name = kwargs.pop("storage_account_name")
1429+
storage_account_key = kwargs.pop("storage_account_key")
1430+
14221431
# Arrange
14231432
await self._setup(storage_account_name, storage_account_key)
14241433
blob_name = self._get_blob_reference()
@@ -1484,7 +1493,10 @@ async def test_create_blob_from_path_non_parallel(self, **kwargs):
14841493

14851494
@BlobPreparer()
14861495
@recorded_by_proxy_async
1487-
async def test_upload_blob_from_path_non_parallel_with_standard_blob_tier(self, storage_account_name, storage_account_key):
1496+
async def test_upload_blob_from_path_non_parallel_with_standard_blob_tier(self, **kwargs):
1497+
storage_account_name = kwargs.pop("storage_account_name")
1498+
storage_account_key = kwargs.pop("storage_account_key")
1499+
14881500
# Arrange
14891501
await self._setup(storage_account_name, storage_account_key)
14901502
blob_name = self._get_blob_reference()

sdk/storage/azure-storage-blob/tests/test_container.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,8 +2594,10 @@ def test_download_blob_modified(self, **kwargs):
25942594

25952595
@BlobPreparer()
25962596
@recorded_by_proxy
2597-
def test_download_blob_in_chunks_where_maxsinglegetsize_not_multiple_of_chunksize(
2598-
self, storage_account_name, storage_account_key):
2597+
def test_download_blob_in_chunks_where_maxsinglegetsize_not_multiple_of_chunksize(self, **kwargs):
2598+
storage_account_name = kwargs.pop("storage_account_name")
2599+
storage_account_key = kwargs.pop("storage_account_key")
2600+
25992601
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key,
26002602
max_single_get_size=1024,
26012603
max_chunk_get_size=666)

sdk/storage/azure-storage-blob/tests/test_page_blob_async.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,10 @@ async def test_blob_tier_copy_blob(self, **kwargs):
22052205

22062206
@BlobPreparer()
22072207
@recorded_by_proxy_async
2208-
async def test_download_sparse_page_blob(self, storage_account_name, storage_account_key):
2208+
async def test_download_sparse_page_blob(self, **kwargs):
2209+
storage_account_name = kwargs.pop("storage_account_name")
2210+
storage_account_key = kwargs.pop("storage_account_key")
2211+
22092212
# Arrange
22102213
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key, max_page_size=4 * 1024)
22112214
await self._setup(bsc)

sdk/storage/azure-storage-queue/tests/test_queue.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ def test_get_user_delegation_sas(self, **kwargs):
14651465

14661466
@pytest.mark.live_test_only
14671467
@QueuePreparer()
1468-
def test_user_delegation_oid(self, **kwargs):
1468+
def test_queue_user_delegation_oid(self, **kwargs):
14691469
storage_account_name = kwargs.pop("storage_account_name")
14701470
storage_account_key = kwargs.pop("storage_account_key")
14711471
message = "addedmessage"
@@ -1487,7 +1487,7 @@ def test_user_delegation_oid(self, **kwargs):
14871487
queue.account_name,
14881488
queue.queue_name,
14891489
storage_account_key,
1490-
permission=QueueSasPermissions(add=True),
1490+
permission=QueueSasPermissions(add=True, read=True, process=True),
14911491
expiry=expiry,
14921492
user_delegation_key=user_delegation_key,
14931493
user_delegation_oid=user_delegation_oid,
@@ -1497,8 +1497,9 @@ def test_user_delegation_oid(self, **kwargs):
14971497
queue_msg = queue_client.send_message(message)
14981498
assert queue_msg is not None
14991499

1500-
result = next(queue.receive_messages())
1501-
assert message == result.content
1500+
messages = list(queue_client.receive_messages())
1501+
assert len(messages) > 0
1502+
assert message == messages[0].content
15021503

15031504

15041505
# ------------------------------------------------------------------------------

sdk/storage/azure-storage-queue/tests/test_queue_async.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ async def test_get_user_delegation_sas(self, **kwargs):
14831483

14841484
@pytest.mark.live_test_only
14851485
@QueuePreparer()
1486-
async def test_user_delegation_oid(self, **kwargs):
1486+
async def test_queue_user_delegation_oid(self, **kwargs):
14871487
storage_account_name = kwargs.pop("storage_account_name")
14881488
storage_account_key = kwargs.pop("storage_account_key")
14891489
message = "addedmessage"
@@ -1505,7 +1505,7 @@ async def test_user_delegation_oid(self, **kwargs):
15051505
queue.account_name,
15061506
queue.queue_name,
15071507
storage_account_key,
1508-
permission=QueueSasPermissions(add=True),
1508+
permission=QueueSasPermissions(add=True, read=True, process=True),
15091509
expiry=expiry,
15101510
user_delegation_key=user_delegation_key,
15111511
user_delegation_oid=user_delegation_oid,
@@ -1515,12 +1515,10 @@ async def test_user_delegation_oid(self, **kwargs):
15151515
queue_msg = await queue_client.send_message(message)
15161516
assert queue_msg is not None
15171517

1518-
result = anext(queue.receive_messages())
1519-
assert message == result.content
1520-
15211518
messages = []
1522-
async for m in queue.receive_messages():
1519+
async for m in queue_client.receive_messages():
15231520
messages.append(m)
1521+
assert len(messages) > 0
15241522
assert message == messages[0].content
15251523

15261524

sdk/storage/test-resources.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"fileDataPrivilegedContributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/69566ab7-960f-475b-8e7c-b3118f30c6bd')]",
3232
"contributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c')]",
3333
"blobDataOwnerRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
34+
"queueDataContributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/974c5e8b-45b9-4653-ba55-5f855dd0fb88')]",
3435
"primaryAccountName": "[concat('prim', parameters('baseName'))]",
3536
"secondaryAccountName": "[concat('sec', parameters('baseName'))]",
3637
"softDeleteAccountName": "[concat('sftdl', parameters('baseName'))]",
@@ -58,6 +59,18 @@
5859
"principalId": "[parameters('testApplicationOid')]"
5960
}
6061
},
62+
{
63+
"type": "Microsoft.Authorization/roleAssignments",
64+
"apiVersion": "[variables('authorizationApiVersion')]",
65+
"name": "[guid(concat('queueDataContributorRoleId', variables('primaryAccountName')))]",
66+
"dependsOn": [
67+
"[variables('primaryAccountName')]"
68+
],
69+
"properties": {
70+
"roleDefinitionId": "[variables('queueDataContributorRoleId')]",
71+
"principalId": "[parameters('testApplicationOid')]"
72+
}
73+
},
6174
{
6275
"type": "Microsoft.Authorization/roleAssignments",
6376
"apiVersion": "[variables('authorizationApiVersion')]",

0 commit comments

Comments
 (0)