mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2019.2.1' into yaml_flow_style
This commit is contained in:
commit
5f6581a228
7 changed files with 70 additions and 33 deletions
|
@ -828,13 +828,17 @@ def setup_extended_logging(opts):
|
|||
|
||||
def get_multiprocessing_logging_queue():
|
||||
global __MP_LOGGING_QUEUE
|
||||
from salt.utils.platform import is_darwin
|
||||
|
||||
if __MP_IN_MAINPROCESS is False:
|
||||
# We're not in the MainProcess, return! No Queue shall be instantiated
|
||||
return __MP_LOGGING_QUEUE
|
||||
|
||||
if __MP_LOGGING_QUEUE is None:
|
||||
__MP_LOGGING_QUEUE = multiprocessing.Queue()
|
||||
if is_darwin():
|
||||
__MP_LOGGING_QUEUE = multiprocessing.Queue(32767)
|
||||
else:
|
||||
__MP_LOGGING_QUEUE = multiprocessing.Queue(100000)
|
||||
return __MP_LOGGING_QUEUE
|
||||
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='',
|
|||
log.error(tops_failure_msg, 'parsing', python3_bin)
|
||||
log.exception(err)
|
||||
else:
|
||||
log.error(tops_failure_msg, 'collecting', python3_bin)
|
||||
log.debug(tops_failure_msg, 'collecting', python3_bin)
|
||||
log.debug(stderr)
|
||||
|
||||
# Collect tops, alternative to 3.x version
|
||||
|
@ -448,7 +448,7 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='',
|
|||
log.error(tops_failure_msg, 'parsing', python2_bin)
|
||||
log.exception(err)
|
||||
else:
|
||||
log.error(tops_failure_msg, 'collecting', python2_bin)
|
||||
log.debug(tops_failure_msg, 'collecting', python2_bin)
|
||||
log.debug(stderr)
|
||||
|
||||
with salt.utils.files.fopen(pymap_cfg, 'wb') as fp_:
|
||||
|
|
|
@ -172,5 +172,5 @@ def get_python_executable():
|
|||
python_binary = None
|
||||
except AttributeError:
|
||||
# We're not running inside a virtualenv
|
||||
python_binary = None
|
||||
python_binary = sys.executable
|
||||
return python_binary
|
||||
|
|
|
@ -24,6 +24,7 @@ import msgpack
|
|||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
from salt.utils.platform import is_darwin
|
||||
import salt.log.setup
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -60,7 +61,10 @@ def setup_handlers():
|
|||
# Above that value, if `process_queue` can't process fast enough,
|
||||
# start dropping. This will contain a memory leak in case `process_queue`
|
||||
# can't process fast enough of in case it can't deliver the log records at all.
|
||||
queue_size = 10000000
|
||||
if is_darwin():
|
||||
queue_size = 32767
|
||||
else:
|
||||
queue_size = 10000000
|
||||
queue = Queue(queue_size)
|
||||
handler = salt.log.setup.QueueHandler(queue)
|
||||
level = salt.log.setup.LOG_LEVELS[(__opts__.get('runtests_log_level') or 'error').lower()]
|
||||
|
|
|
@ -38,7 +38,7 @@ _PKG_TARGETS = {
|
|||
'Debian': ['python-plist', 'apg'],
|
||||
'RedHat': ['units', 'zsh-html'],
|
||||
'FreeBSD': ['aalib', 'pth'],
|
||||
'Suse': ['aalib', 'rpm-python'],
|
||||
'Suse': ['aalib', 'htop'],
|
||||
'MacOS': ['libpng', 'jpeg'],
|
||||
'Windows': ['putty', '7zip'],
|
||||
}
|
||||
|
|
|
@ -195,7 +195,6 @@ TEST_SUITES = collections.OrderedDict(sorted(TEST_SUITES_UNORDERED.items(),
|
|||
class SaltTestsuiteParser(SaltCoverageTestingParser):
|
||||
support_docker_execution = True
|
||||
support_destructive_tests_selection = True
|
||||
support_expensive_tests_selection = True
|
||||
source_code_basedir = SALT_ROOT
|
||||
|
||||
def _get_suites(self, include_unit=False, include_cloud_provider=False,
|
||||
|
|
|
@ -8,11 +8,13 @@ Tests for the Telegram execution module.
|
|||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import (
|
||||
patch,
|
||||
Mock,
|
||||
MagicMock,
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON
|
||||
|
@ -22,6 +24,47 @@ from tests.support.mock import (
|
|||
import salt.modules.telegram as telegram
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RequestMock(Mock):
|
||||
'''
|
||||
Request Mock
|
||||
'''
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
return RequestResponseMock()
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
return RequestPutResponseMock()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
return RequestResponseMock()
|
||||
|
||||
|
||||
class RequestResponseMock(Mock):
|
||||
'''
|
||||
Request Response Mock
|
||||
'''
|
||||
def json(self):
|
||||
return [{'url': 'http://example.org',
|
||||
'_id': 1234}, ]
|
||||
|
||||
|
||||
class RequestPutResponseMock(Mock):
|
||||
'''
|
||||
Request Put Response Mock
|
||||
'''
|
||||
ok = True
|
||||
|
||||
def json(self):
|
||||
return {'_id': 4321}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class TelegramModuleTest(TestCase, LoaderModuleMockMixin):
|
||||
'''
|
||||
|
@ -29,35 +72,22 @@ class TelegramModuleTest(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
def setup_loader_modules(self):
|
||||
module_globals = {
|
||||
telegram: {
|
||||
'__salt__': {
|
||||
'config.get': MagicMock(return_value={
|
||||
'telegram': {
|
||||
'chat_id': '123456789',
|
||||
'token': '000000000:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
'__salt__': {
|
||||
'config.get': MagicMock(return_value={
|
||||
'telegram': {
|
||||
'chat_id': '123456789',
|
||||
'token': '000000000:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||
}
|
||||
}),
|
||||
'requests.put': Mock(),
|
||||
},
|
||||
'requests': RequestMock()
|
||||
}
|
||||
if telegram.HAS_REQUESTS is False:
|
||||
module_globals['sys.modules'] = {'requests': MagicMock()}
|
||||
return module_globals
|
||||
return {telegram: module_globals}
|
||||
|
||||
def test_post_message(self):
|
||||
'''
|
||||
Test the post_message function.
|
||||
'''
|
||||
message = 'Hello World!'
|
||||
|
||||
class MockRequests(object):
|
||||
"""
|
||||
Mock of requests response.
|
||||
"""
|
||||
def json(self):
|
||||
return {'ok': True}
|
||||
|
||||
with patch('salt.modules.telegram.requests.post',
|
||||
MagicMock(return_value=MockRequests())):
|
||||
|
||||
self.assertTrue(telegram.post_message(message))
|
||||
self.assertTrue(telegram.post_message(message))
|
||||
|
|
Loading…
Add table
Reference in a new issue