Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for infinite paging loop on CloudWatchLogs::Client#get_log_events.
See related issue #712
- Loading branch information
1 parent
b4c9eee
commit e02eb99
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'spec_helper' | ||
|
||
module Aws | ||
module CloudWatchLogs | ||
describe Client do | ||
|
||
let(:client) { Client.new(stub_responses:true) } | ||
|
||
describe '#get_log_events' do | ||
|
||
it 'stops paginating when the next tokens are fixed' do | ||
json = [] | ||
json << (<<-JSON) | ||
{ | ||
"events": [ | ||
{ | ||
"ingestionTime": 1396035394997, | ||
"timestamp": 1396035378988, | ||
"message": "Example Event 1" | ||
} | ||
], | ||
"nextForwardToken": "abc" | ||
} | ||
JSON | ||
json << (<<-JSON) | ||
{ | ||
"events": [ | ||
{ | ||
"ingestionTime": 1396035394997, | ||
"timestamp": 1396035378988, | ||
"message": "Example Event 2" | ||
} | ||
], | ||
"nextForwardToken": "mno" | ||
} | ||
JSON | ||
json << (<<-JSON) | ||
{ | ||
"events": [], | ||
"nextForwardToken": "mno" | ||
} | ||
JSON | ||
client.handle(step: :send) do |context| | ||
context.http_response.signal_headers(200, {}) | ||
context.http_response.signal_data(json.shift) | ||
context.http_response.signal_done | ||
Seahorse::Client::Response.new(context:context) | ||
end | ||
|
||
yield_count = 0 | ||
params = { log_group_name:'name', log_stream_name:'name' } | ||
client.get_log_events(params).each { |resp| yield_count += 1 } | ||
expect(yield_count).to eq(3) | ||
end | ||
end | ||
end | ||
end | ||
end |