pytest-testinfra
pytest-testinfra copied to clipboard
SysV Init service module fails on SLES11
Writing tests against SLES11 which uses SysV Init I found two issues with the service module:
is_enabled fails because the service files are in a different directory (/etc/init.d/rc?.d/ instead of /etc/rc?.d/)
Instead of using the module I just used:
is_enabled = bool(host.check_output(
'find -L /etc/init.d/rc?.d/ -name S??{0}'.format(
service_name
),
))
Also is_running fails if not run as root. Fixed in a similar route:
is_running = host.run_expect(
[0, 1, 3],
'sudo /sbin/service {0} status'.format(service_name)
).rc == 0
Not sure the best option to account for these differences in testinfra.