mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
[master] Ensure proxy_config reads proxy specific configuration (#58307)
* Make proxy_config read in the proxy specific configuration which is typically found in /etc/salt/proxy.d/minionid/. * Adding changelog. * Fixed auto py3 update hook result * Only lay down the required config for tests using it * Running pre-commit bits manually. Co-authored-by: Dmitry Kuzmenko <dmitry.kuzmenko@dsr-corporation.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me>
This commit is contained in:
parent
2237cf2c60
commit
ba4ae77d33
2 changed files with 38 additions and 5 deletions
1
changelog/58307.fixed
Normal file
1
changelog/58307.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
Make proxy_config read in the proxy specific configuration which is typically found in /etc/salt/proxy.d/minionid/.
|
|
@ -2,9 +2,11 @@
|
|||
:codeauthor: Gareth J. Greenaway <gareth@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import textwrap
|
||||
|
||||
import salt.config
|
||||
import salt.ext.tornado
|
||||
|
@ -13,21 +15,50 @@ import salt.metaproxy.proxy
|
|||
import salt.minion
|
||||
import salt.syspaths
|
||||
from tests.support.helpers import slowTest
|
||||
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__opts__ = {}
|
||||
|
||||
|
||||
class ProxyMinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
||||
class ProxyMinionTestCase(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.proxy_conf_d = os.path.join(RUNTIME_VARS.TMP_PROXY_CONF_DIR, "proxy.d")
|
||||
proxytest_conf_d = os.path.join(cls.proxy_conf_d, "proxytest")
|
||||
if not os.path.exists(proxytest_conf_d):
|
||||
os.makedirs(proxytest_conf_d)
|
||||
with salt.utils.files.fopen(
|
||||
os.path.join(proxytest_conf_d, "_schedule.conf"), "w"
|
||||
) as wfh:
|
||||
wfh.write(
|
||||
textwrap.dedent(
|
||||
"""\
|
||||
schedule:
|
||||
test_job:
|
||||
args: [arg1, arg2]
|
||||
enabled: true
|
||||
function: test.arg
|
||||
jid_include: true
|
||||
kwargs: {key1: value1, key2: value2}
|
||||
maxrunning: 1
|
||||
name: test_job
|
||||
return_job: false
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
shutil.rmtree(cls.proxy_conf_d)
|
||||
|
||||
@slowTest
|
||||
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.copy()
|
||||
mock_opts.update(salt.config.DEFAULT_PROXY_MINION_OPTS)
|
||||
mock_jid_queue = [123]
|
||||
|
@ -110,7 +141,8 @@ class ProxyMinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
for the proxy minion, eg. /etc/salt/proxy.d/dummy/*.conf
|
||||
"""
|
||||
opts = salt.config.proxy_config(
|
||||
RUNTIME_VARS.TMP_PROXY_CONF_DIR + "/proxy", minion_id="proxytest"
|
||||
os.path.join(RUNTIME_VARS.TMP_PROXY_CONF_DIR, "proxy"),
|
||||
minion_id="proxytest",
|
||||
)
|
||||
self.assertIn("schedule", opts)
|
||||
self.assertIn("test_job", opts["schedule"])
|
||||
|
|
Loading…
Add table
Reference in a new issue