mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Make legacy and modern syntax detection work for module.wait
PR#61772 added the ability to detect modern or legacy syntax for module.run to allow both styles to co-exist. Those changes did not fully address module.wait semantics which led to all module.wait syntaxes to be treated as legacy. Using modern syntax led to state failure in such cases. This commit adds additional keys that may be generated when module.wait is used to the list of kwargs ignored by detection algorithm. It also adds functional tests for module.wait test cases. Fixes #62988
This commit is contained in:
parent
0f6b9efbea
commit
29812c3dcd
3 changed files with 65 additions and 3 deletions
1
changelog/62988.fixed
Normal file
1
changelog/62988.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
Fixed bug where module.wait states were detected as running legacy module.run syntax
|
|
@ -376,8 +376,10 @@ def run(**kwargs):
|
|||
legacy_run = False
|
||||
|
||||
keys = list(kwargs)
|
||||
if "name" in keys:
|
||||
keys.remove("name")
|
||||
ignored_kwargs = ["name", "__reqs__", "sfun"]
|
||||
for item in ignored_kwargs:
|
||||
if item in keys:
|
||||
keys.remove(item)
|
||||
|
||||
# The rest of the keys should be function names for new-style syntax
|
||||
for name in keys:
|
||||
|
|
|
@ -82,7 +82,66 @@ def test_issue_58763_b(tmp_path, modules, state_tree, caplog):
|
|||
mods="issue-58763",
|
||||
)
|
||||
assert len(ret.raw) == 1
|
||||
print(ret)
|
||||
for k in ret.raw:
|
||||
assert ret.raw[k]["result"] is True
|
||||
assert "Detected legacy module.run syntax: test.ping" in caplog.messages
|
||||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
def test_issue_62988_a(tmp_path, modules, state_tree, caplog):
|
||||
|
||||
venv_dir = tmp_path / "issue-2028-pip-installed"
|
||||
|
||||
sls_contents = dedent(
|
||||
"""
|
||||
test_foo:
|
||||
test.succeed_with_changes
|
||||
|
||||
run_new:
|
||||
module.wait:
|
||||
- test.random_hash:
|
||||
- size: 10
|
||||
- hash_type: md5
|
||||
- watch:
|
||||
- test: test_foo
|
||||
"""
|
||||
)
|
||||
with pytest.helpers.temp_file("issue-62988.sls", sls_contents, state_tree):
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
ret = modules.state.sls(
|
||||
mods="issue-62988",
|
||||
)
|
||||
assert len(ret.raw) == 2
|
||||
for k in ret.raw:
|
||||
assert ret.raw[k]["result"] is True
|
||||
assert "Using new style module.run syntax: run_new" in caplog.messages
|
||||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
def test_issue_62988_b(tmp_path, modules, state_tree, caplog):
|
||||
|
||||
venv_dir = tmp_path / "issue-2028-pip-installed"
|
||||
|
||||
sls_contents = dedent(
|
||||
"""
|
||||
test_foo:
|
||||
test.succeed_with_changes:
|
||||
- watch_in:
|
||||
- module: run_new
|
||||
|
||||
run_new:
|
||||
module.wait:
|
||||
- test.random_hash:
|
||||
- size: 10
|
||||
- hash_type: md5
|
||||
"""
|
||||
)
|
||||
with pytest.helpers.temp_file("issue-62988.sls", sls_contents, state_tree):
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
ret = modules.state.sls(
|
||||
mods="issue-62988",
|
||||
)
|
||||
assert len(ret.raw) == 2
|
||||
for k in ret.raw:
|
||||
assert ret.raw[k]["result"] is True
|
||||
assert "Using new style module.run syntax: run_new" in caplog.messages
|
||||
|
|
Loading…
Add table
Reference in a new issue