Skip to content

add provider creation retry for tests #3453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const char AWS_CONTAINER_AUTHORIZATION_TOKEN[] = "AWS_CONTAINER_AUTHORIZATI

const std::vector<const char*> ENV_VARS = {AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI, AWS_CONTAINER_CREDENTIALS_FULL_URI, AWS_CONTAINER_AUTHORIZATION_TOKEN};

namespace {
size_t PROVIDER_CREATE_ATTEMPTS = 5;
}


class GeneralHTTPCredentialsProviderTest : public Aws::Testing::AwsCppSdkGTestSuite
{
Expand Down Expand Up @@ -488,9 +492,14 @@ TEST_P(GeneralHTTPCredentialsProviderResponseHandlingTests, ResponseHandlingTest
}

Aws::Environment::SetEnv("AWS_CONTAINER_CREDENTIALS_FULL_URI", "http://localhost/get-credentials", 1);
std::shared_ptr<GeneralHTTPCredentialsProvider> genProvider = CreateGeneralProvider();
ASSERT_TRUE(genProvider && genProvider->IsValid());
AWSCredentials credentials = genProvider->GetAWSCredentials();
size_t createRetryCount{0};
std::shared_ptr<GeneralHTTPCredentialsProvider> provider{nullptr};
while ((!provider || !provider->IsValid()) && createRetryCount < PROVIDER_CREATE_ATTEMPTS) {
provider = CreateGeneralProvider();
createRetryCount++;
}
ASSERT_TRUE(provider && provider->IsValid());
AWSCredentials credentials = provider->GetAWSCredentials();

auto requestsMade = m_mockHttpClient->GetAllRequestsMade();
if (expect.GetString("type") == "error") {
Expand Down
Loading