[Perf] keyvault-secrets test improvements
Rename option from "list-size" to "count" to align with other languages
Validate vault contains 0 secrets before running
@@ -24,10 +24,19 @@ class ListSecretsTest(PerfStressTest):
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 @@ class ListSecretsTest(PerfStressTest):
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
)
