-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Key Vault] Add perf tests for certificates, keys, and secrets #17073
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
48 changes: 48 additions & 0 deletions
48
sdk/keyvault/azure-keyvault-certificates/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,48 @@ | ||
# azure-keyvault-certificates 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` install. Start by 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 | ||
|
||
The following environment variables will need to be set for the tests to access the live resources: | ||
|
||
``` | ||
AZURE_TENANT_ID=<tenant ID of testing service principal> | ||
AZURE_CLIENT_ID=<client ID of testing service principal> | ||
AZURE_CLIENT_SECRET=<client secret of testing service principal> | ||
AZURE_KEYVAULT_URL=<URL of the testing key vault> | ||
``` | ||
|
||
### Setup for perf test runs | ||
|
||
```cmd | ||
(env) ~/azure-keyvault-certificates> pip install -r dev_requirements.txt | ||
(env) ~/azure-keyvault-certificates> pip install -e . | ||
``` | ||
|
||
## Test commands | ||
|
||
Once `azure-devtools` is installed, you will have access to the `perfstress` command line tool, which will scan the | ||
current module for runnable perf tests. Only a specific test can be run at a time (i.e. there is no "run all" feature). | ||
|
||
```cmd | ||
(env) ~/azure-keyvault-certificates> cd tests/perfstress_tests/ | ||
(env) ~/azure-keyvault-certificates/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). | ||
- `--no-cleanup` Whether to keep newly created resources after test run. Default is False (resources will be deleted). | ||
|
||
## Example command | ||
```cmd | ||
(env) ~/azure-keyvault-certificates/tests> perfstress GetCertificateTest | ||
``` |
Empty file.
48 changes: 48 additions & 0 deletions
48
sdk/keyvault/azure-keyvault-certificates/tests/perfstress_tests/get_certificate.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,48 @@ | ||
from azure_devtools.perfstress_tests import PerfStressTest | ||
from azure.identity import ClientSecretCredential | ||
from azure.identity.aio import ClientSecretCredential as AsyncClientSecretCredential | ||
from azure.keyvault.certificates import CertificateClient, CertificatePolicy | ||
from azure.keyvault.certificates.aio import CertificateClient as AsyncCertificateClient | ||
|
||
|
||
class GetCertificateTest(PerfStressTest): | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
|
||
# Auth configuration | ||
tenant_id = self.get_from_env("AZURE_TENANT_ID") | ||
client_id = self.get_from_env("AZURE_CLIENT_ID") | ||
client_secret = self.get_from_env("AZURE_CLIENT_SECRET") | ||
self.credential = ClientSecretCredential(tenant_id, client_id, client_secret) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use EnvironmentCredential, if you don't mind being less explicit |
||
self.async_credential = AsyncClientSecretCredential(tenant_id, client_id, client_secret) | ||
|
||
# Create clients | ||
vault_url = self.get_from_env("AZURE_KEYVAULT_URL") | ||
self.client = CertificateClient(vault_url, self.credential) | ||
self.async_client = AsyncCertificateClient(vault_url, self.async_credential) | ||
|
||
async def global_setup(self): | ||
"""The global setup is run only once.""" | ||
await super().global_setup() | ||
await self.async_client.create_certificate("livekvtestperfcert", CertificatePolicy.get_default()) | ||
|
||
async def global_cleanup(self): | ||
"""The global cleanup is run only once.""" | ||
await self.async_client.delete_certificate("livekvtestperfcert") | ||
await self.async_client.purge_deleted_certificate("livekvtestperfcert") | ||
await super().global_cleanup() | ||
|
||
async def close(self): | ||
"""This is run after cleanup.""" | ||
await self.async_client.close() | ||
await self.async_credential.close() | ||
await super().close() | ||
|
||
def run_sync(self): | ||
"""The synchronous perf test.""" | ||
self.client.get_certificate("livekvtestperfcert") | ||
|
||
async def run_async(self): | ||
"""The asynchronous perf test.""" | ||
await self.async_client.get_certificate("livekvtestperfcert") |
48 changes: 48 additions & 0 deletions
48
sdk/keyvault/azure-keyvault-keys/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,48 @@ | ||
# azure-keyvault-keys 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` install. Start by 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 | ||
|
||
The following environment variables will need to be set for the tests to access the live resources: | ||
|
||
``` | ||
AZURE_TENANT_ID=<tenant ID of testing service principal> | ||
AZURE_CLIENT_ID=<client ID of testing service principal> | ||
AZURE_CLIENT_SECRET=<client secret of testing service principal> | ||
AZURE_KEYVAULT_URL=<URL of the testing key vault> | ||
``` | ||
|
||
### Setup for perf test runs | ||
|
||
```cmd | ||
(env) ~/azure-keyvault-keys> pip install -r dev_requirements.txt | ||
(env) ~/azure-keyvault-keys> pip install -e . | ||
``` | ||
|
||
## Test commands | ||
|
||
Once `azure-devtools` is installed, you will have access to the `perfstress` command line tool, which will scan the | ||
current module for runnable perf tests. Only a specific test can be run at a time (i.e. there is no "run all" feature). | ||
|
||
```cmd | ||
(env) ~/azure-keyvault-keys> cd tests/perfstress_tests/ | ||
(env) ~/azure-keyvault-keys/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). | ||
- `--no-cleanup` Whether to keep newly created resources after test run. Default is False (resources will be deleted). | ||
|
||
## Example command | ||
```cmd | ||
(env) ~/azure-keyvault-keys/tests> perfstress GetKeyTest | ||
``` |
Empty file.
48 changes: 48 additions & 0 deletions
48
sdk/keyvault/azure-keyvault-keys/tests/perfstress_tests/get_key.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,48 @@ | ||
from azure_devtools.perfstress_tests import PerfStressTest | ||
from azure.identity import ClientSecretCredential | ||
from azure.identity.aio import ClientSecretCredential as AsyncClientSecretCredential | ||
from azure.keyvault.keys import KeyClient | ||
from azure.keyvault.keys.aio import KeyClient as AsyncKeyClient | ||
|
||
|
||
class GetKeyTest(PerfStressTest): | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
|
||
# Auth configuration | ||
tenant_id = self.get_from_env("AZURE_TENANT_ID") | ||
client_id = self.get_from_env("AZURE_CLIENT_ID") | ||
client_secret = self.get_from_env("AZURE_CLIENT_SECRET") | ||
self.credential = ClientSecretCredential(tenant_id, client_id, client_secret) | ||
self.async_credential = AsyncClientSecretCredential(tenant_id, client_id, client_secret) | ||
|
||
# Create clients | ||
vault_url = self.get_from_env("AZURE_KEYVAULT_URL") | ||
self.client = KeyClient(vault_url, self.credential) | ||
self.async_client = AsyncKeyClient(vault_url, self.async_credential) | ||
|
||
async def global_setup(self): | ||
"""The global setup is run only once.""" | ||
await super().global_setup() | ||
await self.async_client.create_rsa_key("livekvtestperfkey") | ||
|
||
async def global_cleanup(self): | ||
"""The global cleanup is run only once.""" | ||
await self.async_client.delete_key("livekvtestperfkey") | ||
await self.async_client.purge_deleted_key("livekvtestperfkey") | ||
await super().global_cleanup() | ||
|
||
async def close(self): | ||
"""This is run after cleanup.""" | ||
await self.async_client.close() | ||
await self.async_credential.close() | ||
await super().close() | ||
|
||
def run_sync(self): | ||
"""The synchronous perf test.""" | ||
self.client.get_key("livekvtestperfkey") | ||
|
||
async def run_async(self): | ||
"""The asynchronous perf test.""" | ||
await self.async_client.get_key("livekvtestperfkey") |
48 changes: 48 additions & 0 deletions
48
sdk/keyvault/azure-keyvault-secrets/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,48 @@ | ||
# azure-keyvault-secrets 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` install. Start by 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 | ||
|
||
The following environment variables will need to be set for the tests to access the live resources: | ||
|
||
``` | ||
AZURE_TENANT_ID=<tenant ID of testing service principal> | ||
AZURE_CLIENT_ID=<client ID of testing service principal> | ||
AZURE_CLIENT_SECRET=<client secret of testing service principal> | ||
AZURE_KEYVAULT_URL=<URL of the testing key vault> | ||
``` | ||
|
||
### Setup for perf test runs | ||
|
||
```cmd | ||
(env) ~/azure-keyvault-secrets> pip install -r dev_requirements.txt | ||
(env) ~/azure-keyvault-secrets> pip install -e . | ||
``` | ||
|
||
## Test commands | ||
|
||
Once `azure-devtools` is installed, you will have access to the `perfstress` command line tool, which will scan the | ||
current module for runnable perf tests. Only a specific test can be run at a time (i.e. there is no "run all" feature). | ||
|
||
```cmd | ||
(env) ~/azure-keyvault-secrets> cd tests/perfstress_tests/ | ||
(env) ~/azure-keyvault-secrets/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). | ||
- `--no-cleanup` Whether to keep newly created resources after test run. Default is False (resources will be deleted). | ||
|
||
## Example command | ||
```cmd | ||
(env) ~/azure-keyvault-secrets/tests> perfstress GetSecretTest | ||
``` |
Empty file.
48 changes: 48 additions & 0 deletions
48
sdk/keyvault/azure-keyvault-secrets/tests/perfstress_tests/get_secret.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,48 @@ | ||
from azure_devtools.perfstress_tests import PerfStressTest | ||
from azure.identity import ClientSecretCredential | ||
from azure.identity.aio import ClientSecretCredential as AsyncClientSecretCredential | ||
from azure.keyvault.secrets import SecretClient | ||
from azure.keyvault.secrets.aio import SecretClient as AsyncSecretClient | ||
|
||
|
||
class GetSecretTest(PerfStressTest): | ||
|
||
def __init__(self, arguments): | ||
super().__init__(arguments) | ||
|
||
# Auth configuration | ||
tenant_id = self.get_from_env("AZURE_TENANT_ID") | ||
client_id = self.get_from_env("AZURE_CLIENT_ID") | ||
client_secret = self.get_from_env("AZURE_CLIENT_SECRET") | ||
self.credential = ClientSecretCredential(tenant_id, client_id, client_secret) | ||
self.async_credential = AsyncClientSecretCredential(tenant_id, client_id, client_secret) | ||
|
||
# Create clients | ||
vault_url = self.get_from_env("AZURE_KEYVAULT_URL") | ||
self.client = SecretClient(vault_url, self.credential) | ||
self.async_client = AsyncSecretClient(vault_url, self.async_credential) | ||
|
||
async def global_setup(self): | ||
"""The global setup is run only once.""" | ||
await super().global_setup() | ||
await self.async_client.set_secret("livekvtestperfsecret", "secret-value") | ||
|
||
async def global_cleanup(self): | ||
"""The global cleanup is run only once.""" | ||
await self.async_client.delete_secret("livekvtestperfsecret") | ||
await self.async_client.purge_deleted_secret("livekvtestperfsecret") | ||
await super().global_cleanup() | ||
|
||
async def close(self): | ||
"""This is run after cleanup.""" | ||
await self.async_client.close() | ||
await self.async_credential.close() | ||
await super().close() | ||
|
||
def run_sync(self): | ||
"""The synchronous perf test.""" | ||
self.client.get_secret("livekvtestperfsecret") | ||
|
||
async def run_async(self): | ||
"""The asynchronous perf test.""" | ||
await self.async_client.get_secret("livekvtestperfsecret") |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a license header