From 2402424cbf09473190f5c8d6f223c7d7ae4f8010 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 23 Sep 2021 20:02:30 -0700 Subject: [PATCH 1/2] Validate vault contains 0 secrets --- .../tests/perfstress_tests/list_secrets.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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..8ffccd096017 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 @@ -28,6 +28,15 @@ def __init__(self, arguments): 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) From b0404aa155aa5225024b1c53e468af44464a91b2 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 24 Sep 2021 17:04:11 -0700 Subject: [PATCH 2/2] Rename option from list-size to count - Aligns with other languages --- .../tests/perfstress_tests/list_secrets.py | 4 ++-- 1 file changed, 2 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 8ffccd096017..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,7 +24,7 @@ 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.""" @@ -72,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 )