In order to run the performance tests, the devtools_testutils package must be installed. This is done as part of the dev_requirements.
Start be creating a new virtual environment for your perf tests. This will need to be a Python 3 environment, preferably >=3.7.
Note that tests for T1 and T2 SDKs cannot be run from the same environment, and will need to be setup separately.
These tests will run against a pre-configured Storage account. The following environment variable will need to be set for the tests to access the live resources using the connection string for authentication:
AZURE_STORAGE_CONNECTION_STRING=<live storage account connection string>
The following environment variables will need to be set for the tests to access the live resources using Microsoft Entra ID for authentication:
AZURE-STORAGE-BLOB_TENANT_ID=<Microsoft Entra ID tenant ID>
AZURE-STORAGE-BLOB_CLIENT_ID=<Microsoft Entra ID client ID>
AZURE-STORAGE-BLOB_CLIENT_SECRET=<Microsoft Entra ID client secret>
AZURE_STORAGE_ACCOUNT_NAME=<live storage account name>
(env) ~/azure-storage-blob> pip install -r dev_requirements.txt
(env) ~/azure-storage-blob> pip install -e .(env) ~/azure-storage-blob> pip install -r dev_requirements.txt
(env) ~/azure-storage-blob> pip install tests/perfstress_tests/T1_legacy_tests/t1_test_requirements.txtWhen devtools_testutils is installed, you will have access to the perfstress command line tool, which will scan the current module for runable perf tests. Only a specific test can be run at a time (i.e. there is no "run all" feature).
(env) ~/azure-storage-blob> cd tests
(env) ~/azure-storage-blob/tests> perfstressUsing the perfstress command alone will list the available perf tests found. Note that the available tests discovered will vary depending on whether your environment is configured for the T1 or T2 SDK.
These options are available for all perf tests:
-d --duration=10Number of seconds to run as many operations (the "run" function) as possible. Default is 10.-i --iterations=1Number of test iterations to run. Default is 1.-p --parallel=1Number of tests to run in parallel. Default is 1.--no-client-shareWhether each parallel test instance should share a single client, or use their own. Default is False (sharing).-w --warm-up=5Number of seconds to spend warming up the connection before measuring begins. Default is 5.--syncWhether to run the tests in sync or async. Default is False (async). This flag must be used for Storage legacy tests, which do not support async.--no-cleanupWhether to keep newly created resources after test run. Default is False (resources will be deleted).-x --test-proxiesWhether to run the tests against the test proxy server. Specfiy the URL(s) for the proxy endpoint(s) (e.g. "https://localhost:5001"). WARNING: When using with Legacy tests - only HTTPS is supported.--profileWhether to run the perftest with cProfile. If enabled (default is False), the output file of the last completed single iteration will be written to the current working directory in the format"cProfile-<TestClassName>-<TestID>-<sync/async>.pstats".--use-entra-id- Flag to pass in to use Microsoft Entra ID as the authentication. By default, set to False.
The options are available for all Blob perf tests:
--size=10240Size in bytes of data to be transferred in upload or download tests. Default is 10240.--max-concurrency=1Number of threads to concurrently upload/download a single operation using the SDK API parameter. Default is 1.--max-put-sizeMaximum size of data uploading in single HTTP PUT.--max-block-sizeMaximum size of data in a block within a blob.--max-get-sizeInitial chunk size of a Blob download.--buffer-thresholdMinimum block size to prevent full block buffering.--data-block-sizeThe chunk size used when reading from the network stream.--client-encryptionThe version of client-side encryption to use. Leave out for no encryption.
This option is only available to the List Blobs test (T1 and T2).
--num-blobsNumber of blobs to list. Defaults to 100.
The tests currently written for the T2 SDK:
UploadTestUploads a stream ofsizebytes to a new Blob.UploadFromFileTestUploads a local file ofsizebytes to a new Blob.UploadBlockTestUpload a single block ofsizebytes within a Blob.DownloadTestDownload a stream ofsizebytes.DownloadToFileTestDownloads a blob ofsizebytes to a local file.DownloadBasicTestDownloads using basic HTTP library primitives, ignoring content.ListBlobsTestList a specified number of blobs.
The tests currently written for the T1 SDK:
LegacyUploadTestUploads a stream ofsizebytes to a new Blob.LegacyUploadFromFileTestUploads a local file ofsizebytes to a new Blob.LegacyUploadBlockTestUpload a single block ofsizebytes within a Blob.LegacyDownloadTestDownload a stream ofsizebytes.LegacyListBlobsTestList a specified number of blobs.
(env) ~/azure-storage-blob/tests> perfstress UploadTest --parallel=2 --size=10240Follow the instructions here to install and run the test proxy server: https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy
Once running, in a separate process run the perf test in question, combined with the -x flag to specify the proxy endpoint. (Note, only the HTTPS endpoint is supported for the Legacy tests).
(env) ~/azure-storage-blob/tests> perfstress DownloadTest -x "https://localhost:5001"