Skip to content

Commit

Permalink
Merge pull request #54433 from dwoz/sudo_minion
Browse files Browse the repository at this point in the history
Re-gen executors with proper arguments
  • Loading branch information
dwoz authored Sep 9, 2019
2 parents 76fac57 + e08eb19 commit 62fc61c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion salt/minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def gen_modules(self, initial_load=False):
# 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):
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/test_minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,27 @@ def test_minion_retry_dns_count(self):
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)
io_loop = tornado.ioloop.IOLoop()
io_loop.make_current()
minion = salt.minion.Minion(mock_opts, io_loop=io_loop)

class MockPillarCompiler(object):
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):
Expand Down

0 comments on commit 62fc61c

Please sign in to comment.