From 4aaa1e83e602734a1f5a00329476b4013956bafc Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 27 Sep 2021 16:44:06 -0700 Subject: [PATCH] [Perf] keyvault-secrets test improvements (#20900) - Rename option from "list-size" to "count" to align with other languages - Validate vault contains 0 secrets before running --- .../tests/perfstress_tests/list_secrets.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-secrets/tests/perfstress_tests/list_secrets.py b/sdk/keyvault/azure-keyvault-secrets/tests/perfstress_tests/list_secrets.py index 983d6e6703ee..00f42aa3395a 100644 --- a/sdk/keyvault/azure-keyvault-secrets/tests/perfstress_tests/list_secrets.py +++ b/sdk/keyvault/azure-keyvault-secrets/tests/perfstress_tests/list_secrets.py @@ -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) @@ -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 )