-
Notifications
You must be signed in to change notification settings - Fork 3k
[Perfstress][Storage] Added Blobs perf tests #15833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4b8899e
First pass
annatisch dd76b2e
Update blob tests
annatisch 357d200
Added writestream to framework
annatisch 23eeecc
Blob tests memory
annatisch ca04d23
Make streams seekable
annatisch 239e8d1
Fix upload tests
annatisch 2c17bc0
More efficient upload
annatisch d4750b8
Fix listing memory
annatisch 8dd2f72
Support reset between iterations
annatisch 26c5231
Some efficiencies
annatisch 12fb962
Rethink of reset
annatisch 415be89
Reset first
annatisch ad5470a
Added readme
annatisch 74379d8
Fix readme typo
annatisch 6403641
Merge branch 'master' into perfstress_tests_blob
annatisch fb526a7
Updated readme with env var info
annatisch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
51 changes: 51 additions & 0 deletions
51
sdk/storage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/_test_base_legacy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
import uuid | ||
|
||
from azure_devtools.perfstress_tests import PerfStressTest | ||
|
||
from azure.storage.blob import BlockBlobService | ||
|
||
class _LegacyServiceTest(PerfStressTest): | ||
service_client = None | ||
async_service_client = None | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
connection_string = self.get_from_env("AZURE_STORAGE_CONNECTION_STRING") | ||
if not _LegacyServiceTest.service_client or self.args.no_client_share: | ||
_LegacyServiceTest.service_client = BlockBlobService(connection_string=connection_string) | ||
_LegacyServiceTest.service_client.MAX_SINGLE_PUT_SIZE = self.args.max_put_size | ||
_LegacyServiceTest.service_client.MAX_BLOCK_SIZE = self.args.max_block_size | ||
_LegacyServiceTest.service_client.MIN_LARGE_BLOCK_UPLOAD_THRESHOLD = self.args.buffer_threshold | ||
self.async_service_client = None | ||
self.service_client = _LegacyServiceTest.service_client | ||
|
||
@staticmethod | ||
def add_arguments(parser): | ||
super(_LegacyServiceTest, _LegacyServiceTest).add_arguments(parser) | ||
parser.add_argument('--max-put-size', nargs='?', type=int, help='Maximum size of data uploading in single HTTP PUT. Defaults to 64*1024*1024', default=64*1024*1024) | ||
parser.add_argument('--max-block-size', nargs='?', type=int, help='Maximum size of data in a block within a blob. Defaults to 4*1024*1024', default=4*1024*1024) | ||
parser.add_argument('--buffer-threshold', nargs='?', type=int, help='Minimum block size to prevent full block buffering. Defaults to 4*1024*1024+1', default=4*1024*1024+1) | ||
parser.add_argument('-c', '--max-concurrency', nargs='?', type=int, help='Maximum number of concurrent threads used for data transfer. Defaults to 1', default=1) | ||
parser.add_argument('-s', '--size', nargs='?', type=int, help='Size of data to transfer. Default is 10240.', default=10240) | ||
parser.add_argument('--no-client-share', action='store_true', help='Create one ServiceClient per test instance. Default is to share a single ServiceClient.', default=False) | ||
|
||
|
||
class _LegacyContainerTest(_LegacyServiceTest): | ||
container_name = "perfstress-legacy-" + str(uuid.uuid4()) | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
self.service_client.create_container(self.container_name) | ||
|
||
async def global_cleanup(self): | ||
self.service_client.delete_container(self.container_name) | ||
await super().global_cleanup() |
36 changes: 36 additions & 0 deletions
36
sdk/storage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/download.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure_devtools.perfstress_tests import get_random_bytes, WriteStream | ||
|
||
from ._test_base_legacy import _LegacyContainerTest | ||
|
||
|
||
class LegacyDownloadTest(_LegacyContainerTest): | ||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
self.blob_name = "downloadtest" | ||
self.download_stream = WriteStream() | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
data = get_random_bytes(self.args.size) | ||
self.service_client.create_blob_from_bytes( | ||
container_name=self.container_name, | ||
blob_name=self.blob_name, | ||
blob=data) | ||
|
||
def reset_sync(self): | ||
self.download_stream = WriteStream() | ||
|
||
def run_sync(self): | ||
self.service_client.get_blob_to_stream( | ||
container_name=self.container_name, | ||
blob_name=self.blob_name, | ||
stream=self.download_stream, | ||
max_connections=self.args.max_concurrency) | ||
|
||
async def run_async(self): | ||
raise NotImplementedError("Async not supported for legacy T1 tests.") |
29 changes: 29 additions & 0 deletions
29
sdk/storage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/list_blobs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from ._test_base_legacy import _LegacyContainerTest | ||
|
||
|
||
class LegacyListBlobsTest(_LegacyContainerTest): | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
for i in range(self.args.num_blobs): | ||
mikeharder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.service_client.create_blob_from_bytes( | ||
container_name=self.container_name, | ||
blob_name="listtest" + str(i), | ||
blob=b"") | ||
|
||
def run_sync(self): | ||
for _ in self.service_client.list_blobs(container_name=self.container_name): | ||
pass | ||
|
||
async def run_async(self): | ||
raise NotImplementedError("Async not supported for legacy T1 tests.") | ||
|
||
@staticmethod | ||
def add_arguments(parser): | ||
super(LegacyListBlobsTest, LegacyListBlobsTest).add_arguments(parser) | ||
parser.add_argument('--num-blobs', nargs='?', type=int, help='Number of blobs to list. Defaults to 100', default=100) |
1 change: 1 addition & 0 deletions
1
...torage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/t1_test_requirements.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
azure-storage-blob==2.1.0 |
30 changes: 30 additions & 0 deletions
30
sdk/storage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/upload.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import uuid | ||
|
||
from azure_devtools.perfstress_tests import RandomStream | ||
|
||
from ._test_base_legacy import _LegacyContainerTest | ||
|
||
|
||
class LegacyUploadTest(_LegacyContainerTest): | ||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
self.blob_name = "blobtest-" + str(uuid.uuid4()) | ||
self.upload_stream = RandomStream(self.args.size) | ||
|
||
def reset_sync(self): | ||
self.upload_stream = RandomStream(self.args.size) | ||
|
||
def run_sync(self): | ||
self.service_client.create_blob_from_stream( | ||
container_name=self.container_name, | ||
blob_name=self.blob_name, | ||
stream=self.upload_stream, | ||
max_connections=self.args.max_concurrency) | ||
|
||
async def run_async(self): | ||
raise NotImplementedError("Async not supported for legacy T1 tests.") |
28 changes: 28 additions & 0 deletions
28
sdk/storage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/upload_block.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import uuid | ||
|
||
from azure_devtools.perfstress_tests import get_random_bytes | ||
|
||
from ._test_base_legacy import _LegacyContainerTest | ||
|
||
|
||
class LegacyUploadBlockTest(_LegacyContainerTest): | ||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
self.blob_name = "blobblocktest-" + str(uuid.uuid4()) | ||
self.block_id = str(uuid.uuid4()) | ||
self.data = get_random_bytes(self.args.size) | ||
|
||
def run_sync(self): | ||
self.service_client.put_block( | ||
container_name=self.container_name, | ||
blob_name=self.blob_name, | ||
block=self.data, | ||
block_id=self.block_id) | ||
|
||
async def run_async(self): | ||
raise NotImplementedError("Async not supported for legacy T1 tests.") |
41 changes: 41 additions & 0 deletions
41
sdk/storage/azure-storage-blob/tests/perfstress_tests/T1_legacy_tests/upload_from_file.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
import tempfile | ||
import uuid | ||
|
||
from azure_devtools.perfstress_tests import get_random_bytes | ||
|
||
from ._test_base_legacy import _LegacyContainerTest | ||
|
||
|
||
class LegacyUploadFromFileTest(_LegacyContainerTest): | ||
temp_file = None | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
self.blob_name = "containertest-" + str(uuid.uuid4()) | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
data = get_random_bytes(self.args.size) | ||
with tempfile.NamedTemporaryFile(delete=False) as temp_file: | ||
LegacyUploadFromFileTest.temp_file = temp_file.name | ||
temp_file.write(data) | ||
|
||
async def global_cleanup(self): | ||
os.remove(LegacyUploadFromFileTest.temp_file) | ||
await super().global_cleanup() | ||
|
||
def run_sync(self): | ||
self.service_client.create_blob_from_path( | ||
container_name=self.container_name, | ||
blob_name=self.blob_name, | ||
file_path=LegacyUploadFromFileTest.temp_file, | ||
max_connections=self.args.max_concurrency) | ||
|
||
async def run_async(self): | ||
raise NotImplementedError("Async not supported for legacy T1 tests.") |
Empty file.
78 changes: 78 additions & 0 deletions
78
sdk/storage/azure-storage-blob/tests/perfstress_tests/_test_base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
import uuid | ||
|
||
from azure_devtools.perfstress_tests import PerfStressTest | ||
|
||
from azure.core.exceptions import ResourceNotFoundError | ||
from azure.storage.blob import BlobServiceClient as SyncBlobServiceClient | ||
from azure.storage.blob.aio import BlobServiceClient as AsyncBlobServiceClient | ||
|
||
|
||
class _ServiceTest(PerfStressTest): | ||
service_client = None | ||
async_service_client = None | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
connection_string = self.get_from_env("AZURE_STORAGE_CONNECTION_STRING") | ||
kwargs = {} | ||
kwargs['max_single_put_size'] = self.args.max_put_size | ||
kwargs['max_block_size'] = self.args.max_block_size | ||
kwargs['min_large_block_upload_threshold'] = self.args.buffer_threshold | ||
if not _ServiceTest.service_client or self.args.no_client_share: | ||
_ServiceTest.service_client = SyncBlobServiceClient.from_connection_string(conn_str=connection_string, **kwargs) | ||
_ServiceTest.async_service_client = AsyncBlobServiceClient.from_connection_string(conn_str=connection_string, **kwargs) | ||
self.service_client = _ServiceTest.service_client | ||
self.async_service_client =_ServiceTest.async_service_client | ||
|
||
async def close(self): | ||
await self.async_service_client.close() | ||
await super().close() | ||
|
||
@staticmethod | ||
def add_arguments(parser): | ||
super(_ServiceTest, _ServiceTest).add_arguments(parser) | ||
parser.add_argument('--max-put-size', nargs='?', type=int, help='Maximum size of data uploading in single HTTP PUT. Defaults to 64*1024*1024', default=64*1024*1024) | ||
parser.add_argument('--max-block-size', nargs='?', type=int, help='Maximum size of data in a block within a blob. Defaults to 4*1024*1024', default=4*1024*1024) | ||
parser.add_argument('--buffer-threshold', nargs='?', type=int, help='Minimum block size to prevent full block buffering. Defaults to 4*1024*1024+1', default=4*1024*1024+1) | ||
parser.add_argument('-c', '--max-concurrency', nargs='?', type=int, help='Maximum number of concurrent threads used for data transfer. Defaults to 1', default=1) | ||
parser.add_argument('-s', '--size', nargs='?', type=int, help='Size of data to transfer. Default is 10240.', default=10240) | ||
parser.add_argument('--no-client-share', action='store_true', help='Create one ServiceClient per test instance. Default is to share a single ServiceClient.', default=False) | ||
|
||
|
||
class _ContainerTest(_ServiceTest): | ||
container_name = "perfstress-" + str(uuid.uuid4()) | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
self.container_client = self.service_client.get_container_client(self.container_name) | ||
self.async_container_client = self.async_service_client.get_container_client(self.container_name) | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
await self.async_container_client.create_container() | ||
|
||
async def global_cleanup(self): | ||
await self.async_container_client.delete_container() | ||
await super().global_cleanup() | ||
|
||
async def close(self): | ||
await self.async_container_client.close() | ||
await super().close() | ||
|
||
|
||
class _BlobTest(_ContainerTest): | ||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
blob_name = "blobtest-" + str(uuid.uuid4()) | ||
self.blob_client = self.container_client.get_blob_client(blob_name) | ||
self.async_blob_client = self.async_container_client.get_blob_client(blob_name) | ||
|
||
async def close(self): | ||
await self.async_blob_client.close() | ||
await super().close() |
40 changes: 40 additions & 0 deletions
40
sdk/storage/azure-storage-blob/tests/perfstress_tests/download.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure_devtools.perfstress_tests import get_random_bytes, WriteStream | ||
|
||
from ._test_base import _ContainerTest | ||
|
||
|
||
class DownloadTest(_ContainerTest): | ||
mikeharder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
blob_name = "downloadtest" | ||
self.blob_client = self.container_client.get_blob_client(blob_name) | ||
self.async_blob_client = self.async_container_client.get_blob_client(blob_name) | ||
self.download_stream = WriteStream() | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
data = get_random_bytes(self.args.size) | ||
await self.async_blob_client.upload_blob(data) | ||
|
||
def reset_sync(self): | ||
self.download_stream = WriteStream() | ||
|
||
async def reset_async(self): | ||
self.download_stream = WriteStream() | ||
|
||
def run_sync(self): | ||
stream = self.blob_client.download_blob(max_concurrency=self.args.max_concurrency) | ||
stream.readinto(self.download_stream) | ||
|
||
async def run_async(self): | ||
stream = await self.async_blob_client.download_blob(max_concurrency=self.args.max_concurrency) | ||
await stream.readinto(self.download_stream) | ||
|
||
async def close(self): | ||
await self.async_blob_client.close() | ||
await super().close() |
39 changes: 39 additions & 0 deletions
39
sdk/storage/azure-storage-blob/tests/perfstress_tests/list_blobs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
import itertools | ||
import asyncio | ||
|
||
from ._test_base import _ContainerTest | ||
|
||
|
||
class ListBlobsTest(_ContainerTest): | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
pending = (asyncio.ensure_future(self.async_container_client.upload_blob("listtest" + str(i), data=b"")) for i in range(self.args.num_blobs)) | ||
annatisch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
running = list(itertools.islice(pending, 16)) | ||
while True: | ||
# Wait for some upload to finish before adding a new one | ||
done, running = await asyncio.wait(running, return_when=asyncio.FIRST_COMPLETED) | ||
try: | ||
for _ in range(0, len(done)): | ||
next_upload = next(pending) | ||
running.add(next_upload) | ||
except StopIteration: | ||
await asyncio.wait(running, return_when=asyncio.ALL_COMPLETED) | ||
break | ||
|
||
def run_sync(self): | ||
for _ in self.container_client.list_blobs(): | ||
pass | ||
|
||
async def run_async(self): | ||
async for _ in self.async_container_client.list_blobs(): | ||
pass | ||
|
||
@staticmethod | ||
def add_arguments(parser): | ||
super(ListBlobsTest, ListBlobsTest).add_arguments(parser) | ||
parser.add_argument('--num-blobs', nargs='?', type=int, help='Number of blobs to list. Defaults to 100', default=100) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another minor nit: could we mention that its fetching the connection string from an env variable in the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch - forgot all about that!