-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50059 from garethgreenaway/allow_multiple_engine_…
…instances [develop] Initial work to allow running multiple instances of a Salt engine
- Loading branch information
Showing
4 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
unit tests for the Salt engines | ||
''' | ||
# Import Python libs | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
# Import Salt Testing Libs | ||
from tests.support.mixins import LoaderModuleMockMixin | ||
from tests.support.unit import skipIf, TestCase | ||
from tests.support.mock import ( | ||
NO_MOCK, | ||
NO_MOCK_REASON, | ||
patch) | ||
|
||
# Import Salt Libs | ||
import salt.engines as engines | ||
import salt.config | ||
import salt.utils.process | ||
|
||
# Import 3rd-party libs | ||
from salt.ext import six | ||
|
||
import logging | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
@skipIf(NO_MOCK, NO_MOCK_REASON) | ||
class EngineTestCase(TestCase, LoaderModuleMockMixin): | ||
''' | ||
Test cases for salt.engine.sqs_events | ||
''' | ||
|
||
def setup_loader_modules(self): | ||
return {engines: {}} | ||
|
||
def test_engine_module(self): | ||
''' | ||
Test | ||
''' | ||
mock_opts = salt.config.DEFAULT_MINION_OPTS | ||
mock_opts['__role'] = 'minion' | ||
mock_opts['engines'] = [{'test_one': {'engine_module': 'test'}}, | ||
{'test_two': {'engine_module': 'test'}}] | ||
|
||
process_manager = salt.utils.process.ProcessManager() | ||
with patch.dict(engines.__opts__, mock_opts): | ||
salt.engines.start_engines(mock_opts, process_manager) | ||
process_map = process_manager._process_map | ||
count = 0 | ||
for proc in six.iterkeys(process_map): | ||
count += 1 | ||
fun = process_map[proc]['Process'].fun | ||
|
||
# Ensure function is start from the test engine | ||
self.assertEqual(fun, 'test.start') | ||
|
||
# Ensure there were two engine started | ||
self.assertEqual(count, len(mock_opts['engines'])) |