mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Adding tests to ensure _metaproxy_call to called when ProxyMinion objects are created.
This commit is contained in:
parent
d162a88629
commit
4af95e49a1
2 changed files with 76 additions and 0 deletions
|
@ -3308,6 +3308,7 @@ class ProxyMinionManager(MinionManager):
|
|||
|
||||
|
||||
def _metaproxy_call(opts, fn_name):
|
||||
log.debug('=== here ====')
|
||||
metaproxy = salt.loader.metaproxy(opts)
|
||||
try:
|
||||
metaproxy_name = opts['metaproxy']
|
||||
|
|
75
tests/unit/test_proxy_minion.py
Normal file
75
tests/unit/test_proxy_minion.py
Normal file
|
@ -0,0 +1,75 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: Gareth J. Greenaway <gareth@saltstack.com>
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import copy
|
||||
|
||||
import logging
|
||||
import tornado
|
||||
import tornado.testing
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import NO_MOCK, NO_MOCK_REASON
|
||||
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
|
||||
|
||||
# Import salt libs
|
||||
import salt.minion
|
||||
import salt.syspaths
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__opts__ = {}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class ProxyMinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
||||
def test_post_master_init_metaproxy_called(self):
|
||||
'''
|
||||
Tests that when the _post_master_ini function is called, _metaproxy_call is also called.
|
||||
'''
|
||||
mock_opts = salt.config.DEFAULT_MINION_OPTS
|
||||
mock_jid_queue = [123]
|
||||
proxy_minion = salt.minion.ProxyMinion(mock_opts, jid_queue=copy.copy(mock_jid_queue), io_loop=tornado.ioloop.IOLoop())
|
||||
try:
|
||||
ret = proxy_minion._post_master_init('dummy_master')
|
||||
self.assert_called_once(salt.minion._metaproxy_call)
|
||||
finally:
|
||||
proxy_minion.destroy()
|
||||
|
||||
def test_handle_decoded_payload_metaproxy_called(self):
|
||||
'''
|
||||
Tests that when the _handle_decoded_payload function is called, _metaproxy_call is also called.
|
||||
'''
|
||||
mock_opts = salt.config.DEFAULT_MINION_OPTS
|
||||
mock_data = {'fun': 'foo.bar',
|
||||
'jid': 123}
|
||||
mock_jid_queue = [123]
|
||||
proxy_minion = salt.minion.ProxyMinion(mock_opts, jid_queue=copy.copy(mock_jid_queue), io_loop=tornado.ioloop.IOLoop())
|
||||
try:
|
||||
ret = proxy_minion._handle_decoded_payload(mock_data).result()
|
||||
self.assertEqual(proxy_minion.jid_queue, mock_jid_queue)
|
||||
self.assertIsNone(ret)
|
||||
self.assert_called_once(salt.minion._metaproxy_call)
|
||||
finally:
|
||||
proxy_minion.destroy()
|
||||
|
||||
def test_handle_payload_metaproxy_called(self):
|
||||
'''
|
||||
Tests that when the _handle_payload function is called, _metaproxy_call is also called.
|
||||
'''
|
||||
mock_opts = salt.config.DEFAULT_MINION_OPTS
|
||||
mock_data = {'fun': 'foo.bar',
|
||||
'jid': 123}
|
||||
mock_jid_queue = [123]
|
||||
proxy_minion = salt.minion.ProxyMinion(mock_opts, jid_queue=copy.copy(mock_jid_queue), io_loop=tornado.ioloop.IOLoop())
|
||||
try:
|
||||
ret = proxy_minion._handle_decoded_payload(mock_data).result()
|
||||
self.assertEqual(proxy_minion.jid_queue, mock_jid_queue)
|
||||
self.assertIsNone(ret)
|
||||
self.assert_called_once(salt.minion._metaproxy_call)
|
||||
finally:
|
||||
proxy_minion.destroy()
|
Loading…
Add table
Reference in a new issue