Commit 936994b3 authored by Rafael Monnerat's avatar Rafael Monnerat

Implement initial timeout to never lock a test run for more them a day

parent ea890a3a
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
import os import os
import transaction import transaction
from time import sleep import time
import signal import signal
import re import re
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
...@@ -63,6 +63,9 @@ bt5_dir_list = ','.join([ ...@@ -63,6 +63,9 @@ bt5_dir_list = ','.join([
os.path.join(instance_home, 'Products/ERP5/bootstrap'), os.path.join(instance_home, 'Products/ERP5/bootstrap'),
os.path.join(instance_home, 'bt5')]) os.path.join(instance_home, 'bt5')])
class TimeoutError(Exception):
pass
class Xvfb: class Xvfb:
def __init__(self, fbdir, display): def __init__(self, fbdir, display):
self.display = display self.display = display
...@@ -201,6 +204,8 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \ ...@@ -201,6 +204,8 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \
class FunctionalTestRunner: class FunctionalTestRunner:
# There is no test that can take more them 24 hours
timeout = 24 * 60 * 60
def __init__(self, host, port, portal, run_only=''): def __init__(self, host, port, portal, run_only=''):
...@@ -232,12 +237,15 @@ class FunctionalTestRunner: ...@@ -232,12 +237,15 @@ class FunctionalTestRunner:
display = None display = None
xvfb = Xvfb(self.instance_home, None) xvfb = Xvfb(self.instance_home, None)
try: try:
start = time.time()
if not debug and self.browser.use_xvfb: if not debug and self.browser.use_xvfb:
xvfb.display = self.xvfb_display xvfb.display = self.xvfb_display
xvfb.run() xvfb.run()
browser.run(test_url, xvfb.display) browser.run(test_url, xvfb.display)
while self.getStatus() is None: while self.getStatus() is None:
sleep(10) time.sleep(10)
if (start - time.time()) > float(self.timeout):
raise TimeoutError("Test took more them %s seconds" % self.timeout)
finally: finally:
browser.quit() browser.quit()
......
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