Commit 55b97101 authored by Sebastien Robin's avatar Sebastien Robin

install runTestSuite command when installing erp5 in order

to allow running parallel tests. runTestSuite command will
come with a list of prepared sql tables

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45591 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9f27a46d
...@@ -76,6 +76,8 @@ class Recipe(BaseSlapRecipe): ...@@ -76,6 +76,8 @@ class Recipe(BaseSlapRecipe):
conversion_server_conf, memcached_conf, kumo_conf, self.site_id) conversion_server_conf, memcached_conf, kumo_conf, self.site_id)
self.installTestRunner(ca_conf, mysql_conf, conversion_server_conf, self.installTestRunner(ca_conf, mysql_conf, conversion_server_conf,
memcached_conf, kumo_conf) memcached_conf, kumo_conf)
self.installTestSuiteRunner(ca_conf, mysql_conf, conversion_server_conf,
memcached_conf, kumo_conf)
self.linkBinary() self.linkBinary()
self.setConnectionDict(dict( self.setConnectionDict(dict(
site_url=apache_conf['apache_login'], site_url=apache_conf['apache_login'],
...@@ -162,11 +164,8 @@ class Recipe(BaseSlapRecipe): ...@@ -162,11 +164,8 @@ class Recipe(BaseSlapRecipe):
def installTestRunner(self, ca_conf, mysql_conf, conversion_server_conf, def installTestRunner(self, ca_conf, mysql_conf, conversion_server_conf,
memcached_conf, kumo_conf): memcached_conf, kumo_conf):
"""Installs bin/runTestSuite executable to run all tests using """Installs bin/runUnitTest executable to run all tests using
bin/runUnitTest""" bin/runUnitTest"""
# XXX: This method can be drastically simplified after #20110128-1ECA63
# (ERP5 specific runUnitTest script shall be generated by erp5 eggg) will
# be solved
testinstance = self.createDataDirectory('testinstance') testinstance = self.createDataDirectory('testinstance')
# workaround wrong assumptions of ERP5Type.tests.runUnitTest about # workaround wrong assumptions of ERP5Type.tests.runUnitTest about
# directory existence # directory existence
...@@ -196,6 +195,43 @@ class Recipe(BaseSlapRecipe): ...@@ -196,6 +195,43 @@ class Recipe(BaseSlapRecipe):
)])[0] )])[0]
self.path_list.append(runUnitTest) self.path_list.append(runUnitTest)
def installTestSuiteRunner(self, ca_conf, mysql_conf, conversion_server_conf,
memcached_conf, kumo_conf):
"""Installs bin/runTestSuite executable to run all tests using
bin/runUnitTest"""
testinstance = self.createDataDirectory('test_suite_instance')
# workaround wrong assumptions of ERP5Type.tests.runUnitTest about
# directory existence
unit_test = os.path.join(testinstance, 'unit_test')
if not os.path.isdir(unit_test):
os.mkdir(unit_test)
connection_string_list = []
for test_database, test_user, test_password in \
mysql_conf['mysql_parallel_test_dict']:
connection_string_list.append(
'%s@%s:%s %s %s' % (test_database, mysql_conf['ip'],
mysql_conf['tcp_port'], test_user, test_password))
command = zc.buildout.easy_install.scripts([
('runTestSuite', __name__ + '.test_suite_runner', 'runTestSuite')],
self.ws, sys.executable, self.bin_directory, arguments=[dict(
instance_home=testinstance,
prepend_path=self.bin_directory,
openssl_binary=self.options['openssl_binary'],
test_ca_path=ca_conf['certificate_authority_path'],
call_list=[self.options['runTestSuite_binary'],
'--db_list', ', '.join(connection_string_list),
'--conversion_server_hostname=%(conversion_server_ip)s' % \
conversion_server_conf,
'--conversion_server_port=%(conversion_server_port)s' % \
conversion_server_conf,
'--volatile_memcached_server_hostname=%(memcached_ip)s' % memcached_conf,
'--volatile_memcached_server_port=%(memcached_port)s' % memcached_conf,
'--persistent_memcached_server_hostname=%(kumo_gateway_ip)s' % kumo_conf,
'--persistent_memcached_server_port=%(kumo_gateway_port)s' % kumo_conf,
]
)])[0]
self.path_list.append(command)
def installCrond(self): def installCrond(self):
timestamps = self.createDataDirectory('cronstamps') timestamps = self.createDataDirectory('cronstamps')
cron_d = os.path.join(self.var_directory, 'cron.d') cron_d = os.path.join(self.var_directory, 'cron.d')
...@@ -555,6 +591,9 @@ SSLRandomSeed connect builtin ...@@ -555,6 +591,9 @@ SSLRandomSeed connect builtin
mysql_test_password=self.generatePassword(), mysql_test_password=self.generatePassword(),
mysql_test_database=test_database, mysql_test_database=test_database,
mysql_test_user=test_user, mysql_test_user=test_user,
mysql_parallel_test_dict=[
('test_%i' % x,)*2 + (self.generatePassword(),) \
for x in xrange(0,100)],
) )
self._createDirectory(mysql_conf['data_directory']) self._createDirectory(mysql_conf['data_directory'])
...@@ -562,8 +601,22 @@ SSLRandomSeed connect builtin ...@@ -562,8 +601,22 @@ SSLRandomSeed connect builtin
self.substituteTemplate(self.getTemplateFilename('my.cnf.in'), self.substituteTemplate(self.getTemplateFilename('my.cnf.in'),
mysql_conf)) mysql_conf))
mysql_script = pkg_resources.resource_string(__name__, mysql_script_list = []
'template/initmysql.sql.in') % mysql_conf for x_database, x_user, x_password in \
[(mysql_conf['mysql_database'],
mysql_conf['mysql_user'],
mysql_conf['mysql_password']),
(mysql_conf['mysql_test_database'],
mysql_conf['mysql_test_user'],
mysql_conf['mysql_test_password']),
] + mysql_conf['mysql_parallel_test_dict']:
mysql_script_list.append(pkg_resources.resource_string(__name__,
'template/initmysql.sql.in') % {
'mysql_database': x_database,
'mysql_user': x_user,
'mysql_password': x_password})
mysql_script_list.append('EXIT')
mysql_script = '\n'.join(mysql_script_list)
self.path_list.extend(zc.buildout.easy_install.scripts([('mysql_update', self.path_list.extend(zc.buildout.easy_install.scripts([('mysql_update',
__name__ + '.mysql', 'updateMysql')], self.ws, __name__ + '.mysql', 'updateMysql')], self.ws,
sys.executable, self.wrapper_directory, arguments=[dict( sys.executable, self.wrapper_directory, arguments=[dict(
......
CREATE DATABASE IF NOT EXISTS %(mysql_database)s; CREATE DATABASE IF NOT EXISTS %(mysql_database)s;
GRANT ALL PRIVILEGES ON %(mysql_database)s.* TO %(mysql_user)s@'%%' IDENTIFIED BY '%(mysql_password)s'; GRANT ALL PRIVILEGES ON %(mysql_database)s.* TO %(mysql_user)s@'%%' IDENTIFIED BY '%(mysql_password)s';
CREATE DATABASE IF NOT EXISTS %(mysql_test_database)s;
GRANT ALL PRIVILEGES ON %(mysql_test_database)s.* TO %(mysql_test_user)s@'%%' IDENTIFIED BY '%(mysql_test_password)s';
EXIT
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