mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #46696 from dwoz/win_test_client
Windows `unit.test_client` fixes
This commit is contained in:
commit
14ab50d3f4
@ -13,7 +13,10 @@ from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON
|
||||
|
||||
# Import Salt libs
|
||||
from salt import client
|
||||
from salt.exceptions import EauthAuthenticationError, SaltInvocationError, SaltClientError
|
||||
import salt.utils
|
||||
from salt.exceptions import (
|
||||
EauthAuthenticationError, SaltInvocationError, SaltClientError, SaltReqTimeoutError
|
||||
)
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
@ -67,7 +70,13 @@ class LocalClientTestCase(TestCase,
|
||||
kwarg=None, tgt_type='list',
|
||||
ret='')
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'Not supported on Windows')
|
||||
def test_pub(self):
|
||||
'''
|
||||
Tests that the client cleanly returns when the publisher is not running
|
||||
|
||||
Note: Requires ZeroMQ's IPC transport which is not supported on windows.
|
||||
'''
|
||||
if self.get_config('minion')['transport'] != 'zeromq':
|
||||
self.skipTest('This test only works with ZeroMQ')
|
||||
# Make sure we cleanly return if the publisher isn't running
|
||||
@ -83,3 +92,27 @@ class LocalClientTestCase(TestCase,
|
||||
self.assertRaises(SaltInvocationError,
|
||||
self.client.pub,
|
||||
'non_existent_group', 'test.ping', tgt_type='nodegroup')
|
||||
|
||||
@skipIf(not salt.utils.is_windows(), 'Windows only test')
|
||||
def test_pub_win32(self):
|
||||
'''
|
||||
Tests that the client raises a timeout error when using ZeroMQ's TCP
|
||||
transport and publisher is not running.
|
||||
|
||||
Note: Requires ZeroMQ's TCP transport, this is only the default on Windows.
|
||||
'''
|
||||
if self.get_config('minion')['transport'] != 'zeromq':
|
||||
self.skipTest('This test only works with ZeroMQ')
|
||||
# Make sure we cleanly return if the publisher isn't running
|
||||
with patch('os.path.exists', return_value=False):
|
||||
self.assertRaises(SaltReqTimeoutError, lambda: self.client.pub('*', 'test.ping'))
|
||||
|
||||
# Check nodegroups behavior
|
||||
with patch('os.path.exists', return_value=True):
|
||||
with patch.dict(self.client.opts,
|
||||
{'nodegroups':
|
||||
{'group1': 'L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com'}}):
|
||||
# Do we raise an exception if the nodegroup can't be matched?
|
||||
self.assertRaises(SaltInvocationError,
|
||||
self.client.pub,
|
||||
'non_existent_group', 'test.ping', tgt_type='nodegroup')
|
||||
|
Loading…
Reference in New Issue
Block a user