mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
3c298afa72
Conflicts: - salt/modules/pip.py - salt/modules/reg.py - salt/modules/win_pkg.py - salt/runners/manage.py - salt/states/pkg.py - salt/transport/zeromq.py - salt/utils/event.py - tests/integration/modules/test_pip.py - tests/integration/states/test_user.py - tests/unit/grains/test_core.py - tests/unit/states/test_archive.py - tests/unit/utils/test_boto.py
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# Import Python libs
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
# Import Salt Testing libs
|
|
from tests.support.case import ModuleCase
|
|
from tests.support.helpers import destructiveTest
|
|
|
|
# Import Salt libs
|
|
import salt.utils.path
|
|
|
|
|
|
@destructiveTest
|
|
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 = 'sshd'
|
|
cmd_name = 'systemctl'
|
|
elif os_family == 'MacOS':
|
|
self.service_name = 'org.ntp.ntpd'
|
|
|
|
if salt.utils.path.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
|
|
'''
|
|
self.run_function('service.start', [self.service_name])
|
|
check_service = self.run_function('service.status', [self.service_name])
|
|
self.assertTrue(check_service)
|
|
|
|
def test_service_status_dead(self):
|
|
'''
|
|
test service.status execution module
|
|
when service is dead
|
|
'''
|
|
self.run_function('service.stop', [self.service_name])
|
|
check_service = self.run_function('service.status', [self.service_name])
|
|
self.assertFalse(check_service)
|