From 144a6008bd7875e85a39f8f764d602c6e003570d Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 6 Sep 2019 21:27:00 +0000 Subject: [PATCH] Re-gen executors with proper arguments --- salt/minion.py | 2 +- tests/unit/test_minion.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/salt/minion.py b/salt/minion.py index 4a3e0711a3..d1c0c00751 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -456,7 +456,7 @@ class MinionBase(object): # self.matcher = Matcher(self.opts, self.functions) self.matchers = salt.loader.matchers(self.opts) self.functions['sys.reload_modules'] = self.gen_modules - self.executors = salt.loader.executors(self.opts) + self.executors = salt.loader.executors(self.opts, self.functions) @staticmethod def process_schedule(minion, loop_interval): diff --git a/tests/unit/test_minion.py b/tests/unit/test_minion.py index c4cfff9b0b..23d2ddb7a7 100644 --- a/tests/unit/test_minion.py +++ b/tests/unit/test_minion.py @@ -293,6 +293,27 @@ class MinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin): self.assertRaises(SaltMasterUnresolvableError, salt.minion.resolve_dns, __opts__) + def test_gen_modules_executors(self): + ''' + Ensure gen_modules is called with the correct arguments #54429 + ''' + mock_opts = self.get_config('minion', from_scratch=True) + mock_opts['master_uri'] = 'master' #, 'tcp://master:9090' + io_loop = tornado.ioloop.IOLoop() + io_loop.make_current() + minion = salt.minion.Minion(mock_opts, io_loop=io_loop) + class MockPillarCompiler(): + def compile_pillar(self): + return {} + try: + with patch('salt.pillar.get_pillar', return_value=MockPillarCompiler()): + with patch('salt.loader.executors') as execmock: + minion.gen_modules() + assert execmock.called_with(minion.opts, minion.functions) + finally: + minion.destroy() + + @skipIf(NO_MOCK, NO_MOCK_REASON) class MinionAsyncTestCase(TestCase, AdaptedConfigurationTestCaseMixin, tornado.testing.AsyncTestCase):