Merge pull request #56221 from max-arnold/parallel-slots

Make slots work with parallel=true
This commit is contained in:
Daniel Wozniak 2020-04-14 10:48:59 -07:00 committed by GitHub
commit 353d20ed90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -1906,6 +1906,7 @@ class State(object):
# correctly calculate further down the chain
utc_start_time = datetime.datetime.utcnow()
self.format_slots(cdata)
tag = _gen_tag(low)
try:
ret = self.states[cdata["full"]](*cdata["args"], **cdata["kwargs"])

View file

@ -618,3 +618,31 @@ class StateFormatSlotsTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
self.state_obj.format_slots(cdata)
mock.assert_called_once_with("fun_arg", fun_key="fun_val")
self.assertEqual(cdata, {"args": ["arg"], "kwargs": {"key": "value1thing~"}})
# Skip on windows like integration.modules.test_state.StateModuleTest.test_parallel_state_with_long_tag
@skipIf(
salt.utils.platform.is_windows(),
"Skipped until parallel states can be fixed on Windows",
)
def test_format_slots_parallel(self):
"""
Test if slots work with "parallel: true".
"""
high_data = {
"always-changes-and-succeeds": {
"test": [
{"changes": True},
{"comment": "__slot__:salt:test.echo(fun_return)"},
{"parallel": True},
"configurable_test_state",
{"order": 10000},
],
"__env__": "base",
"__sls__": "parallel_slots",
}
}
self.state_obj.jid = "123"
res = self.state_obj.call_high(high_data)
self.state_obj.jid = None
[(_, data)] = res.items()
self.assertEqual(data["comment"], "fun_return")