slapos.proxy: tests: do not wait for fixed time for external proxy to be started.

Also remove trailing whitespaces.
parent 91852bd7
...@@ -32,6 +32,7 @@ import ConfigParser ...@@ -32,6 +32,7 @@ import ConfigParser
import os import os
import logging import logging
import shutil import shutil
import socket
import subprocess import subprocess
import tempfile import tempfile
import time import time
...@@ -41,6 +42,7 @@ from xml_marshaller.xml_marshaller import loads, dumps ...@@ -41,6 +42,7 @@ from xml_marshaller.xml_marshaller import loads, dumps
import slapos.proxy import slapos.proxy
import slapos.proxy.views as views import slapos.proxy.views as views
import slapos.slap
import slapos.slap.slap import slapos.slap.slap
import sqlite3 import sqlite3
...@@ -867,6 +869,8 @@ class TestMultiMasterSupport(MasterMixin): ...@@ -867,6 +869,8 @@ class TestMultiMasterSupport(MasterMixin):
self.external_proxy_port = 8281 self.external_proxy_port = 8281
self.external_master_url = 'http://%s:%s' % (self.external_proxy_host, self.external_proxy_port) self.external_master_url = 'http://%s:%s' % (self.external_proxy_host, self.external_proxy_port)
self.external_computer_id = 'external_computer' self.external_computer_id = 'external_computer'
self.external_proxy_slap = slapos.slap.slap()
self.external_proxy_slap.initializeConnection(self.external_master_url)
super(TestMultiMasterSupport, self).setUp() super(TestMultiMasterSupport, self).setUp()
...@@ -900,9 +904,16 @@ database_uri = %(tempdir)s/lib/external_proxy.db ...@@ -900,9 +904,16 @@ database_uri = %(tempdir)s/lib/external_proxy.db
# XXX use current dev version, not standard one installed through package # XXX use current dev version, not standard one installed through package
self.external_proxy_process = subprocess.Popen(['slapos', 'proxy', 'start', '--cfg', self.external_slapproxy_configuration_file_location ]) self.external_proxy_process = subprocess.Popen(['slapos', 'proxy', 'start', '--cfg', self.external_slapproxy_configuration_file_location ])
# Wait a bit for proxy to be started # Wait a bit for proxy to be started
time.sleep(0.5) attempts = 0
self.external_proxy_slap = slapos.slap.slap() while (attempts < 20):
self.external_proxy_slap.initializeConnection(self.external_master_url) try:
self.external_proxy_slap._connection_helper.GET('/')
except slapos.slap.NotFoundError:
break
except socket.error:
attempts = attempts + 1
time.sleep(0.1)
def createSlapOSConfigurationFile(self): def createSlapOSConfigurationFile(self):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment