Commit 8569c50e authored by Julien Muchembled's avatar Julien Muchembled

run_test_suite: add dumb offline mode for testing purpose

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42828 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6184b051
...@@ -347,6 +347,29 @@ for var in SubprocessError, TestSuite, ERP5TypeTestSuite: ...@@ -347,6 +347,29 @@ for var in SubprocessError, TestSuite, ERP5TypeTestSuite:
setattr(module, var.__name__, var) setattr(module, var.__name__, var)
class DummyTaskDistributionTool(object):
def __init__(self):
self.lock = threading.Lock()
def createTestResult(self, name, revision, test_name_list, allow_restart):
self.test_name_list = list(test_name_list)
return None, revision
def startUnitTest(self, test_result_path, exclude_list=()):
self.lock.acquire()
try:
for i, test in enumerate(self.test_name_list):
if test not in exclude_list:
del self.test_name_list[i]
return None, test
finally:
self.lock.release()
def stopUnitTest(self, test_path, status_dict):
pass
def safeRpcCall(function, *args): def safeRpcCall(function, *args):
retry = 64 retry = 64
while True: while True:
...@@ -400,6 +423,7 @@ def main(): ...@@ -400,6 +423,7 @@ def main():
def makeSuite(revision=None): def makeSuite(revision=None):
updater = Updater(revision) updater = Updater(revision)
if portal_url:
updater.checkout('tests') updater.checkout('tests')
for k in sys.modules.keys(): for k in sys.modules.keys():
if k == 'tests' or k.startswith('tests.'): if k == 'tests' or k.startswith('tests.'):
...@@ -416,15 +440,19 @@ def main(): ...@@ -416,15 +440,19 @@ def main():
suite = suite_class(revision=updater.revision, suite = suite_class(revision=updater.revision,
max_instance_count=max_instance_count, max_instance_count=max_instance_count,
mysql_db_list=db_list[:suite_class.mysql_db_count]) mysql_db_list=db_list[:suite_class.mysql_db_count])
if portal_url:
suite.update() suite.update()
return suite return suite
portal_url = options.master portal_url = options.master
if portal_url:
if portal_url[-1] != '/': if portal_url[-1] != '/':
portal_url += '/' portal_url += '/'
portal = xmlrpclib.ServerProxy(portal_url, allow_none=1) portal = xmlrpclib.ServerProxy(portal_url, allow_none=1)
master = portal.portal_task_distribution master = portal.portal_task_distribution
assert master.getProtocolRevision() == 1 assert master.getProtocolRevision() == 1
else:
master = DummyTaskDistributionTool()
suite = makeSuite() suite = makeSuite()
revision = suite.getRevision() revision = suite.getRevision()
...@@ -432,9 +460,10 @@ def main(): ...@@ -432,9 +460,10 @@ def main():
name, revision, suite.getTestList(), suite.allow_restart) name, revision, suite.getTestList(), suite.allow_restart)
if test_result: if test_result:
test_result_path, test_revision = test_result test_result_path, test_revision = test_result
if portal_url: # for buildbot
url_parts = list(urlparse.urlparse(portal_url + test_result_path)) url_parts = list(urlparse.urlparse(portal_url + test_result_path))
url_parts[1] = url_parts[1].split('@')[-1] url_parts[1] = url_parts[1].split('@')[-1]
print 'ERP5_TEST_URL %s OK' % urlparse.urlunparse(url_parts) # for buildbot print 'ERP5_TEST_URL %s OK' % urlparse.urlunparse(url_parts)
while suite.acquire(): while suite.acquire():
test = safeRpcCall(master.startUnitTest, test_result_path, test = safeRpcCall(master.startUnitTest, test_result_path,
suite.running.keys()) suite.running.keys())
......
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