Skip to content

Commit d609c00

Browse files
authored
Backup Tests redo PR (#5916)
* redo PR * fdedws * added logging
1 parent 6d77ab8 commit d609c00

4 files changed

Lines changed: 81 additions & 6 deletions

File tree

sdk/keyvault/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "cpp",
44
"TagPrefix": "cpp/keyvault",
5-
"Tag": "cpp/keyvault_e1582c490f"
5+
"Tag": "cpp/keyvault_ae1c1474ad"
66
}

sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,33 @@ TEST_F(KeyVaultCertificateClientTest, BackupRestoreCertificate)
572572
auto result = response.PollUntilDone(m_defaultWait);
573573
EXPECT_EQ(result.Value.Name(), certificateName);
574574
client.PurgeDeletedCertificate(certificateName);
575-
std::this_thread::sleep_for(m_defaultWait);
575+
TestSleep(m_defaultWait);
576+
}
577+
{
578+
int retries = 15;
579+
// before we restore we need to ensure the certificate is purged.
580+
// since we have no visibility into the purge status we will just wait and check for a few
581+
// seconds
582+
while (retries > 0)
583+
{
584+
try
585+
{
586+
client.GetDeletedCertificate(certificateName);
587+
}
588+
catch (Azure::Core::RequestFailedException const&)
589+
{
590+
std::cout << std::endl << "- Certificate is gone";
591+
break;
592+
}
593+
TestSleep(m_defaultWait);
594+
retries--;
595+
}
596+
597+
if (retries == 0)
598+
{
599+
std::cout << std::endl << "retries reached 0";
600+
EXPECT_TRUE(false);
601+
}
576602
}
577603
{
578604
auto responseRestore = client.RestoreCertificateBackup(certBackup.Value.Certificate);

sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,33 @@ TEST_F(KeyVaultKeyClient, BackupKey)
4949
auto response = client.PurgeDeletedKey(keyName);
5050
CheckValidResponse(response, Azure::Core::Http::HttpStatusCode::NoContent);
5151
// Purge can take up to 2 min
52-
TestSleep(4min);
52+
TestSleep(m_testPollingIntervalMs);
5353
}
54-
{ // Check key is gone
55-
EXPECT_THROW(client.GetKey(keyName), Azure::Core::RequestFailedException);
54+
{
55+
int retries = 15;
56+
// before we restore we need to ensure the key is purged.
57+
// since we have no visibility into the purge status we will just wait and check for a few
58+
// seconds
59+
while (retries > 0)
60+
{
61+
try
62+
{
63+
client.GetDeletedKey(keyName);
64+
}
65+
catch (Azure::Core::RequestFailedException const&)
66+
{
67+
std::cout << std::endl << "- Key is gone";
68+
break;
69+
}
70+
TestSleep(m_testPollingIntervalMs);
71+
retries--;
72+
}
73+
74+
if (retries == 0)
75+
{
76+
std::cout << std::endl << "retries reached 0";
77+
EXPECT_TRUE(false);
78+
}
5679
}
5780
{
5881
// Restore

sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,33 @@ TEST_F(KeyVaultSecretClientTest, BackupRestore)
184184
{
185185
auto purgedResponse = client.PurgeDeletedSecret(secretName);
186186
CheckValidResponse(purgedResponse, Azure::Core::Http::HttpStatusCode::NoContent);
187-
TestSleep(4min);
187+
TestSleep(m_defaultWait);
188+
}
189+
{
190+
int retries = 15;
191+
// before we restore we need to ensure the secret is purged.
192+
// since we have no visibility into the purge status we will just wait and check for a few
193+
// seconds
194+
while (retries > 15)
195+
{
196+
try
197+
{
198+
client.GetDeletedSecret(secretName);
199+
}
200+
catch (Azure::Core::RequestFailedException const&)
201+
{
202+
std::cout << std::endl << "- Secret is gone";
203+
break;
204+
}
205+
TestSleep(m_defaultWait);
206+
retries--;
207+
}
208+
209+
if (retries == 0)
210+
{
211+
std::cout << std::endl << "retries reached 0";
212+
EXPECT_TRUE(false);
213+
}
188214
}
189215
{
190216
auto restore = client.RestoreSecretBackup(backupData);

0 commit comments

Comments
 (0)