mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Give supervisor a little time to startup during tests
This commit is contained in:
parent
4948914766
commit
1eca34f8e6
@ -1,6 +1,6 @@
|
||||
[unix_http_server]
|
||||
file={{ virtual_env }}/supervisor.sock ; (the path to the socket file)
|
||||
chmod=0700 ; sockef file mode (default 0700)
|
||||
file={{ supervisor_sock }} ; (the path to the socket file)
|
||||
chmod=0700 ; socket file mode (default 0700)
|
||||
|
||||
[supervisord]
|
||||
logfile={{ virtual_env }}/supervisord.log ; (main log file;default $CWD/supervisord.log)
|
||||
@ -13,7 +13,7 @@ pidfile={{ virtual_env }}/supervisord.pid ; (supervisord pidfile;default supervi
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix://{{ virtual_env }}/supervisor.sock ; use a unix:// URL for a unix socket
|
||||
serverurl=unix://{{ supervisor_sock }} ; use a unix:// URL for a unix socket
|
||||
|
||||
[program:sleep_service]
|
||||
command=sleep 600
|
||||
|
@ -2,6 +2,7 @@ import os
|
||||
import tempfile
|
||||
import integration
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
class SupervisordModuleTest(integration.ModuleCase):
|
||||
@ -15,6 +16,7 @@ class SupervisordModuleTest(integration.ModuleCase):
|
||||
self.skipTest('virtualenv not installed')
|
||||
self.venv_test_dir = tempfile.mkdtemp()
|
||||
self.venv_dir = os.path.join(self.venv_test_dir, 'venv')
|
||||
self.supervisor_sock = os.path.join(self.venv_dir, 'supervisor.sock')
|
||||
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
self.run_function('pip.install', [], pkgs='supervisor', bin_env=self.venv_dir)
|
||||
@ -29,7 +31,8 @@ class SupervisordModuleTest(integration.ModuleCase):
|
||||
'file.managed', name=self.supervisor_conf, source='salt://supervisor.conf',
|
||||
template='jinja',
|
||||
context={
|
||||
'virtual_env': self.venv_dir,
|
||||
'supervisor_sock' : self.supervisor_sock,
|
||||
'virtual_env' : self.venv_dir,
|
||||
'autostart': autostart
|
||||
}
|
||||
)
|
||||
@ -38,6 +41,15 @@ class SupervisordModuleTest(integration.ModuleCase):
|
||||
self.supervisor_proc = subprocess.Popen([self.supervisord, '-c', self.supervisor_conf])
|
||||
if self.supervisor_proc.poll() is not None:
|
||||
self.skipTest('failed to start supervisord')
|
||||
timeout = 10
|
||||
while not os.path.exists(self.supervisor_sock):
|
||||
if timeout == 0:
|
||||
self.skipTest('supervisor socket not found - failed to start supervisord')
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
timeout -= 1
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
if hasattr(self, 'supervisor_proc') and self.supervisor_proc.poll() is not None:
|
||||
|
@ -5,6 +5,7 @@ import os
|
||||
import tempfile
|
||||
import integration
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
|
||||
@ -20,6 +21,7 @@ class SupervisordTest(integration.ModuleCase,
|
||||
self.skipTest('virtualenv not installed')
|
||||
self.venv_test_dir = tempfile.mkdtemp()
|
||||
self.venv_dir = os.path.join(self.venv_test_dir, 'venv')
|
||||
self.supervisor_sock = os.path.join(self.venv_dir, 'supervisor.sock')
|
||||
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
self.run_function('pip.install', [], pkgs='supervisor', bin_env=self.venv_dir)
|
||||
@ -35,6 +37,7 @@ class SupervisordTest(integration.ModuleCase,
|
||||
'file.managed', name=self.supervisor_conf, source='salt://supervisor.conf',
|
||||
template='jinja',
|
||||
context={
|
||||
'supervisor_sock' : self.supervisor_sock,
|
||||
'virtual_env': self.venv_dir,
|
||||
'autostart': autostart
|
||||
}
|
||||
@ -44,6 +47,14 @@ class SupervisordTest(integration.ModuleCase,
|
||||
self.supervisor_proc = subprocess.Popen([self.supervisord, '-c', self.supervisor_conf])
|
||||
if self.supervisor_proc.poll() is not None:
|
||||
self.skipTest('failed to start supervisord')
|
||||
timeout = 10
|
||||
while not os.path.exists(self.supervisor_sock):
|
||||
if timeout == 0:
|
||||
self.skipTest('supervisor socket not found - failed to start supervisord')
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
timeout -= 1
|
||||
|
||||
def tearDown(self):
|
||||
if hasattr(self, 'supervisor_proc') and self.supervisor_proc.poll() is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user