Skip to content

Commit df25a4c

Browse files
authored
[Corehttp] add perf tests (#34412)
* copy over core perf tests * update readme * update perf tests to corehttp * add query attribute to httprequest in perf tests * update httppolicy checks in pipeline base * add perf tests yml for corehttp * move perf tests yml into corehttp folder * fix merge * move perf files to corehttp * black * add dev reqs for perf * add identity to dev reqs * remove 1.0.0b3 from perf tests * update corehttp aad envvars get * update perf tests.yml * revert azure core perf yml * update perf readme * remove unneeded policies * address kashif/paul comments * black * black on azure core
1 parent ed99826 commit df25a4c

16 files changed

+1094
-9
lines changed

sdk/core/azure-core/perf-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Tests:
1313
Class: UploadBinaryDataTest
1414
Arguments:
1515
- --size 1024 --parallel 64 --duration 60 --policies all
16-
- --size 1024 --parallel 64 --duration 60 --policies all --aad
16+
- --size 1024 --parallel 64 --duration 60 --policies all --use-entra-id
1717
- --size 10240 --parallel 32 --duration 60
1818
- --size 10240 --parallel 32 --duration 60 --transport requests
1919

@@ -22,29 +22,29 @@ Tests:
2222
Arguments:
2323
- --size 1024 --parallel 64 --duration 60
2424
- --size 1024 --parallel 64 --duration 60 --transport requests
25-
- --size 1024 --parallel 64 --duration 60 --aad
25+
- --size 1024 --parallel 64 --duration 60 --use-entra-id
2626
- --size 10240 --parallel 32 --duration 60 --policies all
2727

2828
- Test: update-entity
2929
Class: UpdateEntityJSONTest
3030
Arguments:
3131
- --size 1024 --parallel 64 --duration 60
3232
- --size 1024 --parallel 64 --duration 60 --transport requests
33-
- --size 1024 --parallel 64 --duration 60 --aad
33+
- --size 1024 --parallel 64 --duration 60 --use-entra-id
3434
- --size 1024 --parallel 64 --duration 60 --policies all
3535

3636
- Test: query-entities
3737
Class: QueryEntitiesJSONTest
3838
Arguments:
3939
- --size 1024 --parallel 64 --duration 60
4040
- --size 1024 --parallel 64 --duration 60 --transport requests
41-
- --size 1024 --parallel 64 --duration 60 --aad
41+
- --size 1024 --parallel 64 --duration 60 --use-entra-id
4242
- --size 1024 --parallel 64 --duration 60 --policies all
4343

4444
- Test: list-entities
4545
Class: ListEntitiesPageableTest
4646
Arguments:
4747
- --count 500 --parallel 32 --warmup 60 --duration 60
4848
- --count 500 --parallel 32 --warmup 60 --duration 60 --transport requests
49-
- --count 500 --parallel 32 --warmup 60 --duration 60 --aad
49+
- --count 500 --parallel 32 --warmup 60 --duration 60 --use-entra-id
5050
- --count 500 --parallel 32 --warmup 60 --duration 60 --policies all

sdk/core/azure-core/tests/perf_tests/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ The options that are available for all Core perf tests:
6565
- `"requests"`: AsyncioRequestsTransport
6666
- For sync:
6767
- `"requests"`: RequestsTransport (default)
68-
- `--aad` - Flag to pass in to use Azure Active Directory as the authentication. By default, set to False.
68+
- `--use-entra-id` - Flag to pass in to use Microsoft Entra ID as the authentication. By default, set to False.
6969
- `--size=10240` - Size of request content (in bytes). Defaults to 10240. (Not used by `ListEntitiesPageableTest`.)
70+
- `--policies` - List of policies to pass in to the pipeline. Options:
71+
- None: No extra policies passed in, except for authentication policy. This is the default.
72+
- 'all': All policies added automatically by autorest.
73+
- 'policy1,policy2': Comma-separated list of policies, such as 'RetryPolicy,HttpLoggingPolicy'"
7074

7175
#### Additional ListEntitiesPageableTest command line options
7276

@@ -78,5 +82,5 @@ The options that are additionally available for `ListEntitiesPageableTest`:
7882
## Example command
7983

8084
```cmd
81-
(env) ~/azure-core> perfstress DownloadBinaryDataTest --aad --transport requests --size=20480 --parallel=2
85+
(env) ~/azure-core> perfstress DownloadBinaryDataTest --use-entra-id --transport requests --size=20480 --parallel=2
8286
```

sdk/core/azure-core/tests/perf_tests/_test_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _build_async_pipeline_client(self, auth_policy):
159159
return AsyncPipelineClient(self.account_endpoint, pipeline=async_pipeline)
160160

161161
def _set_auth_policies(self):
162-
if not self.args.aad:
162+
if not self.args.use_entra_id:
163163
# if tables, create table credential policy, else blob policy
164164
if "tables" in self.sdk_moniker:
165165
self.sync_auth_policy = TableSharedKeyCredentialPolicy(
@@ -199,7 +199,9 @@ def add_arguments(parser):
199199
"""\n- 'policy1,policy2': Comma-separated list of policies, such as 'RetryPolicy,HttpLoggingPolicy'""",
200200
default=None,
201201
)
202-
parser.add_argument("--aad", action="store_true", help="Use AAD authentication instead of shared key.")
202+
parser.add_argument(
203+
"--use-entra-id", action="store_true", help="Use Microsoft Entra ID authentication instead of shared key."
204+
)
203205

204206

205207
class _BlobTest(_ServiceTest):

sdk/core/corehttp/dev_requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ httpx>=0.25.0
77
-e ../../../tools/azure-devtools
88
-e tests/testserver_tests/coretestserver
99
../../core/azure-core
10+
azure-storage-blob
11+
azure-data-tables
12+
azure-identity
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
param baseName string = resourceGroup().name
2+
param location string = resourceGroup().location
3+
param storageEndpointSuffix string = 'core.windows.net'
4+
param testApplicationOid string
5+
6+
resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {
7+
name: '${baseName}storage'
8+
location: location
9+
kind: 'StorageV2'
10+
sku: {
11+
name: 'Standard_RAGRS'
12+
}
13+
}
14+
15+
resource storageAccountBlobServices 'Microsoft.Storage/storageAccounts/blobServices@2021-09-01' = {
16+
name: 'default'
17+
parent: storageAccount
18+
}
19+
20+
resource testContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-09-01' = {
21+
name: 'testcontainer'
22+
parent: storageAccountBlobServices
23+
24+
}
25+
26+
@description('This is the Blob owner role.')
27+
resource blobOwnerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
28+
scope: resourceGroup()
29+
name: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'
30+
}
31+
32+
resource blobRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
33+
name: guid(resourceGroup().id, testApplicationOid, blobOwnerRoleDefinition.id)
34+
properties: {
35+
roleDefinitionId: blobOwnerRoleDefinition.id
36+
principalId: testApplicationOid
37+
principalType: 'ServicePrincipal'
38+
}
39+
}
40+
41+
resource tableServices 'Microsoft.Storage/storageAccounts/tableServices@2022-09-01' = {
42+
name: 'default'
43+
parent: storageAccount
44+
}
45+
46+
resource tables 'Microsoft.Storage/storageAccounts/tableServices/tables@2022-09-01' = {
47+
name: 'default'
48+
parent: tableServices
49+
}
50+
51+
@description('This is the Blob owner role.')
52+
resource tableOwnerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
53+
scope: resourceGroup()
54+
name: '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3'
55+
}
56+
57+
resource tableRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
58+
name: guid(resourceGroup().id, testApplicationOid, tableOwnerRoleDefinition.id)
59+
properties: {
60+
roleDefinitionId: tableOwnerRoleDefinition.id
61+
principalId: testApplicationOid
62+
principalType: 'ServicePrincipal'
63+
}
64+
}
65+
66+
var storageAccountKey = storageAccount.listKeys('2021-09-01').keys[0].value
67+
output AZURE_STORAGE_ACCOUNT_NAME string = storageAccount.name
68+
output AZURE_STORAGE_BLOBS_ENDPOINT string = storageAccount.properties.primaryEndpoints.blob
69+
output AZURE_STORAGE_ACCOUNT_KEY string = storageAccountKey
70+
output AZURE_STORAGE_CONN_STR string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccountKey};EndpointSuffix=${storageEndpointSuffix}'
71+
output AZURE_STORAGE_CONTAINER_NAME string = testContainer.name
72+
73+
output AZURE_STORAGE_TABLE_NAME string = tables.name
74+
output AZURE_STORAGE_TABLES_ENDPOINT string = 'https://${storageAccount.name}.table.${storageEndpointSuffix}/'

sdk/core/corehttp/perf-tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Service: core
2+
3+
Project: sdk/core/corehttp
4+
5+
PrimaryPackage: corehttp
6+
7+
PackageVersions:
8+
- corehttp: 1.0.0b4
9+
- corehttp: source
10+
11+
Tests:
12+
- Test: upload-binary
13+
Class: UploadBinaryDataTest
14+
Arguments:
15+
- --size 1024 --parallel 64 --duration 60 --policies all
16+
- --size 1024 --parallel 64 --duration 60 --policies all --use-entra-id
17+
- --size 10240 --parallel 32 --duration 60
18+
- --size 10240 --parallel 32 --duration 60 --transport httpx
19+
20+
- Test: download-binary
21+
Class: DownloadBinaryDataTest
22+
Arguments:
23+
- --size 1024 --parallel 64 --duration 60
24+
- --size 1024 --parallel 64 --duration 60 --transport httpx
25+
- --size 1024 --parallel 64 --duration 60 --use-entra-id
26+
- --size 10240 --parallel 32 --duration 60 --policies all
27+
28+
- Test: update-entity
29+
Class: UpdateEntityJSONTest
30+
Arguments:
31+
- --size 1024 --parallel 64 --duration 60
32+
- --size 1024 --parallel 64 --duration 60 --transport httpx
33+
- --size 1024 --parallel 64 --duration 60 --use-entra-id
34+
- --size 1024 --parallel 64 --duration 60 --policies all
35+
36+
- Test: query-entities
37+
Class: QueryEntitiesJSONTest
38+
Arguments:
39+
- --size 1024 --parallel 64 --duration 60
40+
- --size 1024 --parallel 64 --duration 60 --transport httpx
41+
- --size 1024 --parallel 64 --duration 60 --use-entra-id
42+
- --size 1024 --parallel 64 --duration 60 --policies all
43+
44+
- Test: list-entities
45+
Class: ListEntitiesPageableTest
46+
Arguments:
47+
- --count 500 --parallel 32 --warmup 60 --duration 60
48+
- --count 500 --parallel 32 --warmup 60 --duration 60 --transport httpx
49+
- --count 500 --parallel 32 --warmup 60 --duration 60 --use-entra-id
50+
- --count 500 --parallel 32 --warmup 60 --duration 60 --policies all

sdk/core/corehttp/perf.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
parameters:
2+
- name: LanguageVersion
3+
displayName: LanguageVersion (3.8, 3.9, 3.10, 3.11, 3.12)
4+
type: string
5+
default: '3.11'
6+
- name: PackageVersions
7+
displayName: PackageVersions (regex of package versions to run)
8+
type: string
9+
default: '1|source'
10+
- name: Tests
11+
displayName: Tests (regex of tests to run)
12+
type: string
13+
default: '^(upload-binary|download-binary|update-entity|query-entities|list-entities)$'
14+
- name: Arguments
15+
displayName: Arguments (regex of arguments to run)
16+
type: string
17+
default: '(1024)|(10240)|(500)'
18+
- name: Iterations
19+
displayName: Iterations (times to run each test)
20+
type: number
21+
default: '5'
22+
- name: AdditionalArguments
23+
displayName: AdditionalArguments (passed to PerfAutomation)
24+
type: string
25+
default: ' '
26+
27+
extends:
28+
template: /eng/pipelines/templates/jobs/perf.yml
29+
parameters:
30+
TimeoutInMinutes: 720
31+
ServiceDirectory: core/corehttp
32+
LanguageVersion: ${{ parameters.LanguageVersion }}
33+
PackageVersions: ${{ parameters.PackageVersions }}
34+
Tests: ${{ parameters.Tests }}
35+
Arguments: ${{ parameters.Arguments }}
36+
Iterations: ${{ parameters.Iterations }}
37+
AdditionalArguments: ${{ parameters.AdditionalArguments }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Core Python client performance tests
2+
3+
In order to run the performance tests, the `devtools_testutils` package must be installed. This is done as part of the `dev_requirements.txt` installation. Start be creating a new virtual environment for your perf tests. This will need to be a Python 3 environment, preferably >=3.7.
4+
5+
### Setup for test resources
6+
The following environment variables will need to be set for the tests to access the live resources:
7+
8+
```
9+
AZURE_STORAGE_CONN_STR=<the connection string to the Storage account>
10+
AZURE_STORAGE_ACCOUNT_NAME=<the Storage account name>
11+
AZURE_STORAGE_ACCOUNT_KEY=<the Storage account key>
12+
13+
AZURE_STORAGE_CONTAINER_NAME=<the container name>
14+
AZURE_STORAGE_BLOBS_ENDPOINT=<The Storage Blobs endpoint in the format 'https://{storageAccountName}.blob.core.windows.net'>
15+
16+
AZURE_STORAGE_TABLE_NAME=<The name to use for the Storage Table>
17+
AZURE_STORAGE_TABLES_ENDPOINT=<The Storage Tables endpoint in the format 'https://{storageAccountName}.table.core.windows.net'>
18+
```
19+
20+
### Setup for perf test runs
21+
22+
```cmd
23+
(env) ~/core/corehttp> pip install -r dev_requirements.txt
24+
(env) ~/core/corehttp> pip install .
25+
```
26+
27+
## Test commands
28+
29+
When `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).
30+
31+
```cmd
32+
(env) ~/core/corehttp> cd tests
33+
(env) ~/core/corehttp/tests> perfstress
34+
```
35+
36+
Using the `perfstress` command alone will list the available perf tests found.
37+
38+
### Tests
39+
40+
The tests currently available:
41+
42+
- `UploadBinaryDataTest` - Puts binary data of `size` in a Storage Blob (corresponds to the `upload_blob` Blob operation).
43+
- `DownloadBinaryDataTest` - Gets binary data of `size` from a Storage Blob (corresponds to the `download_blob` Blob operation).
44+
- `UpdateEntityJSONTest` - Puts JSON data of `size` in a Storage Table (corresponds to the `update_entity` Tables operation).
45+
- `QueryEntitiesJSONTest` - Gets JSON data of `size` from a Storage Table (corresponds to the `query_entities` Tables operation).
46+
- `ListEntitiesPageableTest` - Gets pageable data from a Storage Table (corresponds to the `list_entities` Tables operation).
47+
48+
### Common perf command line options
49+
50+
The `perfstress` framework has a series of common command line options built in. View them [here](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/perfstress_tests.md#default-command-options).
51+
52+
- `--sync` Whether to run the tests in sync or async. Default is False (async).
53+
- `-d --duration=10` Number of seconds to run as many operations (the "run" function) as possible. Default is 10.
54+
- `-i --iterations=1` Number of test iterations to run. Default is 1.
55+
- `-p --parallel=1` Number of tests to run in parallel. Default is 1.
56+
- `-w --warm-up=5` Number of seconds to spend warming up the connection before measuring begins. Default is 5.
57+
58+
#### Core perf test common command line options
59+
60+
The options that are available for all Core perf tests:
61+
62+
- `--transport` - By default, uses AiohttpTransport ("aiohttp") for async. By default, uses RequestsTransport ("requests") for sync. All options:
63+
- For async:
64+
- `"aiohttp"`: AiohttpTransport (default)
65+
- `"httpx"`: AsyncHttpXTransport
66+
- For sync:
67+
- `"requests"`: RequestsTransport (default)
68+
- `"httpx"`: HttpXTransport
69+
- `--use-entra-id` - Flag to pass in to use Microsoft Entra ID as the authentication. By default, set to False.
70+
- `--size=10240` - Size of request content (in bytes). Defaults to 10240. (Not used by `ListEntitiesPageableTest`.)
71+
- `--policies` - List of policies to pass in to the pipeline. Options:
72+
- None: No extra policies passed in, except for authentication policy. This is the default.
73+
- 'all': All policies added automatically by autorest.
74+
- 'policy1,policy2': Comma-separated list of policies, such as 'RetryPolicy,UserAgentPolicy'"
75+
76+
#### Additional ListEntitiesPageableTest command line options
77+
78+
The options that are additionally available for `ListEntitiesPageableTest`:
79+
80+
- `--count=100` - Number of table entities to list. Defaults to 100.
81+
- `--page-size=None` - Maximum number of entities to list per page. Default is None, which will return all possible results per page.
82+
83+
## Example command
84+
85+
```cmd
86+
(env) ~/core/corehttp> perfstress DownloadBinaryDataTest --use-entra-id --transport httpx --size=20480 --parallel=2
87+
```

sdk/core/corehttp/tests/perf_tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)