-
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.
fixes #61478 state_aggregate minion option not respected
- Loading branch information
1 parent
eb8bd12
commit c9a6217
Showing
3 changed files
with
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix state_aggregate minion option not respected |
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,68 @@ | ||
import itertools | ||
|
||
import pytest | ||
import salt.config | ||
import salt.state | ||
|
||
|
||
@pytest.fixture | ||
def master_opts(): | ||
""" | ||
Return a subset of master options to the minion | ||
""" | ||
opts = salt.config.DEFAULT_MASTER_OPTS.copy() | ||
mopts = {} | ||
mopts["file_roots"] = opts["file_roots"] | ||
mopts["top_file_merging_strategy"] = opts["top_file_merging_strategy"] | ||
mopts["env_order"] = opts["env_order"] | ||
mopts["default_top"] = opts["default_top"] | ||
mopts["renderer"] = opts["renderer"] | ||
mopts["failhard"] = opts["failhard"] | ||
mopts["state_top"] = opts["state_top"] | ||
mopts["state_top_saltenv"] = opts["state_top_saltenv"] | ||
mopts["nodegroups"] = opts["nodegroups"] | ||
mopts["state_auto_order"] = opts["state_auto_order"] | ||
mopts["state_events"] = opts["state_events"] | ||
mopts["state_aggregate"] = opts["state_aggregate"] | ||
mopts["jinja_env"] = opts["jinja_env"] | ||
mopts["jinja_sls_env"] = opts["jinja_sls_env"] | ||
mopts["jinja_lstrip_blocks"] = opts["jinja_lstrip_blocks"] | ||
mopts["jinja_trim_blocks"] = opts["jinja_trim_blocks"] | ||
return mopts | ||
|
||
|
||
class MockBaseHighStateClient: | ||
def __init__(self, opts): | ||
self.opts = opts | ||
|
||
def master_opts(self): | ||
return self.opts | ||
|
||
|
||
def test_state_aggregate_option_behavior(master_opts): | ||
""" | ||
Ensure state_aggregate can be overridden on the minion | ||
""" | ||
minion_opts = salt.config.DEFAULT_MINION_OPTS.copy() | ||
possible = [None, True, False, ["pkg"]] | ||
expected_result = [ | ||
True, | ||
False, | ||
["pkg"], | ||
True, | ||
True, | ||
["pkg"], | ||
False, | ||
True, | ||
["pkg"], | ||
["pkg"], | ||
True, | ||
["pkg"], | ||
] | ||
|
||
for idx, combo in enumerate(itertools.permutations(possible, 2)): | ||
master_opts["state_aggregate"], minion_opts["state_aggregate"] = combo | ||
state_obj = salt.state.BaseHighState | ||
state_obj.client = MockBaseHighStateClient(master_opts) | ||
return_result = state_obj(minion_opts)._BaseHighState__gen_opts(minion_opts) | ||
assert expected_result[idx] == return_result["state_aggregate"] |