Skip to content

Commit

Permalink
Add retry count to Outcome template; add more tracing to a test
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyRyabinin committed Nov 9, 2023
1 parent 69a1790 commit 3409c6f
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 67 deletions.
17 changes: 15 additions & 2 deletions src/aws-cpp-sdk-core/include/aws/core/utils/Outcome.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ namespace Aws
result = o.result;
error = o.error;
success = o.success;
retryCount = o.retryCount;
}

return *this;
Expand All @@ -109,7 +110,8 @@ namespace Aws
Outcome(Outcome&& o) : // Required to force Move Constructor
result(std::move(o.result)),
error(std::move(o.error)),
success(o.success)
success(o.success),
retryCount(std::move(o.retryCount))
{
}

Expand All @@ -120,6 +122,7 @@ namespace Aws
result = std::move(o.result);
error = std::move(o.error);
success = o.success;
retryCount = std::move(o.retryCount);
}

return *this;
Expand Down Expand Up @@ -160,10 +163,20 @@ namespace Aws
return this->success;
}

/**
* Returns how many times the retry happened before getting this outcome.
*/
inline unsigned int GetRetryCount() const { return retryCount; }
/**
* Sets the retry count.
*/
inline void SetRetryCount(const unsigned int iRetryCount) { retryCount = iRetryCount; }

private:
R result;
E error;
bool success;
bool success = false;
unsigned int retryCount = 0;
};

} // namespace Utils
Expand Down
2 changes: 2 additions & 0 deletions src/aws-cpp-sdk-core/source/client/AWSClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ HttpResponseOutcome AWSClient::AttemptExhaustively(const Aws::Http::URI& uri,
httpRequest->SetEventStreamRequest(request.IsEventStreamRequest());

outcome = AttemptOneRequest(httpRequest, request, signerName, signerRegion, signerServiceNameOverride);
outcome.SetRetryCount(retries);
if (retries == 0)
{
m_retryStrategy->RequestBookkeeping(outcome);
Expand Down Expand Up @@ -422,6 +423,7 @@ HttpResponseOutcome AWSClient::AttemptExhaustively(const Aws::Http::URI& uri,

};
outcome = AttemptOneRequest(httpRequest, signerName, requestName, signerRegion, signerServiceNameOverride);
outcome.SetRetryCount(retries);
if (retries == 0)
{
m_retryStrategy->RequestBookkeeping(outcome);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,28 @@ namespace

void EnsureUniqueBucketNames()
{
AppendUUID(BASE_CREATE_BUCKET_TEST_NAME);
AppendUUID(BASE_DNS_UNFRIENDLY_TEST_NAME);
AppendUUID(BASE_LOCATION_BUCKET_TEST_NAME);
AppendUUID(BASE_OBJECTS_BUCKET_NAME);
AppendUUID(BASE_OBJECTS_DEFAULT_CTOR_BUCKET_NAME);
AppendUUID(BASE_PUT_OBJECTS_BUCKET_NAME);
AppendUUID(BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME);
AppendUUID(BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME);
AppendUUID(BASE_PUT_MULTIPART_BUCKET_NAME);
AppendUUID(BASE_ERRORS_TESTING_BUCKET);
AppendUUID(BASE_EVENT_STREAM_TEST_BUCKET_NAME);
AppendUUID(BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME);
AppendUUID(BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME);
Aws::Vector<std::reference_wrapper<Aws::String>> TEST_BUCKETS =
{
std::ref(BASE_CREATE_BUCKET_TEST_NAME),
std::ref(BASE_DNS_UNFRIENDLY_TEST_NAME),
std::ref(BASE_LOCATION_BUCKET_TEST_NAME),
std::ref(BASE_OBJECTS_BUCKET_NAME),
std::ref(BASE_OBJECTS_DEFAULT_CTOR_BUCKET_NAME),
std::ref(BASE_PUT_OBJECTS_BUCKET_NAME),
std::ref(BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME),
std::ref(BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME),
std::ref(BASE_PUT_MULTIPART_BUCKET_NAME),
std::ref(BASE_ERRORS_TESTING_BUCKET),
std::ref(BASE_EVENT_STREAM_TEST_BUCKET_NAME),
std::ref(BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME),
std::ref(BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME)
};

for (auto& testBucketName : TEST_BUCKETS)
{
AppendUUID(testBucketName);
SCOPED_TRACE(Aws::String("EnsureUniqueBucketNames: ") + testBucketName.get());
}
}

class RetryFiveTimesRetryStrategy: public Aws::Client::RetryStrategy
Expand All @@ -133,6 +142,27 @@ namespace
static void SetUpTestCase()
{
EnsureUniqueBucketNames();
Aws::Vector<std::reference_wrapper<Aws::String>> TEST_BUCKETS =
{
std::ref(BASE_CREATE_BUCKET_TEST_NAME),
std::ref(BASE_DNS_UNFRIENDLY_TEST_NAME),
std::ref(BASE_LOCATION_BUCKET_TEST_NAME),
std::ref(BASE_OBJECTS_BUCKET_NAME),
std::ref(BASE_OBJECTS_DEFAULT_CTOR_BUCKET_NAME),
std::ref(BASE_PUT_OBJECTS_BUCKET_NAME),
std::ref(BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME),
std::ref(BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME),
std::ref(BASE_PUT_MULTIPART_BUCKET_NAME),
std::ref(BASE_ERRORS_TESTING_BUCKET),
std::ref(BASE_EVENT_STREAM_TEST_BUCKET_NAME),
std::ref(BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME),
std::ref(BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME)
};

for (auto& testBucketName : TEST_BUCKETS)
{
SCOPED_TRACE(Aws::String("EnsureUniqueBucketNames: ") + testBucketName.get());
}
}

static void TearDownTestCase()
Expand Down Expand Up @@ -351,7 +381,9 @@ namespace

static Aws::String CalculateBucketName(const Aws::String& bucketPrefix)
{
return Aws::Testing::GetAwsResourcePrefix() + bucketPrefix;
Aws::String result = Aws::Testing::GetAwsResourcePrefix() + bucketPrefix;
SCOPED_TRACE(Aws::String("Generated bucket name for a prefix ") + bucketPrefix + ": " + result);
return result;
}

static Aws::String PreparePresignedUrlTest()
Expand Down
Loading

0 comments on commit 3409c6f

Please sign in to comment.