-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Perfstress][Storage] Added FileShare perf tests #15834
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 9 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
56968cd
Fileshare perf tests
annatisch df53958
Merge remote-tracking branch 'upstream/master' into perfstress_tests_…
annatisch 2b39706
Memory management
annatisch 8db909b
Fix legacy test memory
annatisch 84d11bb
Fix upload test
annatisch a2289a8
Fix file upload test
annatisch 74b529e
Fix perf stream
annatisch 5fbbdc5
Removed global cleanup
annatisch b16b86a
Update stream support
annatisch 75bfaad
Remove useless setup
annatisch 83e7797
Added readme
annatisch 69151e1
Ignore readme
annatisch a0f2c21
Merge branch 'master' into perfstress_tests_fileshare
annatisch d784aac
Fix stream merge
annatisch 8d5344a
Fix readme
annatisch f7824e8
Fix stream merge
annatisch a23b773
Merge remote-tracking branch 'upstream/master' into perfstress_tests_…
annatisch 1cfa1f8
Merge remote-tracking branch 'upstream/master' into perfstress_tests_…
annatisch d09452b
Fix async stream
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.
48 changes: 48 additions & 0 deletions
48
sdk/storage/azure-storage-file-share/tests/perfstress_tests/T1_legacy_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,48 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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.file import FileService | ||
|
|
||
| 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 = FileService(connection_string=connection_string) | ||
| if self.args.max_range_size: | ||
| _LegacyServiceTest.service_client.MAX_RANGE_SIZE = self.args.max_range_size | ||
| 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('-r', '--max-range-size', nargs='?', type=int, help='Maximum size of data uploading in single HTTP PUT. Defaults to 4*1024*1024', default=4*1024*1024) | ||
| 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 _LegacyShareTest(_LegacyServiceTest): | ||
| share_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_share(self.share_name) | ||
|
|
||
| async def global_cleanup(self): | ||
| self.service_client.delete_share(self.share_name) | ||
| await super().global_cleanup() |
36 changes: 36 additions & 0 deletions
36
sdk/storage/azure-storage-file-share/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 import _LegacyShareTest | ||
|
|
||
|
|
||
| class LegacyDownloadTest(_LegacyShareTest): | ||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| self.file_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_file_from_bytes( | ||
| share_name=self.share_name, | ||
| directory_name=None, | ||
| file_name=self.file_name, | ||
| file=data) | ||
|
|
||
| def run_sync(self): | ||
| self.download_stream.reset() | ||
| self.service_client.get_file_to_stream( | ||
| share_name=self.share_name, | ||
| directory_name=None, | ||
| file_name=self.file_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.") |
44 changes: 44 additions & 0 deletions
44
...orage/azure-storage-file-share/tests/perfstress_tests/T1_legacy_tests/download_to_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,44 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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 import _LegacyShareTest | ||
|
|
||
|
|
||
| class LegacyDownloadToFileTest(_LegacyShareTest): | ||
| file_name = "downloadtest" | ||
|
|
||
| async def global_setup(self): | ||
| await super().global_setup() | ||
| data = get_random_bytes(self.args.size) | ||
| self.service_client.create_file_from_bytes( | ||
| share_name=self.share_name, | ||
| directory_name=None, | ||
| file_name=self.file_name, | ||
| file=data) | ||
|
|
||
| async def setup(self): | ||
| await super().setup() | ||
| self.temp_file = os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) | ||
|
|
||
| async def cleanup(self): | ||
| os.remove(self.temp_file) | ||
| await super().cleanup() | ||
|
|
||
| def run_sync(self): | ||
| self.service_client.get_file_to_path( | ||
| share_name=self.share_name, | ||
| directory_name=None, | ||
| file_name=self.file_name, | ||
| file_path=self.temp_file, | ||
| max_connections=self.args.max_concurrency) | ||
|
|
||
| async def run_async(self): | ||
| raise NotImplementedError("Async not supported for legacy T1 tests.") |
1 change: 1 addition & 0 deletions
1
.../azure-storage-file-share/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-file==2.1.0 |
30 changes: 30 additions & 0 deletions
30
sdk/storage/azure-storage-file-share/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, get_random_bytes | ||
|
|
||
| from ._test_base import _LegacyShareTest | ||
|
|
||
|
|
||
| class LegacyUploadTest(_LegacyShareTest): | ||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| self.file_name = "sharefiletest-" + str(uuid.uuid4()) | ||
| self.upload_stream = RandomStream(self.args.size) | ||
|
|
||
| def run_sync(self): | ||
| self.upload_stream.reset() | ||
| self.service_client.create_file_from_stream( | ||
| share_name=self.share_name, | ||
| directory_name=None, | ||
| file_name=self.file_name, | ||
| stream=self.upload_stream, | ||
| count=self.args.size, | ||
| max_connections=self.args.max_concurrency) | ||
|
|
||
| async def run_async(self): | ||
| raise NotImplementedError("Async not supported for legacy T1 tests.") |
42 changes: 42 additions & 0 deletions
42
...orage/azure-storage-file-share/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,42 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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 import _LegacyShareTest | ||
|
|
||
|
|
||
| class LegacyUploadFromFileTest(_LegacyShareTest): | ||
| temp_file = None | ||
|
|
||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| self.file_name = "sharefiletest-" + 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_file_from_path( | ||
| share_name=self.share_name, | ||
| directory_name=None, | ||
| file_name=self.file_name, | ||
| local_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.
82 changes: 82 additions & 0 deletions
82
sdk/storage/azure-storage-file-share/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,82 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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.fileshare import ShareServiceClient as SyncShareServiceClient | ||
| from azure.storage.fileshare.aio import ShareServiceClient as AsyncShareServiceClient | ||
|
|
||
|
|
||
| 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 = {} | ||
| if self.args.max_range_size: | ||
| kwargs['max_range_size'] = self.args.max_range_size | ||
| if not _ServiceTest.service_client or self.args.no_client_share: | ||
| _ServiceTest.service_client = SyncShareServiceClient.from_connection_string(conn_str=connection_string, **kwargs) | ||
| _ServiceTest.async_service_client = AsyncShareServiceClient.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('-r', '--max-range-size', nargs='?', type=int, help='Maximum size of data uploading in single HTTP PUT. Defaults to 4*1024*1024', default=4*1024*1024) | ||
| 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 _ShareTest(_ServiceTest): | ||
| share_name = "perfstress-" + str(uuid.uuid4()) | ||
|
|
||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| self.share_client = self.service_client.get_share_client(self.share_name) | ||
| self.async_share_client = self.async_service_client.get_share_client(self.share_name) | ||
|
|
||
| async def global_setup(self): | ||
| await super().global_setup() | ||
| self.share_client.create_share() | ||
|
|
||
| async def global_cleanup(self): | ||
| self.share_client.delete_share() | ||
| await super().global_cleanup() | ||
|
|
||
| async def close(self): | ||
| await self.async_share_client.close() | ||
| await super().close() | ||
|
|
||
|
|
||
| class _FileTest(_ShareTest): | ||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| file_name = "sharefiletest-" + str(uuid.uuid4()) | ||
| self.sharefile_client = self.share_client.get_file_client(file_name) | ||
| self.async_sharefile_client = self.async_share_client.get_file_client(file_name) | ||
|
|
||
| async def global_setup(self): | ||
| await super().global_setup() | ||
| try: | ||
| self.sharefile_client.delete_file() | ||
| except ResourceNotFoundError: | ||
| pass | ||
|
|
||
| async def close(self): | ||
| await self.async_sharefile_client.close() | ||
| await super().close() | ||
36 changes: 36 additions & 0 deletions
36
sdk/storage/azure-storage-file-share/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,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 import _ShareTest | ||
|
|
||
|
|
||
| class DownloadTest(_ShareTest): | ||
mikeharder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| file_name = "downloadtest" | ||
| self.sharefile_client = self.share_client.get_file_client(file_name) | ||
| self.async_sharefile_client = self.async_share_client.get_file_client(file_name) | ||
| self.download_stream = WriteStream() | ||
|
|
||
| async def global_setup(self): | ||
| await super().global_setup() | ||
| data = get_random_bytes(self.args.size) | ||
| await self.async_sharefile_client.upload_file(data) | ||
|
|
||
| def run_sync(self): | ||
| self.download_stream.reset() | ||
| stream = self.sharefile_client.download_file(max_concurrency=self.args.max_concurrency) | ||
| stream.readinto(self.download_stream) | ||
|
|
||
| async def run_async(self): | ||
| self.download_stream.reset() | ||
| stream = await self.async_sharefile_client.download_file(max_concurrency=self.args.max_concurrency) | ||
| await stream.readinto(self.download_stream) | ||
|
|
||
| async def close(self): | ||
| await self.async_sharefile_client.close() | ||
| await super().close() | ||
37 changes: 37 additions & 0 deletions
37
sdk/storage/azure-storage-file-share/tests/perfstress_tests/download_to_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,37 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import tempfile | ||
|
|
||
| from azure_devtools.perfstress_tests import get_random_bytes | ||
|
|
||
| from ._test_base import _ShareTest | ||
|
|
||
|
|
||
| class DownloadToFileTest(_ShareTest): | ||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| file_name = "downloadtest" | ||
| self.sharefile_client = self.share_client.get_file_client(file_name) | ||
| self.async_sharefile_client = self.async_share_client.get_file_client(file_name) | ||
|
|
||
| async def global_setup(self): | ||
| await super().global_setup() | ||
| data = get_random_bytes(self.args.size) | ||
| await self.async_sharefile_client.upload_file(data) | ||
|
|
||
| def run_sync(self): | ||
| with tempfile.TemporaryFile() as fp: | ||
mikeharder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| stream = self.sharefile_client.download_file(max_concurrency=self.args.max_concurrency) | ||
| stream.readinto(fp) | ||
|
|
||
| async def run_async(self): | ||
| with tempfile.TemporaryFile() as fp: | ||
| stream = await self.async_sharefile_client.download_file(max_concurrency=self.args.max_concurrency) | ||
| await stream.readinto(fp) | ||
|
|
||
| async def close(self): | ||
| await self.async_sharefile_client.close() | ||
| await super().close() | ||
30 changes: 30 additions & 0 deletions
30
sdk/storage/azure-storage-file-share/tests/perfstress_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. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from ._test_base import _FileTest | ||
|
|
||
| from azure_devtools.perfstress_tests import RandomStream, get_random_bytes | ||
| from azure_devtools.perfstress_tests import AsyncRandomStream | ||
|
|
||
|
|
||
| class UploadTest(_FileTest): | ||
| def __init__(self, arguments): | ||
| super().__init__(arguments) | ||
| self.upload_stream = RandomStream(self.args.size) | ||
| self.upload_stream_async = AsyncRandomStream(self.args.size) | ||
|
|
||
| def run_sync(self): | ||
| self.upload_stream.reset() | ||
| self.sharefile_client.upload_file( | ||
| self.upload_stream, | ||
| length=self.args.size, | ||
| max_concurrency=self.args.max_concurrency) | ||
|
|
||
| async def run_async(self): | ||
| self.upload_stream_async.reset() | ||
| await self.async_sharefile_client.upload_file( | ||
| self.upload_stream_async, | ||
| length=self.args.size, | ||
| max_concurrency=self.args.max_concurrency) | ||
annatisch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.