Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/keyvault/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/keyvault",
"Tag": "cpp/keyvault_e1582c490f"
"Tag": "cpp/keyvault_ae1c1474ad"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment thread
gearama marked this conversation as resolved.
Comment on lines +599 to +600
Copy link
Copy Markdown
Contributor

@ahsonkhan ahsonkhan Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Another mechanism to add output messages for tests that fail, instead of cout, is use the gtest feature.

EXPECT_TRUE(<put condition here>) << <put your log message here>;

This way, you only output that error message if the test assertion fails.

You can also use: GTEST_LOG_INFO. We have a few places in test that do that already.

In cases like this, where you want to fail a test if it reaches this point, rather than using EXPECT_TRUE(false), you can see GTEST_FAIL with an output message appended to it

Here are a couple example usages of that:

GTEST_LOG_(ERROR) << "Response: " << bodyAsString;
GTEST_FAIL();

GTEST_FAIL() << "GetToken should have thrown an exception due to an invalid tenant ID.";

}
}
{
auto responseRestore = client.RestoreCertificateBackup(certBackup.Value.Certificate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down