Skip to content

Commit 30865ae

Browse files
committed
Added all cases for metadata's ingest pipeline
1 parent 04ceb87 commit 30865ae

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

spec/unit/outputs/elasticsearch_spec.rb

+37
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,43 @@
377377
end
378378
end
379379

380+
context "when plugin's pipeline is specified" do
381+
let(:options) { {"pipeline" => "pipeline_from_settings" } }
382+
383+
context "when the event contains an integration metadata pipeline" do
384+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"pipeline" => "integration-pipeline"}}}) }
385+
386+
it "plugin's pipeline is used" do
387+
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "pipeline_from_settings")
388+
end
389+
end
390+
391+
context "when the event DOESN'T contains an integration metadata pipeline" do
392+
it "plugin's pipeline is used" do
393+
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "pipeline_from_settings")
394+
end
395+
end
396+
end
397+
398+
context "when plugin's pipeline is NOT specified" do
399+
let(:options) { super().merge("pipeline" => nil)}
400+
401+
context "when the event contains an integration metadata pipeline" do
402+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"pipeline" => "integration-pipeline"}}}) }
403+
404+
it "event's metadata pipeline is used" do
405+
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "integration-pipeline")
406+
end
407+
end
408+
409+
context "when the event DOESN'T contains an integration metadata pipeline" do
410+
it "plugin's default pipeline mechanism is used" do
411+
expect(subject.send(:event_action_tuple, event)[1]).to_not have_key(:pipeline)
412+
end
413+
end
414+
end
415+
end
416+
380417
describe "with auth" do
381418
let(:user) { "myuser" }
382419
let(:password) { ::LogStash::Util::Password.new("mypassword") }

0 commit comments

Comments
 (0)