From 00568c92b960f1a4e68964a60e26aca969a0fbeb Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Wed, 11 Oct 2023 15:06:19 -0700 Subject: [PATCH 1/3] Add rspec retry for :flaky --- gems/aws-sdk-core/spec/shared_spec_helper.rb | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gems/aws-sdk-core/spec/shared_spec_helper.rb b/gems/aws-sdk-core/spec/shared_spec_helper.rb index a8413857bf6..d3ce7237dfd 100644 --- a/gems/aws-sdk-core/spec/shared_spec_helper.rb +++ b/gems/aws-sdk-core/spec/shared_spec_helper.rb @@ -10,6 +10,16 @@ require_relative './sigv4_helper' +module RSpec + module Core + class Example + def clear_exception + @exception = nil + end + end + end +end + # Prevent the SDK unit tests from loading actual credentials while under test. # By default the SDK attempts to load credentials from: # @@ -51,4 +61,18 @@ Thread.report_on_exception = current_value if current_value end + + config.around(:each, :flaky) do |example| + attempt = 0 + retries = 3 + loop do + attempt += 1 + example.run + if example.exception && attempt < retries + example.example.clear_exception + redo + end + break + end + end end From c90590814358514ff90090b739c11d3f48bc8807 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Thu, 12 Oct 2023 09:07:05 -0700 Subject: [PATCH 2/3] Cleanup, apply only to jruby and add :flaky to tests --- .../aws/plugins/endpoint_discovery_spec.rb | 2 +- gems/aws-sdk-core/spec/shared_spec_helper.rb | 30 +++++++------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb b/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb index 3f1059da84f..553f8bf7771 100644 --- a/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb +++ b/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb @@ -4,7 +4,7 @@ module Aws module Plugins - describe EndpointDiscovery do + describe EndpointDiscovery, :flaky do EndpointDiscoveryClient = ApiHelper.sample_service( api: { diff --git a/gems/aws-sdk-core/spec/shared_spec_helper.rb b/gems/aws-sdk-core/spec/shared_spec_helper.rb index d3ce7237dfd..ed28338b685 100644 --- a/gems/aws-sdk-core/spec/shared_spec_helper.rb +++ b/gems/aws-sdk-core/spec/shared_spec_helper.rb @@ -10,16 +10,6 @@ require_relative './sigv4_helper' -module RSpec - module Core - class Example - def clear_exception - @exception = nil - end - end - end -end - # Prevent the SDK unit tests from loading actual credentials while under test. # By default the SDK attempts to load credentials from: # @@ -62,17 +52,19 @@ def clear_exception Thread.report_on_exception = current_value if current_value end - config.around(:each, :flaky) do |example| - attempt = 0 - retries = 3 - loop do - attempt += 1 - example.run - if example.exception && attempt < retries - example.example.clear_exception + if defined?(JRUBY_VERSION) + config.around(:each, :flaky) do |example| + attempt = 0 + retries = 3 + loop do + attempt += 1 + example.run + break if !example.exception || attempt >= retries + + # clear the exception, ensuring it can run from a clean state + example.example.instance_variable_set(:@exception, nil) redo end - break end end end From dd717cb7b58766b346bd04f615417cd078445704 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 16 Oct 2023 14:59:24 -0400 Subject: [PATCH 3/3] Update naming and add to flaky tests --- build_tools/spec/changelog_spec.rb | 2 +- gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb | 2 +- gems/aws-sdk-core/spec/retry_errors_helper.rb | 2 +- gems/aws-sdk-core/spec/shared_spec_helper.rb | 2 +- gems/aws-sdk-s3/spec/object/download_file_spec.rb | 2 +- gems/aws-sdk-s3/spec/object/upload_stream_spec.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build_tools/spec/changelog_spec.rb b/build_tools/spec/changelog_spec.rb index f2c767d1ec8..37dc2b4a6bc 100644 --- a/build_tools/spec/changelog_spec.rb +++ b/build_tools/spec/changelog_spec.rb @@ -3,7 +3,7 @@ require_relative 'spec_helper' module BuildTools - describe Changelog do + describe Changelog, :jruby_flaky do let(:path) { Tempfile.create('file').path } let(:expected_changelog) { <<-LOG diff --git a/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb b/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb index 553f8bf7771..b4480ebb7e8 100644 --- a/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb +++ b/gems/aws-sdk-core/spec/aws/plugins/endpoint_discovery_spec.rb @@ -4,7 +4,7 @@ module Aws module Plugins - describe EndpointDiscovery, :flaky do + describe EndpointDiscovery, :jruby_flaky do EndpointDiscoveryClient = ApiHelper.sample_service( api: { diff --git a/gems/aws-sdk-core/spec/retry_errors_helper.rb b/gems/aws-sdk-core/spec/retry_errors_helper.rb index 342edf48f8f..93497664c05 100644 --- a/gems/aws-sdk-core/spec/retry_errors_helper.rb +++ b/gems/aws-sdk-core/spec/retry_errors_helper.rb @@ -91,7 +91,7 @@ def apply_expectations(test_case) if expected[:clock_correction] endpoint = resp.context.http_request.endpoint expect(resp.context.config.clock_skew.clock_correction(endpoint)) - .to be_within(1).of(expected[:clock_correction]) + .to be_within(5).of(expected[:clock_correction]) end end diff --git a/gems/aws-sdk-core/spec/shared_spec_helper.rb b/gems/aws-sdk-core/spec/shared_spec_helper.rb index ed28338b685..6cee7bb4f9a 100644 --- a/gems/aws-sdk-core/spec/shared_spec_helper.rb +++ b/gems/aws-sdk-core/spec/shared_spec_helper.rb @@ -53,7 +53,7 @@ end if defined?(JRUBY_VERSION) - config.around(:each, :flaky) do |example| + config.around(:each, :jruby_flaky) do |example| attempt = 0 retries = 3 loop do diff --git a/gems/aws-sdk-s3/spec/object/download_file_spec.rb b/gems/aws-sdk-s3/spec/object/download_file_spec.rb index bd398a35800..6bef89df4c6 100644 --- a/gems/aws-sdk-s3/spec/object/download_file_spec.rb +++ b/gems/aws-sdk-s3/spec/object/download_file_spec.rb @@ -9,7 +9,7 @@ module S3 let(:client) { S3::Client.new(stub_responses: true) } let(:tmpdir) { Dir.tmpdir } - describe '#download_file' do + describe '#download_file', :jruby_flaky do let(:path) { Tempfile.new('destination').path } let(:small_obj) do diff --git a/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb b/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb index b201f8b93e7..1897f82b70e 100644 --- a/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb +++ b/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb @@ -8,7 +8,7 @@ module S3 describe Object do let(:client) { S3::Client.new(stub_responses: true) } - describe '#upload_stream' do + describe '#upload_stream', :jruby_flaky do let(:object) do S3::Object.new( bucket_name: 'bucket',