mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Further fixes to for salt-ssh test under heavy load
This makes some further tweaks to make the test more stable under heavy load. Firstly, the background job sleeps longer, and secondly, we make up to 3 attempts run state.running instead of just the one, in case our first attempt was too early. It also uses threading to make the job sleep, since the method of adding a & to the command seemed to be producing intermittent failures with returning clean JSON.
This commit is contained in:
parent
0dff596b59
commit
629e6c9674
3 changed files with 26 additions and 8 deletions
|
@ -535,6 +535,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)
|
||||
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):
|
||||
|
|
Loading…
Add table
Reference in a new issue