Tests: Configurable check for taskd readyness
* Also increase the frequency from 1/s to 2/s
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
@@ -188,7 +189,7 @@ class Taskd(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def start(self, minutes=5):
|
def start(self, minutes=5, tries_per_minute=2):
|
||||||
"""Start the taskd server if it's not running.
|
"""Start the taskd server if it's not running.
|
||||||
If it's already running OSError will be raised
|
If it's already running OSError will be raised
|
||||||
"""
|
"""
|
||||||
@@ -199,10 +200,10 @@ class Taskd(object):
|
|||||||
raise OSError("Taskd server is still running or crashed")
|
raise OSError("Taskd server is still running or crashed")
|
||||||
|
|
||||||
# Wait for server to listen by checking connectivity in the port
|
# Wait for server to listen by checking connectivity in the port
|
||||||
# Default is to wait up to 5 minutes checking once each second
|
# Default is to wait up to 5 minutes checking once every 500ms
|
||||||
for i in range(minutes * 60):
|
for i in range(minutes * 60 * tries_per_minute):
|
||||||
if not self.status():
|
if not self.status():
|
||||||
sleep(1)
|
sleep(1 / tries_per_minute)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ def wait_condition(cond, timeout=1):
|
|||||||
# Max number of attempts until giving up
|
# Max number of attempts until giving up
|
||||||
tries = int(timeout / sleeptime)
|
tries = int(timeout / sleeptime)
|
||||||
|
|
||||||
# Wait for up to a second for the process to finish and avoid zombies
|
|
||||||
for i in range(tries):
|
for i in range(tries):
|
||||||
val = cond()
|
val = cond()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user