From 936994b33f25f4bea36c50b7a06c8de85989b69a Mon Sep 17 00:00:00 2001 From: Rafael Monnerat <rafael@nexedi.com> Date: Tue, 16 Aug 2011 01:17:25 -0300 Subject: [PATCH] Implement initial timeout to never lock a test run for more them a day --- product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py b/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py index e600f5b319..ed31c40e20 100755 --- a/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py @@ -29,7 +29,7 @@ import os import transaction -from time import sleep +import time import signal import re from subprocess import Popen, PIPE @@ -63,6 +63,9 @@ bt5_dir_list = ','.join([ os.path.join(instance_home, 'Products/ERP5/bootstrap'), os.path.join(instance_home, 'bt5')]) +class TimeoutError(Exception): + pass + class Xvfb: def __init__(self, fbdir, display): self.display = display @@ -201,6 +204,8 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \ 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=''): @@ -232,12 +237,15 @@ class FunctionalTestRunner: display = None xvfb = Xvfb(self.instance_home, None) try: + start = time.time() if not debug and self.browser.use_xvfb: xvfb.display = self.xvfb_display xvfb.run() browser.run(test_url, xvfb.display) 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: browser.quit() -- 2.30.9