Merge pull request #45604 from rallytime/bp-45582

Back-port #45582 to 2017.7.3
This commit is contained in:
Nicole Thomas 2018-01-22 11:54:14 -05:00 committed by GitHub
commit ced3269ae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 9 deletions

View File

@ -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():

View File

@ -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',

View File

@ -1,4 +1,4 @@
sleep_running:
module.run:
- name: test.sleep
- length: 10
- length: 20

View File

@ -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):