|
232 | 232 | end |
233 | 233 | end |
234 | 234 |
|
235 | | - context 'max_payload_size 2MB' do |
236 | | - let(:config) { { 'ingest_endpoint_url' => ingest_endpoint_url, 'api_key' => api_key, 'max_payload_size' => 2_000_000 } } |
| 235 | + context 'max_payload_size 500' do |
| 236 | + let(:max_payload_size) { 500 } |
| 237 | + let(:config) { { 'ingest_endpoint_url' => ingest_endpoint_url, 'api_key' => api_key, 'max_payload_size' => max_payload_size } } |
237 | 238 | subject { LogStash::Outputs::Dynatrace.new(config) } |
238 | 239 |
|
239 | 240 | before do |
240 | 241 | allow(subject).to receive(:send_event) { |e, att| [:success, e, att] } |
241 | | - subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 1_250_000 }) }) |
242 | 242 | end |
243 | 243 |
|
244 | | - it 'should split the chunk into multiple requests' do |
245 | | - expect(subject).to have_received(:send_event).exactly(2).times |
| 244 | + it 'should send 2 400B messages in multiple requests' do |
| 245 | + subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 400 }) }) |
| 246 | + expect(subject).to have_received(:send_event).exactly(2).times do |s| |
| 247 | + expect(s.bytesize).to be <= max_payload_size |
| 248 | + end |
| 249 | + end |
| 250 | + |
| 251 | + it 'should send 2 100B messages in a single request' do |
| 252 | + subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 100 }) }) |
| 253 | + expect(subject).to have_received(:send_event).exactly(1).times do |s| |
| 254 | + expect(s.bytesize).to be <= max_payload_size |
| 255 | + end |
| 256 | + end |
| 257 | + |
| 258 | + it 'should drop messages larger than max_payload_size' do |
| 259 | + subject.multi_receive([ |
| 260 | + LogStash::Event.new({ 'event' => '🤣' * 400 }), |
| 261 | + LogStash::Event.new({ 'event' => 'n' * 600 }), |
| 262 | + LogStash::Event.new({ 'event' => 'n' * 400 }), |
| 263 | + ]) |
| 264 | + expect(subject).to have_received(:send_event).exactly(1).times do |s| |
| 265 | + expect(s.bytesize).to be <= max_payload_size |
| 266 | + end |
246 | 267 | end |
247 | 268 | end |
248 | 269 |
|
|
0 commit comments