diff --git a/sdk/keyvault/assets.json b/sdk/keyvault/assets.json index 1fcadfa3e..8391afdb4 100644 --- a/sdk/keyvault/assets.json +++ b/sdk/keyvault/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "cpp", "TagPrefix": "cpp/keyvault", - "Tag": "cpp/keyvault_e1582c490f" + "Tag": "cpp/keyvault_ae1c1474ad" } diff --git a/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp b/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp index cc6176015..300b49f20 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp @@ -572,7 +572,33 @@ TEST_F(KeyVaultCertificateClientTest, BackupRestoreCertificate) auto result = response.PollUntilDone(m_defaultWait); EXPECT_EQ(result.Value.Name(), certificateName); client.PurgeDeletedCertificate(certificateName); - std::this_thread::sleep_for(m_defaultWait); + TestSleep(m_defaultWait); + } + { + int retries = 15; + // before we restore we need to ensure the certificate is purged. + // since we have no visibility into the purge status we will just wait and check for a few + // seconds + while (retries > 0) + { + try + { + client.GetDeletedCertificate(certificateName); + } + catch (Azure::Core::RequestFailedException const&) + { + std::cout << std::endl << "- Certificate is gone"; + break; + } + TestSleep(m_defaultWait); + retries--; + } + + if (retries == 0) + { + std::cout << std::endl << "retries reached 0"; + EXPECT_TRUE(false); + } } { auto responseRestore = client.RestoreCertificateBackup(certBackup.Value.Certificate); diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp index e119de653..4a0537c9c 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp @@ -49,10 +49,33 @@ TEST_F(KeyVaultKeyClient, BackupKey) auto response = client.PurgeDeletedKey(keyName); CheckValidResponse(response, Azure::Core::Http::HttpStatusCode::NoContent); // Purge can take up to 2 min - TestSleep(4min); + TestSleep(m_testPollingIntervalMs); } - { // Check key is gone - EXPECT_THROW(client.GetKey(keyName), Azure::Core::RequestFailedException); + { + int retries = 15; + // before we restore we need to ensure the key is purged. + // since we have no visibility into the purge status we will just wait and check for a few + // seconds + while (retries > 0) + { + try + { + client.GetDeletedKey(keyName); + } + catch (Azure::Core::RequestFailedException const&) + { + std::cout << std::endl << "- Key is gone"; + break; + } + TestSleep(m_testPollingIntervalMs); + retries--; + } + + if (retries == 0) + { + std::cout << std::endl << "retries reached 0"; + EXPECT_TRUE(false); + } } { // Restore diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp index 94b6da1e8..02c8c2add 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp @@ -184,7 +184,33 @@ TEST_F(KeyVaultSecretClientTest, BackupRestore) { auto purgedResponse = client.PurgeDeletedSecret(secretName); CheckValidResponse(purgedResponse, Azure::Core::Http::HttpStatusCode::NoContent); - TestSleep(4min); + TestSleep(m_defaultWait); + } + { + int retries = 15; + // before we restore we need to ensure the secret is purged. + // since we have no visibility into the purge status we will just wait and check for a few + // seconds + while (retries > 15) + { + try + { + client.GetDeletedSecret(secretName); + } + catch (Azure::Core::RequestFailedException const&) + { + std::cout << std::endl << "- Secret is gone"; + break; + } + TestSleep(m_defaultWait); + retries--; + } + + if (retries == 0) + { + std::cout << std::endl << "retries reached 0"; + EXPECT_TRUE(false); + } } { auto restore = client.RestoreSecretBackup(backupData);