diff --git a/salt/client/ssh/ssh_py_shim.py b/salt/client/ssh/ssh_py_shim.py index e13d72d039..64161f8a4a 100644 --- a/salt/client/ssh/ssh_py_shim.py +++ b/salt/client/ssh/ssh_py_shim.py @@ -157,7 +157,10 @@ def unpack_thin(thin_path): tfile.extractall(path=OPTIONS.saltdir) tfile.close() os.umask(old_umask) - os.unlink(thin_path) + try: + os.unlink(thin_path) + except OSError: + pass def need_ext(): diff --git a/salt/utils/thin.py b/salt/utils/thin.py index 95f14dd9d1..71a66a903b 100644 --- a/salt/utils/thin.py +++ b/salt/utils/thin.py @@ -534,6 +534,7 @@ def gen_min(cachedir, extra_mods='', overwrite=False, so_mods='', 'salt/modules/test.py', 'salt/modules/selinux.py', 'salt/modules/cmdmod.py', + 'salt/modules/saltutil.py', 'salt/minion.py', 'salt/pillar', 'salt/pillar/__init__.py', diff --git a/tests/integration/files/file/base/running.sls b/tests/integration/files/file/base/running.sls index c89113eff1..177662eaf6 100644 --- a/tests/integration/files/file/base/running.sls +++ b/tests/integration/files/file/base/running.sls @@ -1,4 +1,4 @@ sleep_running: module.run: - name: test.sleep - - length: 10 + - length: 20 diff --git a/tests/integration/ssh/test_state.py b/tests/integration/ssh/test_state.py index d57bb72d92..45bdee27aa 100644 --- a/tests/integration/ssh/test_state.py +++ b/tests/integration/ssh/test_state.py @@ -4,6 +4,7 @@ from __future__ import absolute_import import os import shutil +import threading import time # Import Salt Testing Libs @@ -13,6 +14,7 @@ from tests.support.unit import skipIf # Import Salt Libs from salt.ext import six +from salt.ext.six.moves import range # pylint: disable=redefined-builtin SSH_SLS = 'ssh_state_tests' SSH_SLS_FILE = '/tmp/test' @@ -166,19 +168,34 @@ class SSHStateTest(SSHCase): ''' test state.running with salt-ssh ''' - start_sls = self.run_function('state.sls', ['running', '&'], - wipe=False) - time.sleep(8) - get_sls = self.run_function('state.running', wipe=False) - ret = 'The function "state.pkg" is running as' - self.assertIn(ret, ' '.join(get_sls)) + def _run_in_background(): + self.run_function('state.sls', ['running'], wipe=False) + + bg_thread = threading.Thread(target=_run_in_background) + bg_thread.start() + + expected = 'The function "state.pkg" is running as' + for _ in range(3): + time.sleep(5) + get_sls = self.run_function('state.running', wipe=False) + try: + self.assertIn(expected, ' '.join(get_sls)) + except AssertionError: + pass + else: + # We found the expected return + break + else: + self.fail( + 'Did not find \'{0}\' in state.running return'.format(expected) + ) # make sure we wait until the earlier state is complete future = time.time() + 120 while True: if time.time() > future: break - if ret not in ' '.join(self.run_function('state.running', wipe=False)): + if expected not in ' '.join(self.run_function('state.running', wipe=False)): break def tearDown(self):