Commit 74bdb693 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Don't use runner parameters to change process environment.

- Runner do not define the environment, this is under the responsibility
of the parent script.
- Prefix all environment variables with NEO_TEST to avoid conflicts with
other applications
- Runner display all NEO-related environment variables in the report
- Cosmetic change: increase benchmark runner status column size

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2586 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent dd89c78e
...@@ -53,7 +53,7 @@ class BenchmarkRunner(object): ...@@ -53,7 +53,7 @@ class BenchmarkRunner(object):
self._status.append((key, value)) self._status.append((key, value))
def build_report(self, content): def build_report(self, content):
fmt = "%-20s : %s" fmt = "%-25s : %s"
status = "\n".join([fmt % item for item in [ status = "\n".join([fmt % item for item in [
('Title', self._config.title), ('Title', self._config.title),
('Date', datetime.date.today().isoformat()), ('Date', datetime.date.today().isoformat()),
......
...@@ -25,10 +25,10 @@ class ZODBTestCase(NEOFunctionalTest): ...@@ -25,10 +25,10 @@ class ZODBTestCase(NEOFunctionalTest):
def setUp(self): def setUp(self):
NEOFunctionalTest.setUp(self) NEOFunctionalTest.setUp(self)
masters = int(os.environ.get('ZODB_MASTERS', 1)) masters = int(os.environ.get('NEO_TEST_ZODB_MASTERS', 1))
storages = int(os.environ.get('ZODB_STORAGES', 1)) storages = int(os.environ.get('NEO_TEST_ZODB_STORAGES', 1))
replicas = int(os.environ.get('ZODB_REPLICAS', 0)) replicas = int(os.environ.get('NEO_TEST_ZODB_REPLICAS', 0))
partitions = int(os.environ.get('ZODB_PARTITIONS', 1)) partitions = int(os.environ.get('NEO_TEST_ZODB_PARTITIONS', 1))
self.neo = NEOCluster( self.neo = NEOCluster(
db_list=['test_neo%d' % x for x in xrange(storages)], db_list=['test_neo%d' % x for x in xrange(storages)],
partitions=partitions, partitions=partitions,
......
...@@ -105,22 +105,13 @@ for logger_name in ('NEO', 'CLIENT'): ...@@ -105,22 +105,13 @@ for logger_name in ('NEO', 'CLIENT'):
class NeoTestRunner(unittest.TestResult): class NeoTestRunner(unittest.TestResult):
""" Custom result class to build report with statistics per module """ """ Custom result class to build report with statistics per module """
def __init__(self, title, masters, storages, replicas, partitions): def __init__(self, title):
unittest.TestResult.__init__(self) unittest.TestResult.__init__(self)
self._title = title self._title = title
self.modulesStats = {} self.modulesStats = {}
self.failedImports = {} self.failedImports = {}
self.lastStart = None self.lastStart = None
self.masters = masters
self.storages = storages
self.replicas = replicas
self.partitions = partitions
self.temp_directory = tempfile.mkdtemp(prefix='neo_') self.temp_directory = tempfile.mkdtemp(prefix='neo_')
os.environ['TEMP'] = self.temp_directory
os.environ['ZODB_MASTERS'] = str(masters)
os.environ['ZODB_STORAGES'] = str(storages)
os.environ['ZODB_REPLICAS'] = str(replicas)
os.environ['ZODB_PARTITIONS'] = str(partitions)
print "Base directory : %s" % (self.temp_directory, ) print "Base directory : %s" % (self.temp_directory, )
def run(self, name, modules): def run(self, name, modules):
...@@ -194,11 +185,10 @@ class NeoTestRunner(unittest.TestResult): ...@@ -194,11 +185,10 @@ class NeoTestRunner(unittest.TestResult):
def _buildSummary(self, add_status): def _buildSummary(self, add_status):
success = self.testsRun - len(self.errors) - len(self.failures) success = self.testsRun - len(self.errors) - len(self.failures)
add_status('Directory', self.temp_directory) add_status('Directory', self.temp_directory)
add_status('Masters', self.masters)
add_status('Storages', self.storages)
add_status('Replicas', self.replicas)
add_status('Partitions', self.partitions)
add_status('Status', '%.3f%%' % (success * 100.0 / self.testsRun)) add_status('Status', '%.3f%%' % (success * 100.0 / self.testsRun))
for var in os.environ.iterkeys():
if var.startswith('NEO_TEST'):
add_status(var, os.environ[var])
# visual # visual
header = "%25s | run | success | errors | fails | time \n" % 'Test Module' header = "%25s | run | success | errors | fails | time \n" % 'Test Module'
separator = "%25s-+---------+---------+---------+---------+----------\n" % ('-' * 25) separator = "%25s-+---------+---------+---------+---------+----------\n" % ('-' * 25)
...@@ -280,10 +270,6 @@ class TestRunner(BenchmarkRunner): ...@@ -280,10 +270,6 @@ class TestRunner(BenchmarkRunner):
parser.add_option('-f', '--functional', action='store_true') parser.add_option('-f', '--functional', action='store_true')
parser.add_option('-u', '--unit', action='store_true') parser.add_option('-u', '--unit', action='store_true')
parser.add_option('-z', '--zodb', action='store_true') parser.add_option('-z', '--zodb', action='store_true')
parser.add_option('', '--zodb-masters')
parser.add_option('', '--zodb-storages')
parser.add_option('', '--zodb-replicas')
parser.add_option('', '--zodb-partitions')
def load_options(self, options, args): def load_options(self, options, args):
if not (options.unit or options.functional or options.zodb or args): if not (options.unit or options.functional or options.zodb or args):
...@@ -292,10 +278,6 @@ class TestRunner(BenchmarkRunner): ...@@ -292,10 +278,6 @@ class TestRunner(BenchmarkRunner):
unit = options.unit, unit = options.unit,
functional = options.functional, functional = options.functional,
zodb = options.zodb, zodb = options.zodb,
zodb_masters = int(options.zodb_masters or 1),
zodb_storages = int(options.zodb_storages or 1),
zodb_replicas = int(options.zodb_replicas or 0),
zodb_partitions = int(options.zodb_partitions or 1),
) )
def start(self): def start(self):
...@@ -303,10 +285,6 @@ class TestRunner(BenchmarkRunner): ...@@ -303,10 +285,6 @@ class TestRunner(BenchmarkRunner):
# run requested tests # run requested tests
runner = NeoTestRunner( runner = NeoTestRunner(
title=config.title or 'Neo', title=config.title or 'Neo',
masters=config.zodb_masters,
storages=config.zodb_storages,
replicas=config.zodb_replicas,
partitions=config.zodb_partitions,
) )
try: try:
if config.unit: if config.unit:
......
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