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

Testsuite failure while building the Debian package #37

Open
baldurmen opened this issue May 3, 2024 · 2 comments
Open

Testsuite failure while building the Debian package #37

baldurmen opened this issue May 3, 2024 · 2 comments

Comments

@baldurmen
Copy link

Sorry to bother you with such a specific problem, but while trying to update the Debian package to the latest version, I've been getting testsuite failures. This happens with both 4.0.0 and 4.1.0.

Maybe you will have an idea of why? Note I cannot reproduce this issue in a virtualenv.

The problem seems to be that stdout isn't really captured. I get a bunch of these failures:

| count_units=386 units_activating=0 units_active=275 units_failed=0 units_inactive=111
_______________________ TestVersion246.test_version_246 ________________________

self = <tests.test_version246.TestVersion246 object at 0x7ffb61c2b990>

    def test_version_246(self) -> None:
        result = execute_main(
            argv=["--no-performance-data"],
            stdout=[
                "systemctl-list-units_v246.txt",
                "systemd-analyze_12.345.txt",
            ],
        )
        result.assert_critical()
>       result.assert_first_line("SYSTEMD CRITICAL - nm-wait-online.service: failed")

tests/test_version246.py:14: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.helper.MockResult object at 0x7ffb61a69390>
first_line = 'SYSTEMD CRITICAL - nm-wait-online.service: failed'

    def assert_first_line(self, first_line: str) -> None:
>       assert self.first_line == first_line
E       AssertionError

tests/helper.py:171: AssertionError
----------------------------- Captured stdout call -----------------------------
SYSTEMD CRITICAL - nm-wait-online.service: failed

I added some code to debug further and did indeed get self.first_line = None and first_line = SYSTEMD CRITICAL - nm-wait-online.service: failed

Here's the full log:

monitoring-plugins-systemd_4.1.0-1_amd64-2024-05-03T21:00:09Z.txt

@Josef-Friedrich
Copy link
Owner

Unfortunately, I'm not sure what the problem could be

The contextlib is used to capture stdout and stderr

from contextlib import redirect_stderr, redirect_stdout

file_stdout: io.StringIO = io.StringIO()
file_stderr: io.StringIO = io.StringIO()
with redirect_stdout(file_stdout), redirect_stderr(file_stderr):
check_systemd.main() # type: ignore

@Josef-Friedrich
Copy link
Owner

On Github Actions there is no problem https://github.com/Josef-Friedrich/check_systemd/actions/runs/8951918649

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

No branches or pull requests

2 participants