-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Eliminate panic due to nil pointer dereference in Journalbeat #20095
Conversation
Pinging @elastic/integrations-services (Team:Services) |
libbeat/tests/system/beat/beat.py
Outdated
with open(os.path.join(self.working_dir, output_file, ), "r", encoding="utf_8") as f: | ||
return len([1 for line in f]) == 0 | ||
except IOError: | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use self.output_has(lines=0)
?
The output_has
should check for None
when testing if lines
is set, so we can correctly use 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output_has
returns False
if the output does not exist. I added the extra function to avoid getting an exception in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes me wonder if output_has
should really raise an exception. From the test code POV we only want to know what has been 'published' (or if something has been published). The fact that the file does not exist or is empty is just a detail the test code should not care about.
17653ef
to
5affccf
Compare
c1ecbe7
to
caabcda
Compare
(cherry picked from commit 54b1e64)
(cherry picked from commit 54b1e64)
Fixing the testing of Journalbeat will be done in a follow-up PR. |
What does this PR do?
Why is it important?
The current 7.9 snapshot panics with the default configuration.
Checklist
- [] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues
Closes #20089