mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #45604 from rallytime/bp-45582
Back-port #45582 to 2017.7.3
This commit is contained in:
commit
ced3269ae8
@ -157,7 +157,10 @@ def unpack_thin(thin_path):
|
||||
tfile.extractall(path=OPTIONS.saltdir)
|
||||
tfile.close()
|
||||
os.umask(old_umask)
|
||||
try:
|
||||
os.unlink(thin_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def need_ext():
|
||||
|
@ -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',
|
||||
|
@ -1,4 +1,4 @@
|
||||
sleep_running:
|
||||
module.run:
|
||||
- name: test.sleep
|
||||
- length: 10
|
||||
- length: 20
|
||||
|
@ -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)
|
||||
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)
|
||||
ret = 'The function "state.pkg" is running as'
|
||||
self.assertIn(ret, ' '.join(get_sls))
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user