-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add perf test for app config * update readme * updates * move uuid.uuid4() into ctor
- Loading branch information
1 parent
f54eefb
commit 878e384
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
sdk/appconfiguration/azure-appconfiguration/dev_requirements.txt
This file contains 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
42 changes: 42 additions & 0 deletions
42
sdk/appconfiguration/azure-appconfiguration/tests/perfstress_tests/README.md
This file contains 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 @@ | ||
# App config Performance Tests | ||
|
||
In order to run the performance tests, the `azure-devtools` 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. | ||
|
||
### Setup for test resources | ||
|
||
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: | ||
``` | ||
AZURE_APP_CONFIG_CONNECTION_STRING=<app config connection string> | ||
``` | ||
|
||
### Setup for perf test runs | ||
|
||
```cmd | ||
(env) ~/azure-appconfiguration> pip install -r dev_requirements.txt | ||
(env) ~/azure-appconfiguration> pip install -e . | ||
``` | ||
|
||
## Test commands | ||
|
||
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). | ||
|
||
```cmd | ||
(env) ~/azure-appconfiguration> cd tests | ||
(env) ~/azure-appconfiguration/tests> perfstress | ||
``` | ||
Using the `perfstress` command alone will list the available perf tests found. | ||
|
||
### Common perf command line options | ||
These options are available for all perf tests: | ||
- `--duration=10` Number of seconds to run as many operations (the "run" function) as possible. Default is 10. | ||
- `--iterations=1` Number of test iterations to run. Default is 1. | ||
- `--parallel=1` Number of tests to run in parallel. Default is 1. | ||
- `--warm-up=5` Number of seconds to spend warming up the connection before measuring begins. Default is 5. | ||
- `--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. | ||
- `--no-cleanup` Whether to keep newly created resources after test run. Default is False (resources will be deleted). | ||
|
||
## Example command | ||
```cmd | ||
(env) ~/azure-appconfiguration/tests> perfstress GetTest | ||
``` |
Empty file.
38 changes: 38 additions & 0 deletions
38
sdk/appconfiguration/azure-appconfiguration/tests/perfstress_tests/get.py
This file contains 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,38 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
|
||
from azure_devtools.perfstress_tests import PerfStressTest | ||
|
||
from azure.appconfiguration import ConfigurationSetting, AzureAppConfigurationClient as SyncAppConfigClient | ||
from azure.appconfiguration.aio import AzureAppConfigurationClient as AsyncAppConfigClient | ||
|
||
|
||
class GetTest(PerfStressTest): | ||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
connection_string = self.get_from_env("AZURE_APP_CONFIG_CONNECTION_STRING") | ||
self.key = "KEY" | ||
self.service_client = SyncAppConfigClient.from_connection_string(connection_string=connection_string) | ||
self.async_service_client = AsyncAppConfigClient.from_connection_string(connection_string=connection_string) | ||
|
||
async def global_setup(self): | ||
await super().global_setup() | ||
kv = ConfigurationSetting( | ||
key=self.key, | ||
value="VALUE", | ||
) | ||
await self.async_service_client.set_configuration_setting(kv) | ||
|
||
async def close(self): | ||
# await self.async_service_client.close() | ||
await super().close() | ||
|
||
def run_sync(self): | ||
self.service_client.get_configuration_setting(key=self.key) | ||
|
||
async def run_async(self): | ||
await self.async_service_client.get_configuration_setting(key=self.key) |
43 changes: 43 additions & 0 deletions
43
sdk/appconfiguration/azure-appconfiguration/tests/perfstress_tests/set.py
This file contains 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,43 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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.appconfiguration import ConfigurationSetting, AzureAppConfigurationClient as SyncAppConfigClient | ||
from azure.appconfiguration.aio import AzureAppConfigurationClient as AsyncAppConfigClient | ||
|
||
|
||
class SetTest(PerfStressTest): | ||
service_client = None | ||
async_service_client = None | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
connection_string = self.get_from_env("AZURE_APP_CONFIG_CONNECTION_STRING") | ||
self.key = "KEY" | ||
self.value = str(uuid.uuid4()) | ||
self.service_client = SyncAppConfigClient.from_connection_string(connection_string=connection_string) | ||
self.async_service_client = AsyncAppConfigClient.from_connection_string(connection_string=connection_string) | ||
|
||
async def close(self): | ||
# await self.async_service_client.close() | ||
await super().close() | ||
|
||
def run_sync(self): | ||
kv = ConfigurationSetting( | ||
key=self.key, | ||
value="VALUE" + self.value, | ||
) | ||
self.service_client.set_configuration_setting(kv) | ||
|
||
async def run_async(self): | ||
kv = ConfigurationSetting( | ||
key=self.key, | ||
value="VALUE" + self.value, | ||
) | ||
await self.async_service_client.set_configuration_setting(kv) |