Skip to content

Commit f63ba99

Browse files
committed
Moved test about target_ingest_pipeline and ingest_document into the proper context
1 parent 30865ae commit f63ba99

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

Diff for: spec/unit/outputs/elasticsearch_spec.rb

+14-23
Original file line numberDiff line numberDiff line change
@@ -299,20 +299,20 @@
299299
context "when the event contains an integration metadata index" do
300300
let(:event_fields) { super().merge({"@metadata" => {"_ingest_document" => {"index" => "meta-document-index"}}}) }
301301

302-
it "plugin's configuration metadata index is used" do
302+
it "event's metadata index is used" do
303303
expect(subject.send(:event_action_tuple, event)[1]).to include(:_index => "meta-document-index")
304304
end
305305

306306
context "when datastream settings are NOT configured" do
307-
it "plugin's configuration metadata index is used" do
307+
it "event's metadata index is used" do
308308
expect(subject.send(:event_action_tuple, event)[1]).to include(:_index => "meta-document-index")
309309
end
310310
end
311311

312312
context "when datastream settings are configured" do
313313
let(:event_fields) { super().merge({"data_stream" => {"type" => "logs", "dataset" => "generic", "namespace" => "default"}}) }
314314

315-
it "plugin's configuration metadata index is used" do
315+
it "event's metadata index is used" do
316316
expect(subject.send(:event_action_tuple, event)[1]).to include(:_index => "meta-document-index")
317317
end
318318
end
@@ -365,7 +365,7 @@
365365
context "when the event contains an integration metadata document_id" do
366366
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"id" => "meta-document-id"}}}) }
367367

368-
it "plugin's configuration metadata document_id is used" do
368+
it "event's metadata document_id is used" do
369369
expect(subject.send(:event_action_tuple, event)[1]).to include(:_id => "meta-document-id")
370370
end
371371
end
@@ -399,11 +399,20 @@
399399
let(:options) { super().merge("pipeline" => nil)}
400400

401401
context "when the event contains an integration metadata pipeline" do
402-
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"pipeline" => "integration-pipeline"}}}) }
402+
let(:metadata) { {"_ingest_document" => {"pipeline" => "integration-pipeline"}} }
403+
let(:event) { LogStash::Event.new({"@metadata" => metadata}) }
403404

404405
it "event's metadata pipeline is used" do
405406
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "integration-pipeline")
406407
end
408+
409+
context "when also target_ingest_pipeline id defined" do
410+
let(:metadata) { super().merge({"target_ingest_pipeline" => "meta-ingest-pipeline"}) }
411+
412+
it "then event's pipeline from _ingest_document is used" do
413+
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "integration-pipeline")
414+
end
415+
end
407416
end
408417

409418
context "when the event DOESN'T contains an integration metadata pipeline" do
@@ -894,24 +903,6 @@
894903
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "my-ingest-pipeline")
895904
end
896905

897-
context "when event contains also _ingest_document pipeline name" do
898-
let(:event) { LogStash::Event.new({"pipeline" => "my-ingest-pipeline",
899-
"@metadata" => {"target_ingest_pipeline" => "meta-ingest-pipeline",
900-
"_ingest_document" => {"pipeline" => "integration-pipeline"}}}) }
901-
902-
it "precedence is given to the integration" do
903-
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "my-ingest-pipeline")
904-
end
905-
906-
context "when settings doesn't configure a pipeline and integration provides one in the event" do
907-
let(:options) { { } }
908-
909-
it "the one provided by user takes precedence on all the others" do
910-
expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "integration-pipeline")
911-
end
912-
end
913-
end
914-
915906
context "when the plugin's `pipeline` is constant" do
916907
let(:options) { super().merge("pipeline" => "my-constant-pipeline") }
917908
it "uses plugin's pipeline value" do

0 commit comments

Comments
 (0)