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(parsers): add support for missing logs #3582

Merged
merged 1 commit into from Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion insights/parsers/greenboot_status.py
Expand Up @@ -11,7 +11,8 @@
_green = "Boot Status is GREEN"
_red = "Boot Status is RED"
_fallback = "FALLBACK BOOT DETECTED"
add_filter(Specs.greenboot_status, [_green, _red, _fallback])
_nologs = "WARNING: No greenboot logs were found!"
add_filter(Specs.greenboot_status, [_green, _red, _fallback, _nologs])


@parser(Specs.greenboot_status)
Expand All @@ -33,3 +34,4 @@ class GreenbootStatus(LogFileOutput):
GreenbootStatus.token_scan("green", _green)
GreenbootStatus.token_scan("red", _red)
GreenbootStatus.token_scan("fallback", _fallback)
GreenbootStatus.token_scan("nologs", _nologs)
12 changes: 12 additions & 0 deletions insights/tests/parsers/test_greenboot_status.py
Expand Up @@ -61,6 +61,10 @@
Feb 22 22:50:26 example systemd[1]: Started greenboot MotD Generator.
"""

NOLOGS = """
WARNING: No greenboot logs were found!
"""


def test_greenboot_status_green():
green = context_wrap(GREEN)
Expand All @@ -81,3 +85,11 @@ def test_greenboot_status_fallback():
p = GreenbootStatus(fb)
assert p.green
assert p.fallback


def test_greenboot_status_nolog():
fb = context_wrap(NOLOGS)
p = GreenbootStatus(fb)
assert p.nologs
assert not p.green
assert not p.red