Skip to content

Commit

Permalink
[Perf] keyvault-secrets test improvements (#20900)
Browse files Browse the repository at this point in the history
- Rename option from "list-size" to "count" to align with other languages
- Validate vault contains 0 secrets before running
  • Loading branch information
mikeharder authored Sep 27, 2021
1 parent 186b55c commit 4aaa1e8
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ def __init__(self, arguments):
vault_url = self.get_from_env("AZURE_KEYVAULT_URL")
self.client = SecretClient(vault_url, self.credential, **self._client_kwargs)
self.async_client = AsyncSecretClient(vault_url, self.async_credential, **self._client_kwargs)
self.secret_names = ["livekvtestlistperfsecret{}".format(i) for i in range(self.args.list_size)]
self.secret_names = ["livekvtestlistperfsecret{}".format(i) for i in range(self.args.count)]

async def global_setup(self):
"""The global setup is run only once."""
# Validate that vault contains 0 secrets (including soft-deleted secrets), since additional secrets
# (including soft-deleted) impact performance.
async for secret in self.async_client.list_properties_of_secrets():
raise Exception("KeyVault %s must contain 0 secrets (including soft-deleted) before starting perf test" \
% self.async_client.vault_url)
async for secret in self.async_client.list_deleted_secrets():
raise Exception("KeyVault %s must contain 0 secrets (including soft-deleted) before starting perf test" \
% self.async_client.vault_url)

await super().global_setup()
create = [self.async_client.set_secret(name, "secret-value") for name in self.secret_names]
await asyncio.wait(create)
Expand Down Expand Up @@ -63,5 +72,5 @@ async def run_async(self):
def add_arguments(parser):
super(ListSecretsTest, ListSecretsTest).add_arguments(parser)
parser.add_argument(
'--list-size', nargs='?', type=int, help='Number of secrets to list. Defaults to 10', default=10
'--count', nargs='?', type=int, help='Number of secrets to list. Defaults to 10', default=10
)

0 comments on commit 4aaa1e8

Please sign in to comment.