Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transient spec failures #2909

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gems/aws-sdk-core/spec/aws/plugins/retries/clock_skew_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module Plugins
let(:server_time) { (Time.now.utc + 1000).to_s }
it 'updates the corrections' do
subject.update_clock_correction(context)
expect(subject.clock_correction(endpoint)).to be_within(1).of(1000)
expect(subject.clock_correction(endpoint)).to be_within(5).of(1000)
end

it 'does not update corrections for other end points' do
Expand All @@ -90,7 +90,7 @@ module Plugins
let(:server_time) { (Time.now.utc + 1000).to_s }
it 'updates the skew' do
subject.update_estimated_skew(context)
expect(subject.estimated_skew(endpoint)).to be_within(1).of(1000)
expect(subject.estimated_skew(endpoint)).to be_within(5).of(1000)
end
end
end
Expand Down
26 changes: 18 additions & 8 deletions gems/aws-sdk-s3/spec/object/download_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,14 @@ module S3
end

n_calls = 0
mutex = Mutex.new
callback = proc do |bytes, part_sizes, total|
expect(bytes.size).to eq(4)
expect(part_sizes.size).to eq(4)
expect(total).to eq(20*one_meg)
n_calls += 1
mutex.synchronize do
expect(bytes.size).to eq(4)
expect(part_sizes.size).to eq(4)
expect(total).to eq(20*one_meg)
n_calls += 1
end
end

large_obj.download_file(path, progress_callback: callback)
Expand Down Expand Up @@ -218,10 +221,11 @@ module S3
end

it 'raises an error when checksum validation fails on multipart' do
thread = double(value: nil)
client.stub_responses(:get_object, {body: 'body', checksum_sha1: 'invalid'})

thread = double(value: nil)
allow(thread).to receive(:abort_on_exception=)
expect(Thread).to receive(:new).and_yield.and_return(thread)
allow(thread).to receive(:abort_on_exception)

expect do
large_obj.download_file(path)
Expand All @@ -230,12 +234,15 @@ module S3

it 'calls on_checksum_validated on single part' do
callback_data = {called: 0}
mutex = Mutex.new
client.stub_responses(
:get_object,
{body: 'body', checksum_sha1: 'Agg/RXngimEkJcDBoX7ket14O5Q='}
)
callback = proc do |_alg, _resp|
callback_data[:called] += 1
mutex.synchronize do
callback_data[:called] += 1
end
end

small_obj.download_file(path, on_checksum_validated: callback)
Expand All @@ -252,8 +259,11 @@ module S3
checksum_sha1: 'Agg/RXngimEkJcDBoX7ket14O5Q='
}
)
mutex = Mutex.new
callback = proc do |_alg, _resp|
callback_data[:called] += 1
mutex.synchronize do
callback_data[:called] += 1
end
end

large_obj.download_file(path, on_checksum_validated: callback)
Expand Down
33 changes: 21 additions & 12 deletions gems/aws-sdk-s3/spec/object/upload_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,14 @@ module S3
client.stub_responses(:create_multipart_upload, upload_id: 'id')
client.stub_responses(:complete_multipart_upload)
result = []
mutex = Mutex.new
allow(client).to receive(:upload_part) do |part|
result << [
part[:part_number],
part[:body].read.size
]
mutex.synchronize do
result << [
part[:part_number],
part[:body].read.size
]
end
end.and_return(double(:upload_part, etag: 'etag'))
object.upload_stream(part_size: 7 * 1024 * 1024) do |write_stream|
17.times { write_stream << one_mb }
Expand All @@ -195,11 +198,14 @@ module S3
client.stub_responses(:create_multipart_upload, upload_id: 'id')
client.stub_responses(:complete_multipart_upload)
result = []
mutex = Mutex.new
allow(client).to receive(:upload_part) do |part|
result << [
part[:part_number],
part[:body].read.size
]
mutex.synchronize do
result << [
part[:part_number],
part[:body].read.size
]
end
end.and_return(double(:upload_part, etag: 'etag'))
object.upload_stream do |write_stream|
17.times { write_stream << one_mb }
Expand Down Expand Up @@ -375,11 +381,14 @@ module S3
client.stub_responses(:create_multipart_upload, upload_id: 'id')
client.stub_responses(:complete_multipart_upload)
result = []
mutex = Mutex.new
allow(client).to receive(:upload_part) do |part|
result << [
part[:part_number],
part[:body].read.size
]
mutex.synchronize do
result << [
part[:part_number],
part[:body].read.size
]
end
end.and_return(double(:upload_part, etag: 'etag'))
object.upload_stream(tempfile: true) do |write_stream|
17.times { write_stream << one_mb }
Expand Down
1 change: 1 addition & 0 deletions gems/aws-sdk-sqs/spec/queue_poller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def sample_message(n = nil)

it 'polls until :idle_timeout seconds have past without messages' do
now = Time.now
allow(Time).to receive(:now).and_return(now)
one_minute_later = now + 61
expect(client).to receive(:receive_message).exactly(10).times.
and_return(client.stub_data(:receive_message))
Expand Down
Loading