Skip to content

Commit

Permalink
Merge pull request saltstack#56221 from max-arnold/parallel-slots
Browse files Browse the repository at this point in the history
Make slots work with parallel=true
  • Loading branch information
dwoz authored Apr 14, 2020
2 parents c1e0640 + 55658bd commit 353d20e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions salt/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ def _call_parallel_target(self, name, cdata, low):
# 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"])
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,31 @@ def test_slot_append(self):
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")

0 comments on commit 353d20e

Please sign in to comment.