Skip to content
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
4 changes: 2 additions & 2 deletions salt/client/ssh/wrapper/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"""
from __future__ import absolute_import, print_function

import logging

# Import python libs
import logging
import os
import time

Expand Down Expand Up @@ -877,6 +876,7 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs):

salt '*' state.sls_id my_state my_module,a_common_module
"""
__pillar__.update(kwargs.get("pillar", {}))
st_kwargs = __salt__.kwargs
conflict = _check_queue(queue, kwargs)
if conflict is not None:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/files/file/base/ssh_state_tests.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% set jinja = 'test' %}
{% set file_name = 'salt_test_file' + pillar.get('test_file_suffix', '') %}
ssh-file-test:
file.managed:
- name: /tmp/{{ jinja }}
- name: /tmp/{{ file_name }}
- contents: 'test'

second_id:
Expand Down
31 changes: 25 additions & 6 deletions tests/integration/ssh/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals

import glob
import logging
import os
import shutil
Expand All @@ -20,7 +21,7 @@
from tests.support.unit import skipIf

SSH_SLS = "ssh_state_tests"
SSH_SLS_FILE = "/tmp/test"
SSH_SLS_FILE = "/tmp/salt_test_file"

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -58,7 +59,7 @@ def test_state_apply(self):
ret = self.run_function("state.apply", [SSH_SLS])
self._check_dict_ret(ret=ret, val="__sls__", exp_ret=SSH_SLS)

check_file = self.run_function("file.file_exists", ["/tmp/test"])
check_file = self.run_function("file.file_exists", [SSH_SLS_FILE])
self.assertTrue(check_file)

@skipIf(True, "SLOWTEST skip")
Expand All @@ -71,7 +72,11 @@ def test_state_sls_id(self):
self._check_dict_ret(
ret=ret,
val="comment",
exp_ret="The file /tmp/test is set to be changed\nNote: No changes made, actual changes may\nbe different due to other states.",
exp_ret=(
"The file {} is set to be changed\n"
"Note: No changes made, actual changes may\n"
"be different due to other states."
).format(SSH_SLS_FILE),
)

# check state.sls_id without test=True
Expand All @@ -81,7 +86,7 @@ def test_state_sls_id(self):
# make sure the other id in the state was not run
self._check_dict_ret(ret=ret, val="__id__", exp_ret="second_id", equal=False)

check_file = self.run_function("file.file_exists", ["/tmp/test"])
check_file = self.run_function("file.file_exists", [SSH_SLS_FILE])
self.assertTrue(check_file)

@skipIf(True, "SLOWTEST skip")
Expand All @@ -93,6 +98,20 @@ def test_state_sls_wrong_id(self):
ret = self.run_function("state.sls_id", ["doesnotexist", SSH_SLS])
assert "No matches for ID" in ret

@skipIf(True, "SLOWTEST skip")
def test_state_sls_id_with_pillar(self):
"""
test state.sls_id with pillar data
"""
self.run_function(
"state.sls_id",
["ssh-file-test", SSH_SLS, 'pillar=\'{"test_file_suffix": "_pillar"}\''],
)
check_file = self.run_function(
"file.file_exists", ["/tmp/salt_test_file_pillar"]
)
self.assertTrue(check_file)

@skipIf(True, "SLOWTEST skip")
def test_state_show_sls(self):
"""
Expand Down Expand Up @@ -263,5 +282,5 @@ def tearDown(self):
if os.path.exists(salt_dir):
shutil.rmtree(salt_dir)

if os.path.exists(SSH_SLS_FILE):
os.remove(SSH_SLS_FILE)
for test_file_path in glob.glob(SSH_SLS_FILE + "*"):
os.remove(test_file_path)