mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Test that excluded sls files can't extend others
This commit is contained in:
parent
3cb5f5a14f
commit
e91c1a608b
1 changed files with 150 additions and 0 deletions
|
@ -3,10 +3,12 @@
|
|||
"""
|
||||
|
||||
import logging
|
||||
import textwrap
|
||||
|
||||
import pytest # pylint: disable=unused-import
|
||||
|
||||
import salt.state
|
||||
from salt.utils.odict import OrderedDict
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -197,3 +199,151 @@ def test_find_sls_ids_with_exclude(highstate, state_tree_dir):
|
|||
high, _ = highstate.render_highstate(matches)
|
||||
ret = salt.state.find_sls_ids("issue-47182.stateA.newer", high)
|
||||
assert ret == [("somestuff", "cmd")]
|
||||
|
||||
|
||||
def test_dont_extend_in_excluded_sls_file(highstate, state_tree_dir):
|
||||
"""
|
||||
See https://github.com/saltstack/salt/issues/62082#issuecomment-1245461333
|
||||
"""
|
||||
top_sls = textwrap.dedent(
|
||||
"""\
|
||||
base:
|
||||
'*':
|
||||
- test1
|
||||
- exclude
|
||||
"""
|
||||
)
|
||||
exclude_sls = textwrap.dedent(
|
||||
"""\
|
||||
exclude:
|
||||
- sls: test2
|
||||
"""
|
||||
)
|
||||
test1_sls = textwrap.dedent(
|
||||
"""\
|
||||
include:
|
||||
- test2
|
||||
|
||||
test1:
|
||||
cmd.run:
|
||||
- name: echo test1
|
||||
"""
|
||||
)
|
||||
test2_sls = textwrap.dedent(
|
||||
"""\
|
||||
extend:
|
||||
test1:
|
||||
cmd.run:
|
||||
- name: echo "override test1 in test2"
|
||||
|
||||
test2-id:
|
||||
cmd.run:
|
||||
- name: echo test2
|
||||
"""
|
||||
)
|
||||
sls_dir = str(state_tree_dir)
|
||||
with pytest.helpers.temp_file(
|
||||
"top.sls", top_sls, sls_dir
|
||||
), pytest.helpers.temp_file(
|
||||
"test1.sls", test1_sls, sls_dir
|
||||
), pytest.helpers.temp_file(
|
||||
"test2.sls", test2_sls, sls_dir
|
||||
), pytest.helpers.temp_file(
|
||||
"exclude.sls", exclude_sls, sls_dir
|
||||
):
|
||||
# manually compile the high data, error checking is not needed in this
|
||||
# test case.
|
||||
top = highstate.get_top()
|
||||
matches = highstate.top_matches(top)
|
||||
high, _ = highstate.render_highstate(matches)
|
||||
|
||||
# high is mutated by call_high and the different "pipeline steps"
|
||||
assert high == OrderedDict(
|
||||
[
|
||||
(
|
||||
"__extend__",
|
||||
[
|
||||
{
|
||||
"test1": OrderedDict(
|
||||
[
|
||||
("__sls__", "test2"),
|
||||
("__env__", "base"),
|
||||
(
|
||||
"cmd",
|
||||
[
|
||||
OrderedDict(
|
||||
[
|
||||
(
|
||||
"name",
|
||||
'echo "override test1 in test2"',
|
||||
)
|
||||
]
|
||||
),
|
||||
"run",
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
}
|
||||
],
|
||||
),
|
||||
(
|
||||
"test1",
|
||||
OrderedDict(
|
||||
[
|
||||
(
|
||||
"cmd",
|
||||
[
|
||||
OrderedDict([("name", "echo test1")]),
|
||||
"run",
|
||||
{"order": 10001},
|
||||
],
|
||||
),
|
||||
("__sls__", "test1"),
|
||||
("__env__", "base"),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"test2-id",
|
||||
OrderedDict(
|
||||
[
|
||||
(
|
||||
"cmd",
|
||||
[
|
||||
OrderedDict([("name", "echo test2")]),
|
||||
"run",
|
||||
{"order": 10000},
|
||||
],
|
||||
),
|
||||
("__sls__", "test2"),
|
||||
("__env__", "base"),
|
||||
]
|
||||
),
|
||||
),
|
||||
("__exclude__", [OrderedDict([("sls", "test2")])]),
|
||||
]
|
||||
)
|
||||
highstate.state.call_high(high)
|
||||
# assert that the extend declaration was not applied
|
||||
assert high == OrderedDict(
|
||||
[
|
||||
(
|
||||
"test1",
|
||||
OrderedDict(
|
||||
[
|
||||
(
|
||||
"cmd",
|
||||
[
|
||||
OrderedDict([("name", "echo test1")]),
|
||||
"run",
|
||||
{"order": 10001},
|
||||
],
|
||||
),
|
||||
("__sls__", "test1"),
|
||||
("__env__", "base"),
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue