Skip to content

Commit

Permalink
Add rspec retry for :jruby_flaky (#2928)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods authored Oct 16, 2023
1 parent d1b43fa commit 918f8b4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build_tools/spec/changelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Aws
module Plugins
describe EndpointDiscovery do
describe EndpointDiscovery, :jruby_flaky do

EndpointDiscoveryClient = ApiHelper.sample_service(
api: {
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-core/spec/retry_errors_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions gems/aws-sdk-core/spec/shared_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,20 @@

Thread.report_on_exception = current_value if current_value
end

if defined?(JRUBY_VERSION)
config.around(:each, :jruby_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
end
end
end
2 changes: 1 addition & 1 deletion gems/aws-sdk-s3/spec/object/download_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-s3/spec/object/upload_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 918f8b4

Please sign in to comment.