summaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-05-22 19:03:05 -0300
committerVictor Shyba <victor.shyba@gmail.com>2015-05-26 15:28:06 -0300
commit97cd46960c7dacdda3739223fee129c672fef82e (patch)
tree1d6007ebf6b4ac47da3deefed7916447e0e03624 /common/src
parente4963b12cd700e67c74b9a519a1f659990f2a689 (diff)
[bug] Avoid infinite loop starting couch for tests
As described in #4691, sometimes couch just hangs and all testing freezes. This is due to no output from couch (sometimes meaning that an error on boot wasn't logged). This adds a timeout and checks for it while booting for tests. Closes #4691
Diffstat (limited to 'common/src')
-rw-r--r--common/src/leap/soledad/common/tests/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/src/leap/soledad/common/tests/util.py b/common/src/leap/soledad/common/tests/util.py
index 75379fdc..567bc314 100644
--- a/common/src/leap/soledad/common/tests/util.py
+++ b/common/src/leap/soledad/common/tests/util.py
@@ -315,6 +315,7 @@ class CouchDBWrapper(object):
Wrapper for external CouchDB instance which is started and stopped for
testing.
"""
+ BOOT_TIMEOUT_SECONDS = 5
def start(self):
"""
@@ -347,6 +348,7 @@ class CouchDBWrapper(object):
self.process = subprocess.Popen(
args, env=None, stdout=null.fileno(), stderr=null.fileno(),
close_fds=True)
+ boot_time = time.time()
# find port
logPath = os.path.join(self.tempdir, 'log', 'couch.log')
while not os.path.exists(logPath):
@@ -365,8 +367,14 @@ stderr:
%s""" % (
self.process.returncode, got_stdout, got_stderr))
time.sleep(0.01)
+ if (time.time() - boot_time) > self.BOOT_TIMEOUT_SECONDS:
+ self.stop()
+ raise Exception("Timeout starting couch")
while os.stat(logPath).st_size == 0:
time.sleep(0.01)
+ if (time.time() - boot_time) > self.BOOT_TIMEOUT_SECONDS:
+ self.stop()
+ raise Exception("Timeout starting couch")
PORT_RE = re.compile(
'Apache CouchDB has started on http://127.0.0.1:(?P<port>\d+)')