Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ECS test failure cases. #23

Merged
merged 3 commits into from
Sep 5, 2023

Conversation

mashhurs
Copy link
Contributor

@mashhurs mashhurs commented Aug 31, 2023

Description

This change fixes the test case failure, example failure.

Details: the root cause for test failure is, we ca calling directly process() method of the plugin. For the real scenarios, StdinChannel::Reader.new or standard $stdin escapes the new line. So, in the test cases, changed plugin default Line codec to JSON codec to avoid the new line (\n).


subject { LogStash::Inputs::Stdin.new }
require "logstash/codecs/json"
subject { LogStash::Inputs::Stdin.new("codec" => LogStash::Codecs::JSON.new) }
Copy link
Contributor Author

@mashhurs mashhurs Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review note why codec change needs: the root cause for test failure is, we ca calling directly process() method of the plugin which \n always stay. For the real scenarios, StdinChannel::Reader.new or standard $stdin escapes the new line. So, in the test cases, changed plugin default Line (since its delimiter \n and removes when ECS enabled) codec to JSON codec to avoid the new line (\n).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing the codecs, maybe we can add strip to the validation

expect( event.get('event') ).to eql 'original' => stdin_data.strip

just like the "sets hostname" test case

@mashhurs mashhurs marked this pull request as ready for review August 31, 2023 17:03
@kaisecheng kaisecheng self-requested a review September 5, 2023 17:25
Copy link

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mashhurs Thanks for improving the test cases. I have one suggestion to make the test case aligned with the others.


subject { LogStash::Inputs::Stdin.new }
require "logstash/codecs/json"
subject { LogStash::Inputs::Stdin.new("codec" => LogStash::Codecs::JSON.new) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing the codecs, maybe we can add strip to the validation

expect( event.get('event') ).to eql 'original' => stdin_data.strip

just like the "sets hostname" test case

@mashhurs
Copy link
Contributor Author

mashhurs commented Sep 5, 2023

@mashhurs Thanks for improving the test cases. I have one suggestion to make the test case aligned with the others.

@kaisecheng if we align on default Line codec, the solution would be

expect( event.get('[event][original]').strip ).to eql stdin_data.strip

and I have applied it.

Details: we receive the data with \n (new line) in 7.x with ECS disabled because we are directly calling process(), so need to apply the strip on both received event and expected data.

Copy link

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mashhurs mashhurs merged commit 3641d62 into logstash-plugins:main Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Test Failure] ECS compatibility enabled tests are failing on Logstash 8.x
3 participants