|
590 | 590 |
|
591 | 591 | let(:event) { LogStash::Event.new("pipeline" => "my-ingest-pipeline") }
|
592 | 592 |
|
593 |
| - it "should interpolate the pipeline value and set it" do |
| 593 | + it "interpolate the pipeline value and set it" do |
594 | 594 | expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "my-ingest-pipeline")
|
595 | 595 | end
|
596 | 596 | end
|
|
600 | 600 |
|
601 | 601 | let(:event) { LogStash::Event.new("pipeline" => "") }
|
602 | 602 |
|
603 |
| - it "should interpolate the pipeline value but not set it because it is empty" do |
| 603 | + it "interpolates the pipeline value but not set it because it is empty" do |
| 604 | + expect(subject.send(:event_action_tuple, event)[1]).not_to include(:pipeline) |
| 605 | + end |
| 606 | + end |
| 607 | + |
| 608 | + context "with both pipeline and target_ingest_pipeline" do |
| 609 | + let(:options) { {"pipeline" => "%{pipeline}" } } |
| 610 | + let(:event) { LogStash::Event.new({"pipeline" => "my-ingest-pipeline", "[@metadata][target_ingest_pipeline]" => "meta-ingest-pipeline"}) } |
| 611 | + |
| 612 | + it "interpolates the plugin's pipeline value" do |
| 613 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "my-ingest-pipeline") |
| 614 | + end |
| 615 | + |
| 616 | + context "when the plugin's `pipeline` is constant" do |
| 617 | + let(:options) { super().merge("pipeline" => "my-constant-pipeline") } |
| 618 | + it "uses plugin's pipeline value" do |
| 619 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "my-constant-pipeline") |
| 620 | + end |
| 621 | + end |
| 622 | + |
| 623 | + context "when the plugin's `pipeline` includes an unresolvable sprintf placeholder" do |
| 624 | + let(:options) { super().merge("pipeline" => "reference-%{unset}-field") } |
| 625 | + it "does not use the target_ingest_pipeline" do |
| 626 | + # when sprintf doesn't resolve a placeholder, the behaviour of our `pipeline` is UNSPECIFIED. |
| 627 | + # here we only validate that the presence of the magic field does not |
| 628 | + # override an explicitly-configured pipeline. |
| 629 | + expect(subject.send(:event_action_tuple, event)[1]).to_not include(:pipeline => "my-ingest-pipeline") |
| 630 | + end |
| 631 | + end |
| 632 | + end |
| 633 | + |
| 634 | + context "with empty pipeline and target_ingest_pipeline" do |
| 635 | + let(:options) { {"pipeline" => "%{pipeline}" } } |
| 636 | + let(:event) { LogStash::Event.new({"pipeline" => "", "[@metadata][target_ingest_pipeline]" => "meta-ingest-pipeline"}) } |
| 637 | + |
| 638 | + it "interpolates the pipeline value but not set it because pipeline is empty" do |
| 639 | + expect(subject.send(:event_action_tuple, event)[1]).not_to include(:pipeline) |
| 640 | + end |
| 641 | + end |
| 642 | + |
| 643 | + context "with target_ingest_pipeline" do |
| 644 | + let(:event) { LogStash::Event.new({"pipeline" => "", "@metadata" => {"target_ingest_pipeline" => "meta-ingest-pipeline"}}) } |
| 645 | + |
| 646 | + it "interpolates the target_ingest_pipeline value and set it" do |
| 647 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:pipeline => "meta-ingest-pipeline") |
| 648 | + end |
| 649 | + end |
| 650 | + |
| 651 | + context "with empty target_ingest_pipeline" do |
| 652 | + let(:event) { LogStash::Event.new({"pipeline" => "", "@metadata" => {"host" => "elastic"}}) } |
| 653 | + |
| 654 | + it "does not set pipeline" do |
| 655 | + expect(subject.send(:event_action_tuple, event)[1]).not_to include(:pipeline) |
| 656 | + end |
| 657 | + end |
| 658 | + |
| 659 | + context "with empty pipeline and empty target_ingest_pipeline" do |
| 660 | + let(:event) { LogStash::Event.new } |
| 661 | + |
| 662 | + it "does not set pipeline" do |
604 | 663 | expect(subject.send(:event_action_tuple, event)[1]).not_to include(:pipeline)
|
605 | 664 | end
|
606 | 665 | end
|
|
0 commit comments