change service name depending on os

This commit is contained in:
Ch3LL 2017-10-26 11:44:38 -04:00
parent 980c43ebc9
commit c13f37eee4
No known key found for this signature in database
GPG Key ID: 132B55A7C13EFA73

View File

@ -11,8 +11,6 @@ from tests.support.helpers import destructiveTest
# Import Salt libs
import salt.utils
SERVICE_NAME = 'docker'
@destructiveTest
@skipIf(salt.utils.which('docker') is None, 'docker is not installed')
@ -20,14 +18,27 @@ class ServiceModuleTest(ModuleCase):
'''
Module testing the service module
'''
def setUp(self):
self.service_name = 'cron'
cmd_name = 'crontab'
os_family = self.run_function('grains.get', ['os_family'])
if os_family == 'RedHat':
self.service_name = 'crond'
elif os_family == 'Arch':
self.service_name = 'systemd-journald'
cmd_name = 'systemctl'
if salt.utils.which(cmd_name) is None:
self.skipTest('{0} is not installed'.format(cmd_name))
def test_service_status_running(self):
'''
test service.status execution module
when service is running
'''
start_service = self.run_function('service.start', [SERVICE_NAME])
start_service = self.run_function('service.start', [self.service_name])
check_service = self.run_function('service.status', [SERVICE_NAME])
check_service = self.run_function('service.status', [self.service_name])
self.assertTrue(check_service)
def test_service_status_dead(self):
@ -35,7 +46,7 @@ class ServiceModuleTest(ModuleCase):
test service.status execution module
when service is dead
'''
stop_service = self.run_function('service.stop', [SERVICE_NAME])
stop_service = self.run_function('service.stop', [self.service_name])
check_service = self.run_function('service.status', [SERVICE_NAME])
check_service = self.run_function('service.status', [self.service_name])
self.assertFalse(check_service)