|
76 | 76 | end |
77 | 77 | end |
78 | 78 |
|
| 79 | + describe "building an event action tuple" do |
| 80 | + context "for 7.x elasticsearch clusters" do |
| 81 | + let(:maximum_seen_major_version) { 7 } |
| 82 | + it "should include '_type'" do |
| 83 | + action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo")) |
| 84 | + action_params = action_tuple[1] |
| 85 | + expect(action_params).to include(:_type => "_doc") |
| 86 | + end |
| 87 | + |
| 88 | + context "with 'document type set'" do |
| 89 | + let(:options) { super.merge("document_type" => "bar")} |
| 90 | + it "should get the event type from the 'document_type' setting" do |
| 91 | + action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo")) |
| 92 | + action_params = action_tuple[1] |
| 93 | + expect(action_params).to include(:_type => "bar") |
| 94 | + end |
| 95 | + end |
| 96 | + end |
| 97 | + |
| 98 | + context "for 8.x elasticsearch clusters" do |
| 99 | + let(:maximum_seen_major_version) { 8 } |
| 100 | + it "should not include '_type'" do |
| 101 | + action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo")) |
| 102 | + action_params = action_tuple[1] |
| 103 | + expect(action_params).not_to include(:_type) |
| 104 | + end |
| 105 | + |
| 106 | + context "with 'document type set'" do |
| 107 | + let(:options) { super.merge("document_type" => "bar")} |
| 108 | + it "should not include '_type'" do |
| 109 | + action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo")) |
| 110 | + action_params = action_tuple[1] |
| 111 | + expect(action_params).not_to include(:_type) |
| 112 | + end |
| 113 | + end |
| 114 | + end |
| 115 | + end |
| 116 | + |
79 | 117 | describe "with auth" do |
80 | 118 | let(:user) { "myuser" } |
81 | 119 | let(:password) { ::LogStash::Util::Password.new("mypassword") } |
|
0 commit comments