|
1499 | 1499 | end
|
1500 | 1500 | end
|
1501 | 1501 |
|
| 1502 | + describe 'drop_error_types' do |
| 1503 | + |
| 1504 | + let(:error_type) { 'index_closed_exception' } |
| 1505 | + |
| 1506 | + let(:options) { super().merge('drop_error_types' => [error_type]) } |
| 1507 | + |
| 1508 | + let(:events) { [ LogStash::Event.new("foo" => "bar") ] } |
| 1509 | + |
| 1510 | + let(:dlq_writer) { subject.instance_variable_get(:@dlq_writer) } |
| 1511 | + |
| 1512 | + let(:error_code) { 403 } |
| 1513 | + |
| 1514 | + let(:event_action_tuples) { subject.map_events(events) } |
| 1515 | + |
| 1516 | + let(:bulk_response) do |
| 1517 | + { |
| 1518 | + "took"=>1, "ingest_took"=>11, "errors"=>true, "items"=> |
| 1519 | + [{ |
| 1520 | + "index"=>{"_index"=>"bar", "_type"=>"_doc", "_id"=>'bar', "status" => error_code, |
| 1521 | + "error"=>{"type" => error_type, "reason" => "TEST" } |
| 1522 | + } |
| 1523 | + }] |
| 1524 | + } |
| 1525 | + end |
| 1526 | + |
| 1527 | + before(:each) do |
| 1528 | + allow(subject.client).to receive(:bulk_send).and_return(bulk_response) |
| 1529 | + end |
| 1530 | + |
| 1531 | + context 'DLQ is enabled' do |
| 1532 | + |
| 1533 | + let(:options) { super().merge("dlq_custom_codes" => [403]) } |
| 1534 | + |
| 1535 | + it 'does not write the event to the DLQ' do |
| 1536 | + expect(dlq_writer).not_to receive(:write) |
| 1537 | + subject.send(:submit, event_action_tuples) |
| 1538 | + end |
| 1539 | + end |
| 1540 | + |
| 1541 | + context 'DLQ is not enabled' do |
| 1542 | + |
| 1543 | + before(:each) do |
| 1544 | + allow(subject).to receive(:dlq_enabled?).and_return(false) |
| 1545 | + end |
| 1546 | + |
| 1547 | + it 'does not retry indexing the event' do |
| 1548 | + expect(subject).to receive(:submit).with(event_action_tuples).once.and_call_original |
| 1549 | + subject.send(:retrying_submit, event_action_tuples) |
| 1550 | + end |
| 1551 | + end |
| 1552 | + |
| 1553 | + context 'the error type is not in `silence_errors_in_log`' do |
| 1554 | + |
| 1555 | + it 'logs the error' do |
| 1556 | + expect(subject.logger).to receive(:warn).with(a_string_including("Failed action"), anything) |
| 1557 | + subject.send(:submit, event_action_tuples) |
| 1558 | + end |
| 1559 | + end |
| 1560 | + |
| 1561 | + context 'the error type is in `silence_errors_in_log`' do |
| 1562 | + |
| 1563 | + let(:options) { super().merge('silence_errors_in_log' => [error_type]) } |
| 1564 | + |
| 1565 | + before(:each) do |
| 1566 | + # ensure that neither warn nor info is called on the logger by using a test double |
| 1567 | + subject.instance_variable_set("@logger", double('logger')) |
| 1568 | + end |
| 1569 | + |
| 1570 | + it 'does not log the error' do |
| 1571 | + subject.send(:submit, event_action_tuples) |
| 1572 | + end |
| 1573 | + end |
| 1574 | + end |
| 1575 | + |
1502 | 1576 | describe "custom headers" do
|
1503 | 1577 | let(:manticore_options) { subject.client.pool.adapter.manticore.instance_variable_get(:@options) }
|
1504 | 1578 |
|
|
0 commit comments