Commit 02054bd7 authored by Jérome Perrin's avatar Jérome Perrin

runTestSuite: support multiple zserver addresses and frontends URLs

As it is backward compatible, this option can be passed as environment
variable.

Also re-order all argument output to make it clear which comes from
SlapOS generated wrapper and which are passed by test node.
parent e893d815
......@@ -24,6 +24,10 @@ class ERP5TypeTestSuite(TestSuite):
if self.__dict__.has_key("bt5_path"):
args = ("--bt5_path=%s" % self.bt5_path,) + args
instance_number = self.instance or 1
args = (
'--zserver=%s' % self.zserver_address_list[instance_number-1],
'--zserver_frontend_url=%s' % self.zserver_frontend_url_list[instance_number-1],
) + args
mysql_db_list = self.mysql_db_list[
(instance_number-1) * self.mysql_db_count:
(instance_number) * self.mysql_db_count]
......
#!/usr/bin/env python2.7
import argparse, sys
import argparse, sys, os, textwrap
from erp5.util import taskdistribution
# XXX: This import is required, just to populate sys.modules['test_suite'].
......@@ -10,8 +10,14 @@ def _parsingErrorHandler(data, _):
print >> sys.stderr, 'Error parsing data:', repr(data)
taskdistribution.patchRPCParser(_parsingErrorHandler)
def makeSuite(node_quantity=None, test_suite=None, revision=None,
db_list=None, **kwargs):
def makeSuite(
node_quantity=None,
test_suite=None,
revision=None,
db_list=None,
zserver_address_list=None,
zserver_frontend_url_list=None,
**kwargs):
# BBB tests (plural form) is only checked for backward compatibility
for k in sys.modules.keys():
if k in ('tests', 'test',) or k.startswith('tests.') or k.startswith('test.'):
......@@ -32,38 +38,71 @@ def makeSuite(node_quantity=None, test_suite=None, revision=None,
suite = suite_class(revision=revision,
max_instance_count=node_quantity,
mysql_db_list=db_list.split(','),
zserver_address_list=zserver_address_list.split(','),
zserver_frontend_url_list=zserver_frontend_url_list.split(','),
**kwargs)
return suite
def main():
parser = argparse.ArgumentParser(description='Run a test suite.')
parser.add_argument('--test_suite', help='The test suite name')
parser.add_argument('--test_suite_title', help='The test suite title',
parser = argparse.ArgumentParser(
description='Run a test suite.',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent('''
Tips:
Running a full test suite on a development machine can be achieved with:
%(prog)s --node_quantity=3 --test_suite=ERP5 --xvfb_bin=/path/to/Xvfb --firefox_bin=/path/to/firefox
'''))
# Parameters included in wrappers generated by SlapOS ERP5 software release.
# To handle backward compatibity, we prefer that the generated wrapper pass
# these parameters as environment variables. This way, if SlapOS SR is more
# recent, the parameter will be ignored by ERP5.
slapos_wrapper_group = parser.add_argument_group(
'SlapOS wrapper arguments',
description='Arguments passed automatically by SlapOS generated wrapper')
slapos_wrapper_group.add_argument('--db_list', help='A list of comma separated sql connection strings')
slapos_wrapper_group.add_argument('--conversion_server_url', default=None)
slapos_wrapper_group.add_argument('--conversion_server_retry_count', default=None)
slapos_wrapper_group.add_argument('--conversion_server_hostname', default=None)
slapos_wrapper_group.add_argument('--conversion_server_port', default=None)
slapos_wrapper_group.add_argument('--volatile_memcached_server_hostname', default=None)
slapos_wrapper_group.add_argument('--volatile_memcached_server_port', default=None)
slapos_wrapper_group.add_argument('--persistent_memcached_server_hostname', default=None)
slapos_wrapper_group.add_argument('--persistent_memcached_server_port', default=None)
slapos_wrapper_group.add_argument('--bt5_path', default=None)
slapos_wrapper_group.add_argument(
'--zserver_address_list',
help='A list of comma seperated host:port for ZServer.\n'
'Also taken from zserver_address_list environment variable.',
default=os.getenv('zserver_address_list'))
slapos_wrapper_group.add_argument(
'--zserver_frontend_url_list',
help='A list of comma seperated frontend URLs, one for each of zserver_address_list,'
'in the same order.\nAlso taken from zserver_frontend_url_list environment variable',
default=os.getenv('zserver_frontend_url_list'))
# Parameters passed by test node
testnode_group = parser.add_argument_group(
'test node arguments',
description='Arguments passed by testnode')
testnode_group.add_argument('--test_suite', help='The test suite name')
testnode_group.add_argument('--test_suite_title', help='The test suite title',
default=None)
parser.add_argument('--test_node_title', help='The test node title',
testnode_group.add_argument('--test_node_title', help='The test node title',
default=None)
parser.add_argument('--project_title', help='The project title',
testnode_group.add_argument('--project_title', help='The project title',
default=None)
parser.add_argument('--revision', help='The revision to test',
testnode_group.add_argument('--revision', help='The revision to test',
default='dummy_revision')
parser.add_argument('--node_quantity', help='Number of parallel tests to run',
testnode_group.add_argument('--node_quantity', help='Number of parallel tests to run',
default=1, type=int)
parser.add_argument('--master_url',
testnode_group.add_argument('--master_url',
help='The Url of Master controling many suites',
default=None)
parser.add_argument('--db_list', help='A list of sql connection strings')
# parameters that needs to be passed to runUnitTest
parser.add_argument('--conversion_server_url', default=None)
parser.add_argument('--conversion_server_retry_count', default=None)
parser.add_argument('--conversion_server_hostname', default=None)
parser.add_argument('--conversion_server_port', default=None)
parser.add_argument('--volatile_memcached_server_hostname', default=None)
parser.add_argument('--volatile_memcached_server_port', default=None)
parser.add_argument('--persistent_memcached_server_hostname', default=None)
parser.add_argument('--persistent_memcached_server_port', default=None)
parser.add_argument('--bt5_path', default=None)
parser.add_argument("--xvfb_bin", default=None)
parser.add_argument("--firefox_bin", default=None)
testnode_group.add_argument("--xvfb_bin", default=None)
testnode_group.add_argument("--firefox_bin", default=None)
args = parser.parse_args()
if args.bt5_path is not None:
......@@ -71,10 +110,21 @@ def main():
master = taskdistribution.TaskDistributor(args.master_url)
test_suite_title = args.test_suite_title or args.test_suite
revision = args.revision
if len(args.zserver_address_list.split(",")) < args.node_quantity:
print >> sys.stderr, 'Not enough zserver address/frontends for node quantity %s (%r)' % (
args.node_quantity, args.zserver_address_list)
sys.exit(1)
# sanity check
assert len(args.zserver_address_list.split(",")) == len(args.zserver_frontend_url_list.split(","))
suite = makeSuite(test_suite=args.test_suite,
node_quantity=args.node_quantity,
revision=revision,
db_list=args.db_list,
zserver_address_list=args.zserver_address_list,
zserver_frontend_url_list=args.zserver_frontend_url_list,
bt5_path=args.bt5_path,
firefox_bin=args.firefox_bin,
xvfb_bin=args.xvfb_bin)
......
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