From 2fa7710f77fda3a21c81e76f356ff1cb7e8228dc Mon Sep 17 00:00:00 2001 From: Mashhur Date: Wed, 30 Aug 2023 21:00:01 -0700 Subject: [PATCH 1/3] Fix ECS v1/v8 test failure cases. --- spec/inputs/stdin_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/inputs/stdin_spec.rb b/spec/inputs/stdin_spec.rb index 69b7434..010315e 100644 --- a/spec/inputs/stdin_spec.rb +++ b/spec/inputs/stdin_spec.rb @@ -49,12 +49,13 @@ let(:queue) { Queue.new } let(:stdin_data) { "a foo bar\n" } + let(:origin_data) { "a foo bar" } after { subject.close } it "sets message" do event = queue.pop - expect( event.get('message') ).to eql 'a foo bar' + expect( event.get('message') ).to eql origin_data end it "sets hostname" do @@ -64,7 +65,7 @@ it "sets event.original" do event = queue.pop - expect( event.get('event') ).to eql 'original' => stdin_data + expect( event.get('event') ).to eql 'original' => origin_data end end From d2ee956deaabd29c251480dbdf9f9b8678183401 Mon Sep 17 00:00:00 2001 From: Mashhur Date: Thu, 31 Aug 2023 09:47:01 -0700 Subject: [PATCH 2/3] Change codec to Json in test cases to avoid the new line issue. --- spec/inputs/stdin_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/inputs/stdin_spec.rb b/spec/inputs/stdin_spec.rb index 010315e..0561fff 100644 --- a/spec/inputs/stdin_spec.rb +++ b/spec/inputs/stdin_spec.rb @@ -4,6 +4,7 @@ require "logstash/inputs/stdin" describe LogStash::Inputs::Stdin do + context ".reloadable?" do subject { described_class } @@ -31,8 +32,8 @@ end context 'ECS behavior', :ecs_compatibility_support do - - subject { LogStash::Inputs::Stdin.new } + require "logstash/codecs/json" + subject { LogStash::Inputs::Stdin.new("codec" => LogStash::Codecs::JSON.new) } ecs_compatibility_matrix(:v1, :v8 => :v1) do @@ -49,13 +50,12 @@ let(:queue) { Queue.new } let(:stdin_data) { "a foo bar\n" } - let(:origin_data) { "a foo bar" } after { subject.close } it "sets message" do event = queue.pop - expect( event.get('message') ).to eql origin_data + expect( event.get('message') ).to eql 'a foo bar' end it "sets hostname" do @@ -65,7 +65,7 @@ it "sets event.original" do event = queue.pop - expect( event.get('event') ).to eql 'original' => origin_data + expect( event.get('event') ).to eql 'original' => stdin_data end end From 8cda8c83337dc950a8e04a9d70c28e072ae60947 Mon Sep 17 00:00:00 2001 From: Mashhur Date: Tue, 5 Sep 2023 11:02:03 -0700 Subject: [PATCH 3/3] Considering String#strip solution rather than changing the codec. --- spec/inputs/stdin_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/inputs/stdin_spec.rb b/spec/inputs/stdin_spec.rb index 0561fff..c08a142 100644 --- a/spec/inputs/stdin_spec.rb +++ b/spec/inputs/stdin_spec.rb @@ -32,8 +32,7 @@ end context 'ECS behavior', :ecs_compatibility_support do - require "logstash/codecs/json" - subject { LogStash::Inputs::Stdin.new("codec" => LogStash::Codecs::JSON.new) } + subject { LogStash::Inputs::Stdin.new() } ecs_compatibility_matrix(:v1, :v8 => :v1) do @@ -65,7 +64,7 @@ it "sets event.original" do event = queue.pop - expect( event.get('event') ).to eql 'original' => stdin_data + expect( event.get('[event][original]').strip ).to eql stdin_data.strip end end