Skip to content

Commit 878e384

Browse files
authored
Appconfig perf test (#16809)
* add perf test for app config * update readme * updates * move uuid.uuid4() into ctor
1 parent f54eefb commit 878e384

File tree

5 files changed

+124
-0
lines changed

5 files changed

+124
-0
lines changed

sdk/appconfiguration/azure-appconfiguration/dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-e ../../../tools/azure-devtools
12
../../core/azure-core
23
-e ../../identity/azure-identity
34
aiohttp>=3.0; python_version >= '3.5'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# App config Performance Tests
2+
3+
In order to run the performance tests, the `azure-devtools` package must be installed. This is done as part of the `dev_requirements`.
4+
Start be creating a new virtual environment for your perf tests. This will need to be a Python 3 environment, preferably >=3.7.
5+
6+
### Setup for test resources
7+
8+
These tests will run against a pre-configured application configuration service. The following environment variable will need to be set for the tests to access the live resources:
9+
```
10+
AZURE_APP_CONFIG_CONNECTION_STRING=<app config connection string>
11+
```
12+
13+
### Setup for perf test runs
14+
15+
```cmd
16+
(env) ~/azure-appconfiguration> pip install -r dev_requirements.txt
17+
(env) ~/azure-appconfiguration> pip install -e .
18+
```
19+
20+
## Test commands
21+
22+
When `azure-devtools` 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).
23+
24+
```cmd
25+
(env) ~/azure-appconfiguration> cd tests
26+
(env) ~/azure-appconfiguration/tests> perfstress
27+
```
28+
Using the `perfstress` command alone will list the available perf tests found.
29+
30+
### Common perf command line options
31+
These options are available for all perf tests:
32+
- `--duration=10` Number of seconds to run as many operations (the "run" function) as possible. Default is 10.
33+
- `--iterations=1` Number of test iterations to run. Default is 1.
34+
- `--parallel=1` Number of tests to run in parallel. Default is 1.
35+
- `--warm-up=5` Number of seconds to spend warming up the connection before measuring begins. Default is 5.
36+
- `--sync` Whether 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.
37+
- `--no-cleanup` Whether to keep newly created resources after test run. Default is False (resources will be deleted).
38+
39+
## Example command
40+
```cmd
41+
(env) ~/azure-appconfiguration/tests> perfstress GetTest
42+
```

sdk/appconfiguration/azure-appconfiguration/tests/perfstress_tests/__init__.py

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
import os
7+
8+
from azure_devtools.perfstress_tests import PerfStressTest
9+
10+
from azure.appconfiguration import ConfigurationSetting, AzureAppConfigurationClient as SyncAppConfigClient
11+
from azure.appconfiguration.aio import AzureAppConfigurationClient as AsyncAppConfigClient
12+
13+
14+
class GetTest(PerfStressTest):
15+
def __init__(self, arguments):
16+
super().__init__(arguments)
17+
connection_string = self.get_from_env("AZURE_APP_CONFIG_CONNECTION_STRING")
18+
self.key = "KEY"
19+
self.service_client = SyncAppConfigClient.from_connection_string(connection_string=connection_string)
20+
self.async_service_client = AsyncAppConfigClient.from_connection_string(connection_string=connection_string)
21+
22+
async def global_setup(self):
23+
await super().global_setup()
24+
kv = ConfigurationSetting(
25+
key=self.key,
26+
value="VALUE",
27+
)
28+
await self.async_service_client.set_configuration_setting(kv)
29+
30+
async def close(self):
31+
# await self.async_service_client.close()
32+
await super().close()
33+
34+
def run_sync(self):
35+
self.service_client.get_configuration_setting(key=self.key)
36+
37+
async def run_async(self):
38+
await self.async_service_client.get_configuration_setting(key=self.key)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
import os
7+
import uuid
8+
9+
from azure_devtools.perfstress_tests import PerfStressTest
10+
11+
from azure.appconfiguration import ConfigurationSetting, AzureAppConfigurationClient as SyncAppConfigClient
12+
from azure.appconfiguration.aio import AzureAppConfigurationClient as AsyncAppConfigClient
13+
14+
15+
class SetTest(PerfStressTest):
16+
service_client = None
17+
async_service_client = None
18+
19+
def __init__(self, arguments):
20+
super().__init__(arguments)
21+
connection_string = self.get_from_env("AZURE_APP_CONFIG_CONNECTION_STRING")
22+
self.key = "KEY"
23+
self.value = str(uuid.uuid4())
24+
self.service_client = SyncAppConfigClient.from_connection_string(connection_string=connection_string)
25+
self.async_service_client = AsyncAppConfigClient.from_connection_string(connection_string=connection_string)
26+
27+
async def close(self):
28+
# await self.async_service_client.close()
29+
await super().close()
30+
31+
def run_sync(self):
32+
kv = ConfigurationSetting(
33+
key=self.key,
34+
value="VALUE" + self.value,
35+
)
36+
self.service_client.set_configuration_setting(kv)
37+
38+
async def run_async(self):
39+
kv = ConfigurationSetting(
40+
key=self.key,
41+
value="VALUE" + self.value,
42+
)
43+
await self.async_service_client.set_configuration_setting(kv)

0 commit comments

Comments
 (0)