spec/inputs/udp_spec.rb in logstash-input-udp-3.4.1 vs spec/inputs/udp_spec.rb in logstash-input-udp-3.5.0
- old
+ new
@@ -70,33 +70,36 @@
let(:client) { LogStash::Inputs::Test::UDPClient.new(port, "::1") }
include_examples "receiving"
end
end
- shared_examples "use hostname field with ECS" do |ecs_compatibility, field_name|
- let(:config) { { "port" => port, "workers" => 1, "ecs_compatibility" => ecs_compatibility} }
- let(:localhost) { "127.0.0.1" }
- let(:client) { LogStash::Inputs::Test::UDPClient.new(port, localhost) }
+ shared_examples "respects ECS compatibility setting host metadata" do |ecs_compatibility, field_name|
+ context "when ecs_compatibility is `#{ecs_compatibility}`" do
+ let(:config) { { "port" => port, "workers" => 1, "ecs_compatibility" => ecs_compatibility} }
+ let(:localhost) { "127.0.0.1" }
+ let(:client) { LogStash::Inputs::Test::UDPClient.new(port, localhost) }
- let(:events) do
- helper.input(subject, 1) do
- client.send("line1")
+ let(:events) do
+ helper.input(subject, 1) do
+ client.send("line1")
+ end
end
- end
- before(:each) do
- subject.register
- end
+ before(:each) do
+ subject.register
+ end
- it "should receive event with source_ip_fieldname as '#{field_name}' when ecs #{ecs_compatibility}" do
- expect(events.size).to be(1)
- message = events.last
- expect(message.get(field_name)).to eq(client.host)
+ it "produces event with source_ip_fieldname as '#{field_name}'" do
+ expect(events.size).to be(1)
+ message = events.last
+ expect(message.get(field_name)).to eq(client.host)
+ end
end
end
- it_behaves_like "use hostname field with ECS", :disabled, "host"
- it_behaves_like "use hostname field with ECS", :v1, "[host][ip]"
+ it_behaves_like "respects ECS compatibility setting host metadata", :disabled, "host"
+ it_behaves_like "respects ECS compatibility setting host metadata", :v1, "[host][ip]"
+ it_behaves_like "respects ECS compatibility setting host metadata", :v8, "[host][ip]"
describe "uses custom hostname field when ECS is enabled" do
let(:config) { { "port" => port, "workers" => 1, "ecs_compatibility" => :v1, "source_ip_fieldname" => "custom_host_field"} }