diff --git a/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb b/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb index 277e7dfcb2f..7ea64b65756 100644 --- a/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb +++ b/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb @@ -310,13 +310,28 @@ module Plugins { response: { status_code: 200, error: nil }, expect: { available_capacity: 10, retries: 2 } - }, + } + ] + + # failure cases ending in success + handle_with_retry(test_case_def) + + # after success, new request + test_case_post_success = [ { response: { status_code: 500, error: service_error }, expect: { available_capacity: 5, retries: 1, delay: 1 } + }, + { + response: { status_code: 200, error: nil }, + expect: { available_capacity: 10, retries: 1 } } ] - handle_with_retry(test_case_def) + # reset request + config.max_attempts = 2 + resp.context.retries = 0 + resp.context.metadata[:retries] = {} + handle_with_retry(test_case_post_success) end it 'corrects and retries clock skew errors' do diff --git a/gems/aws-sdk-core/spec/retry_errors_helper.rb b/gems/aws-sdk-core/spec/retry_errors_helper.rb index 759a675ba88..302a7eff733 100644 --- a/gems/aws-sdk-core/spec/retry_errors_helper.rb +++ b/gems/aws-sdk-core/spec/retry_errors_helper.rb @@ -30,10 +30,18 @@ def handle_with_retry(test_cases) resp end + expect(i).to( + eq(test_cases.size), + "Wrong number of retries. Handler was called #{i} times but "\ + "#{test_cases.size} test cases were defined." + ) + # Handle has finished called. Apply final expectations. apply_expectations(test_cases[i - 1]) end + + # apply a delay to the current test case # See handle_with_retry for test case definition def apply_delay(test_case)