Skip to content

Commit 5da82aa

Browse files
committed
fix IAM eventual consistency in flaky test
1 parent dd53a46 commit 5da82aa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/aws-cpp-sdk-core-integration-tests/STSWebIdentityProviderIntegrationTest.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ TEST_F(STSWebIdentityProviderIntegrationTest, ShouldWork) {
157157
config.credentialProviderConfig.stsCredentialsProviderConfig.roleArn = testResourcesRAII.GetRoleArn();
158158
config.credentialProviderConfig.stsCredentialsProviderConfig.tokenFilePath = testResourcesRAII.GetTokenFileName();
159159
STSAssumeRoleWebIdentityCredentialsProvider provider{config.credentialProviderConfig};
160-
const auto credentials = provider.GetAWSCredentials();
160+
AWSCredentials credentials{};
161+
size_t attempts = 0;
162+
bool shouldSleep = false;
163+
do {
164+
if (shouldSleep) {
165+
std::this_thread::sleep_for(IAM_CONSISTENCY_SLEEP);
166+
}
167+
credentials = provider.GetAWSCredentials();
168+
shouldSleep = true;
169+
attempts++;
170+
} while (credentials.IsEmpty() && attempts < MAX_IAM_CONSISTENCY_RETRIES);
161171
EXPECT_FALSE(credentials.IsEmpty());
162172
}

0 commit comments

Comments
 (0)