spec/inputs/pipe_spec.rb in logstash-input-pipe-3.0.7 vs spec/inputs/pipe_spec.rb in logstash-input-pipe-3.1.0
- old
+ new
@@ -1,7 +1,9 @@
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
+require "logstash/devutils/rspec/shared_examples"
+require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
require "logstash/inputs/pipe"
require "tempfile"
describe LogStash::Inputs::Pipe, :unix => true do
@@ -22,29 +24,51 @@
let(:config) { { "command" => "echo foo" } }
end
end
- describe "pipe from echo" do
+ describe "pipe from echo", :ecs_compatibility_support do
- let(:config) do <<-CONFIG
- input {
- pipe {
- command => "echo ☹"
+ ecs_compatibility_matrix(:disabled, :v1, :v8) do |ecs_select|
+
+ let(:config) do <<-CONFIG
+ input {
+ pipe {
+ command => "echo ☹"
+ ecs_compatibility => "#{ecs_compatibility}"
+ }
}
- }
- CONFIG
- end
+ CONFIG
+ end
- let(:event) do
- input(config) do |pipeline, queue|
- queue.pop
+ let(:event) do
+ input(config) do |pipeline, queue|
+ queue.pop
+ end
end
- end
- it "should receive the pipe" do
- expect(event.get("message")).to eq("☹")
+ it "should receive the pipe" do
+ expect(event.get("message")).to eq("☹")
+ end
+
+ it "sets host field" do
+ if ecs_select.active_mode == :disabled
+ expect(event.get("host")).to be_a String
+ else
+ expect(event.get("[host][name]")).to be_a String
+ end
+ end
+
+ it "sets the command executed" do
+ if ecs_select.active_mode == :disabled
+ expect(event.get("command")).to eql "echo ☹"
+ else
+ expect(event.include?("command")).to be false
+ expect(event.get("[process][command_line]")).to eql "echo ☹"
+ end
+ end
+
end
end
describe "pipe from tail" do
@@ -72,11 +96,10 @@
event_count.times.map { queue.pop }
end
end
it "should receive all piped elements" do
- event_count.times do |i|
- expect(events[i].get("message")).to eq("#{i} ☹")
- end
+ messages = event_count.times.map { |i| events[i].get("message") }
+ expect( messages.sort ).to eql event_count.times.map { |i| "#{i} ☹" }
end
end
end