Closed
Description
The command being run by SystemdService.exists
:
pytest-testinfra/testinfra/modules/service.py
Line 179 in 54f3b5c
does not run successfully as it appears to be malformed. When attempting to use it in a molecule test configuration the following error is seen:
E AssertionError: Unexpected exit code 2 for CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f792dec0a70>, exit_status=2, command=b'systemctl list-unit-files | grep -q"^systemd-binfmt"', _stdout=b'', _stderr=b"grep: invalid option -- '^'\nUsage: grep [OPTION]... PATTERNS [FILE]...\nTry 'grep --help' for more information.\n")
E assert 2 in [0, 1]
E + where 2 = CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f792dec0a70>, exit_status=2, command=b'syst...=b"grep: invalid option -- '^'\nUsage: grep [OPTION]... PATTERNS [FILE]...\nTry 'grep --help' for more information.\n").rc
I verified that I receive the same error if I login to a running test container:
root@debian12-systemd:/# systemctl list-unit-files | grep -q"^systemd-binfmt"
grep: invalid option -- '^'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
root@debian12-systemd:/# systemctl list-unit-files | grep -q "^systemd-binfmt"
root@debian12-systemd:/# echo $?
0
It appears that #754 fixes this issue in addition to adding testing as verified by both the tests in that PR and my own double-check in the same molecule container:
root@debian12-systemd:/# systemctl list-units --all | grep -q "^[[:space:]]*systemd-binfmt"
root@debian12-systemd:/# echo $?
0
Metadata
Metadata
Assignees
Labels
No labels