Skip to content

Commit f729bea

Browse files
ensured test share paid bursting cleaned up resources and enforce existence of share (#36819)
1 parent 48cdbb2 commit f729bea

File tree

2 files changed

+89
-79
lines changed

2 files changed

+89
-79
lines changed

sdk/storage/azure-storage-file-share/tests/test_share.py

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,47 +1651,53 @@ def test_share_paid_bursting(self, **kwargs):
16511651
premium_storage_file_account_name = kwargs.pop("premium_storage_file_account_name")
16521652
premium_storage_file_account_key = kwargs.pop("premium_storage_file_account_key")
16531653

1654-
# Arrange
1655-
self._setup(premium_storage_file_account_name, premium_storage_file_account_key)
1656-
mibps = 10340
1657-
iops = 102400
1658-
1659-
# Act / Assert
1660-
share = self._create_share(
1661-
paid_bursting_enabled=True,
1662-
paid_bursting_bandwidth_mibps=5000,
1663-
paid_bursting_iops=1000
1664-
)
1665-
share_props = share.get_share_properties()
1666-
assert share_props.paid_bursting_enabled
1667-
assert share_props.paid_bursting_bandwidth_mibps == 5000
1668-
assert share_props.paid_bursting_iops == 1000
1669-
1670-
share.set_share_properties(
1671-
root_squash="NoRootSquash",
1672-
paid_bursting_enabled=True,
1673-
paid_bursting_bandwidth_mibps=mibps,
1674-
paid_bursting_iops=iops
1675-
)
1676-
share_props = share.get_share_properties()
1677-
share_name = share_props.name
1678-
assert share_props.paid_bursting_enabled
1679-
assert share_props.paid_bursting_bandwidth_mibps == mibps
1680-
assert share_props.paid_bursting_iops == iops
1681-
1682-
shares = list(self.fsc.list_shares())
1683-
assert shares is not None
1684-
assert len(shares) >= 1
1685-
for share in shares:
1686-
if share.name == share_name:
1687-
assert share is not None
1688-
assert share.paid_bursting_enabled
1689-
assert share.paid_bursting_bandwidth_mibps == mibps
1690-
assert share.paid_bursting_iops == iops
1691-
break
1692-
raise ValueError("Share with modified bursting values not found.")
1693-
1694-
self._delete_shares()
1654+
try:
1655+
# Arrange
1656+
self._setup(premium_storage_file_account_name, premium_storage_file_account_key)
1657+
mibps = 10340
1658+
iops = 102400
1659+
1660+
# Act / Assert
1661+
share = self._create_share(
1662+
paid_bursting_enabled=True,
1663+
paid_bursting_bandwidth_mibps=5000,
1664+
paid_bursting_iops=1000
1665+
)
1666+
share_props = share.get_share_properties()
1667+
assert share_props.paid_bursting_enabled
1668+
assert share_props.paid_bursting_bandwidth_mibps == 5000
1669+
assert share_props.paid_bursting_iops == 1000
1670+
1671+
share.set_share_properties(
1672+
root_squash="NoRootSquash",
1673+
paid_bursting_enabled=True,
1674+
paid_bursting_bandwidth_mibps=mibps,
1675+
paid_bursting_iops=iops
1676+
)
1677+
share_props = share.get_share_properties()
1678+
share_name = share_props.name
1679+
assert share_props.paid_bursting_enabled
1680+
assert share_props.paid_bursting_bandwidth_mibps == mibps
1681+
assert share_props.paid_bursting_iops == iops
1682+
1683+
shares = list(self.fsc.list_shares())
1684+
assert shares is not None
1685+
assert len(shares) >= 1
1686+
1687+
share_exists = False
1688+
for share in shares:
1689+
if share.name == share_name:
1690+
assert share is not None
1691+
assert share.paid_bursting_enabled
1692+
assert share.paid_bursting_bandwidth_mibps == mibps
1693+
assert share.paid_bursting_iops == iops
1694+
share_exists = True
1695+
break
1696+
1697+
if not share_exists:
1698+
raise ValueError("Share with modified bursting values not found.")
1699+
finally:
1700+
self._delete_shares()
16951701

16961702
@FileSharePreparer()
16971703
@recorded_by_proxy

sdk/storage/azure-storage-file-share/tests/test_share_async.py

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,44 +1689,48 @@ async def test_share_paid_bursting(self, **kwargs):
16891689
premium_storage_file_account_key = kwargs.pop("premium_storage_file_account_key")
16901690

16911691
# Arrange
1692-
self._setup(premium_storage_file_account_name, premium_storage_file_account_key)
1693-
mibps = 10340
1694-
iops = 102400
1695-
1696-
# Act / Assert
1697-
share = await self._create_share(
1698-
paid_bursting_enabled=True,
1699-
paid_bursting_bandwidth_mibps=5000,
1700-
paid_bursting_iops=1000
1701-
)
1702-
share_props = await share.get_share_properties()
1703-
share_name = share_props.name
1704-
assert share_props.paid_bursting_enabled
1705-
assert share_props.paid_bursting_bandwidth_mibps == 5000
1706-
assert share_props.paid_bursting_iops == 1000
1707-
1708-
await share.set_share_properties(
1709-
root_squash="NoRootSquash",
1710-
paid_bursting_enabled=True,
1711-
paid_bursting_bandwidth_mibps=mibps,
1712-
paid_bursting_iops=iops
1713-
)
1714-
share_props = await share.get_share_properties()
1715-
assert share_props.paid_bursting_enabled
1716-
assert share_props.paid_bursting_bandwidth_mibps == mibps
1717-
assert share_props.paid_bursting_iops == iops
1718-
1719-
async for share in self.fsc.list_shares():
1720-
if share.name == share_name:
1721-
1722-
assert share is not None
1723-
assert share.paid_bursting_enabled
1724-
assert share.paid_bursting_bandwidth_mibps == mibps
1725-
assert share.paid_bursting_iops == iops
1726-
break
1727-
raise ValueError("Share with modified bursting values not found.")
1728-
1729-
await self._delete_shares()
1692+
try:
1693+
self._setup(premium_storage_file_account_name, premium_storage_file_account_key)
1694+
mibps = 10340
1695+
iops = 102400
1696+
1697+
# Act / Assert
1698+
share = await self._create_share(
1699+
paid_bursting_enabled=True,
1700+
paid_bursting_bandwidth_mibps=5000,
1701+
paid_bursting_iops=1000
1702+
)
1703+
share_props = await share.get_share_properties()
1704+
share_name = share_props.name
1705+
assert share_props.paid_bursting_enabled
1706+
assert share_props.paid_bursting_bandwidth_mibps == 5000
1707+
assert share_props.paid_bursting_iops == 1000
1708+
1709+
await share.set_share_properties(
1710+
root_squash="NoRootSquash",
1711+
paid_bursting_enabled=True,
1712+
paid_bursting_bandwidth_mibps=mibps,
1713+
paid_bursting_iops=iops
1714+
)
1715+
share_props = await share.get_share_properties()
1716+
assert share_props.paid_bursting_enabled
1717+
assert share_props.paid_bursting_bandwidth_mibps == mibps
1718+
assert share_props.paid_bursting_iops == iops
1719+
1720+
share_exists = False
1721+
async for share in self.fsc.list_shares():
1722+
if share.name == share_name:
1723+
assert share is not None
1724+
assert share.paid_bursting_enabled
1725+
assert share.paid_bursting_bandwidth_mibps == mibps
1726+
assert share.paid_bursting_iops == iops
1727+
share_exists = True
1728+
break
1729+
1730+
if not share_exists:
1731+
raise ValueError("Share with modified bursting values not found.")
1732+
finally:
1733+
await self._delete_shares()
17301734

17311735
@FileSharePreparer()
17321736
@recorded_by_proxy_async

0 commit comments

Comments
 (0)