forked from logstash-plugins/logstash-output-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_whitelist_spec.rb
56 lines (45 loc) · 1.92 KB
/
error_whitelist_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require "logstash/outputs/elasticsearch"
require_relative "../../../spec/es_spec_helper"
describe "whitelisting error types in expected behavior" do
let(:template) { '{"template" : "not important, will be updated by :index"}' }
let(:event1) { LogStash::Event.new("somevalue" => 100, "@timestamp" => "2014-11-17T20:37:17.223Z") }
let(:action1) { ["index", {:_id=>1, :routing=>nil, :_index=>"logstash-2014.11.17", :_type=> doc_type }, event1] }
let(:settings) { {"manage_template" => true, "index" => "logstash-2014.11.17", "template_overwrite" => true, "hosts" => get_host_port() } }
subject { LogStash::Outputs::ElasticSearch.new(settings) }
before :each do
allow(subject.logger).to receive(:warn)
allow(subject).to receive(:maximum_seen_major_version).and_return(0)
allow(subject).to receive(:alive_urls_count).and_return(1)
allow(subject).to receive(:finish_register)
subject.register
allow(subject.client).to receive(:get_xpack_info)
allow(subject.client).to receive(:bulk).and_return(
{
"errors" => true,
"items" => [{
"create" => {
"status" => 409,
"error" => {
"type" => "version_conflict_engine_exception",
"reason" => "[shard] document already exists"
}
}
}]
})
subject.multi_receive([event1])
end
after :each do
subject.close
end
describe "when failure logging is enabled for everything" do
it "should log a failure on the action" do
expect(subject.logger).to have_received(:warn).with("Failed action", anything)
end
end
describe "when failure logging is disabled for document exists error" do
let(:settings) { super().merge("silence_errors_in_log" => ["version_conflict_engine_exception"]) }
it "should log a failure on the action" do
expect(subject.logger).not_to have_received(:warn).with("Failed action", anything)
end
end
end