salt/tests/unit/minion_test.py

57 lines
1.7 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
'''
2014-05-22 00:59:02 +00:00
:codeauthor: :email:`Mike Place <mp@saltstack.com>`
'''
2014-05-22 16:59:26 +00:00
# Import python libs
import os
# Import Salt Testing libs
from salttesting import TestCase, skipIf
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch
2014-05-22 16:59:26 +00:00
# Import salt libs
from salt import minion
from salt.exceptions import SaltSystemExit
2014-05-22 16:59:26 +00:00
import salt.syspaths
ensure_in_syspath('../')
__opts__ = {}
@skipIf(NO_MOCK, NO_MOCK_REASON)
class MinionTestCase(TestCase):
def test_invalid_master_address(self):
with patch.dict(__opts__, {'ipv6': False, 'master': float('127.0'), 'master_port': '4555', 'retry_dns': False}):
2013-12-26 18:51:30 +00:00
self.assertRaises(SaltSystemExit, minion.resolve_dns, __opts__)
2014-03-31 02:03:40 +00:00
2014-05-22 17:02:44 +00:00
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
2014-05-22 16:59:26 +00:00
def test_sock_path_len(self):
'''
This tests whether or not a larger hash causes the sock path to exceed
the system's max sock path length. See the below link for more
information.
https://github.com/saltstack/salt/issues/12172#issuecomment-43903643
'''
opts = {
'id': 'salt-testing',
'hash_type': 'sha512',
'sock_dir': os.path.join(salt.syspaths.SOCK_DIR, 'minion')
}
with patch.dict(__opts__, opts):
testminion = minion.MinionBase(__opts__)
try:
testminion._prepare_minion_event_system()
result = True
except SaltSystemExit:
result = False
self.assertTrue(result)
2014-03-31 02:03:40 +00:00
if __name__ == '__main__':
from integration import run_tests
run_tests(MinionTestCase, needs_daemon=False)