Skip to content

Commit

Permalink
Cleanup, apply only to jruby and add :flaky to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Oct 12, 2023
1 parent 00568c9 commit c905908
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
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, :flaky do

EndpointDiscoveryClient = ApiHelper.sample_service(
api: {
Expand Down
30 changes: 11 additions & 19 deletions gems/aws-sdk-core/spec/shared_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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

0 comments on commit c905908

Please sign in to comment.