Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make slots work with parallel=true #56221

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")