Commit 77b783e0 authored by Rafael Monnerat's avatar Rafael Monnerat

ERP5TypeCaucaseTestCase: Reduce the chances of conflicting in ports

  This occur quite often if multiple tests rely on caucase running
parent d94c85b6
...@@ -38,6 +38,7 @@ import contextlib ...@@ -38,6 +38,7 @@ import contextlib
import multiprocessing import multiprocessing
import requests import requests
import tarfile import tarfile
from random import randint
import caucase.cli import caucase.cli
import caucase.http import caucase.http
...@@ -103,6 +104,10 @@ class ERP5TypeCaucaseTestCase(ERP5TypeTestCase): ...@@ -103,6 +104,10 @@ class ERP5TypeCaucaseTestCase(ERP5TypeTestCase):
self.caucase_runtime.start() self.caucase_runtime.start()
self.caucase_url = 'http://%s:%s' % (ip, port) self.caucase_url = 'http://%s:%s' % (ip, port)
if not caucase_runtime.is_alive():
self._stopCaucaseServer()
raise AssertionError('Something wrong happens because caucase didnt started')
if not retry( if not retry(
lambda: ( lambda: (
self.assertTrue(caucase_runtime.is_alive()) or self.assertTrue(caucase_runtime.is_alive()) or
...@@ -153,7 +158,15 @@ class ERP5TypeCaucaseTestCase(ERP5TypeTestCase): ...@@ -153,7 +158,15 @@ class ERP5TypeCaucaseTestCase(ERP5TypeTestCase):
) )
test_caucase_connector.validate() test_caucase_connector.validate()
try:
self._startCaucaseServer() self._startCaucaseServer()
except AssertionError:
# The server fail to start, probably another process
# running in parallel picked the port, so sleep a random
# moment to increase the chance of success
time.sleep(randint(1,3))
self._startCaucaseServer()
self.addCleanup(self._stopCaucaseServer) self.addCleanup(self._stopCaucaseServer)
test_caucase_connector.setUrlString(self.caucase_url) test_caucase_connector.setUrlString(self.caucase_url)
test_caucase_connector.bootstrapCaucaseConfiguration() test_caucase_connector.bootstrapCaucaseConfiguration()
......
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