From c9b50638c9544bafb450c3d02869294d9257719b Mon Sep 17 00:00:00 2001 From: Richard Wang Date: Wed, 31 Dec 2025 09:18:11 -0800 Subject: [PATCH 1/3] Fix flaky test --- gems/aws-sdk-core/CHANGELOG.md | 2 ++ gems/aws-sdk-core/spec/aws/login_credentials_spec.rb | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gems/aws-sdk-core/CHANGELOG.md b/gems/aws-sdk-core/CHANGELOG.md index 2281a6ec34d..040c10ba1d4 100644 --- a/gems/aws-sdk-core/CHANGELOG.md +++ b/gems/aws-sdk-core/CHANGELOG.md @@ -1,6 +1,8 @@ Unreleased Changes ------------------ +* Issue - Fix flaky login credentials spec test. + 3.240.0 (2025-12-16) ------------------ diff --git a/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb b/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb index f08788a9ece..ec11ddc8183 100644 --- a/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb +++ b/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb @@ -128,13 +128,14 @@ module Aws expect(creds.credentials.secret_access_key).to eq('new_secret') expect(creds.credentials.session_token).to eq('new_token') expect(creds.credentials.account_id).to eq('0123456789012') - expect(creds.expiration).to eq(Time.parse(new_expiration)) + expect(creds.expiration).to eq(Time.parse(expiration) + 60 + 900) end end context 'expired token with refresh token' do - let(:old_expiration) { (Time.now.utc + 60).to_datetime.rfc3339 } - let(:new_expiration) { (Time.now.utc + 900).to_datetime.rfc3339 } + let(:time) { Time.now.utc.round } + let(:old_expiration) { (time + 60).to_datetime.rfc3339 } + let(:new_expiration) { (time + 900).to_datetime.rfc3339 } let(:cached_token) do { @@ -191,6 +192,7 @@ module Aws end it 'refreshes the token' do + allow(Time).to receive(:now).and_return(time) mock_token_file(login_session, cached_token) client.stub_responses(:create_o_auth_2_token, signin_resp) creds = LoginCredentials.new(login_session: login_session, client: client) From 722db778e624f3fbb88a6cb3fbf3a84d6d3112c1 Mon Sep 17 00:00:00 2001 From: Richard Wang Date: Mon, 5 Jan 2026 08:42:05 -0800 Subject: [PATCH 2/3] PR comments --- gems/aws-sdk-core/spec/aws/login_credentials_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb b/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb index ec11ddc8183..e883ebaff7c 100644 --- a/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb +++ b/gems/aws-sdk-core/spec/aws/login_credentials_spec.rb @@ -133,7 +133,7 @@ module Aws end context 'expired token with refresh token' do - let(:time) { Time.now.utc.round } + let(:time) { Time.parse('2026-01-01 00:00:00 UTC') } let(:old_expiration) { (time + 60).to_datetime.rfc3339 } let(:new_expiration) { (time + 900).to_datetime.rfc3339 } @@ -179,9 +179,9 @@ module Aws secret_access_key: 'new_secret', session_token: 'new_token' }, - token_type: "aws_sigv4", + token_type: 'aws_sigv4', expires_in: 900, - refresh_token: "new_refresh_token", + refresh_token: 'new_refresh_token', id_token: 'identity_token' } } @@ -189,10 +189,10 @@ module Aws before do allow_any_instance_of(LoginCredentials).to receive(:warn).with(/WARNING: OpenSSL 3.6.x/) + allow(Time).to receive(:now).and_return(time) end it 'refreshes the token' do - allow(Time).to receive(:now).and_return(time) mock_token_file(login_session, cached_token) client.stub_responses(:create_o_auth_2_token, signin_resp) creds = LoginCredentials.new(login_session: login_session, client: client) From 5966d4ff35013d17ebc1244cf25e0b074925d129 Mon Sep 17 00:00:00 2001 From: Richard Wang Date: Mon, 5 Jan 2026 09:30:23 -0800 Subject: [PATCH 3/3] Add jruby flaky tag --- gems/aws-sdk-s3/spec/multipart_file_uploader_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gems/aws-sdk-s3/spec/multipart_file_uploader_spec.rb b/gems/aws-sdk-s3/spec/multipart_file_uploader_spec.rb index d175588b6a3..4901ff59361 100644 --- a/gems/aws-sdk-s3/spec/multipart_file_uploader_spec.rb +++ b/gems/aws-sdk-s3/spec/multipart_file_uploader_spec.rb @@ -125,7 +125,7 @@ module S3 expect { subject.upload(large_file, params) }.to raise_error(/multipart upload failed: part 3 failed/) end - it 'reports when it is unable to abort a failed multipart upload' do + it 'reports when it is unable to abort a failed multipart upload', :jruby_flaky do client.stub_responses(:upload_part, RuntimeError.new('part failed')) client.stub_responses(:abort_multipart_upload, RuntimeError.new('network-error')) expect do