Commit 35f843aa authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add script specific to nosqltestbed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@45897 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 396a0b82
......@@ -39,7 +39,8 @@ class ArgumentType(object):
return path
@classmethod
def objectFromModule(cls, module_name, object_name=None, callable_object=False):
def objectFromModule(cls, module_name, object_name=None,
callable_object=False):
if module_name.endswith('.py'):
module_name = module_name[:-3]
......@@ -229,7 +230,7 @@ from erp5.utils.test_browser.browser import Browser
class BenchmarkProcess(multiprocessing.Process):
def __init__(self, exit_msg_queue, nb_users, user_index,
argument_namespace, *args, **kwargs):
argument_namespace, publish_method, *args, **kwargs):
self._exit_msg_queue = exit_msg_queue
self._nb_users = nb_users
self._user_index = user_index
......@@ -245,6 +246,7 @@ class BenchmarkProcess(multiprocessing.Process):
self._current_repeat = 1
self._current_result = BenchmarkResult()
self._publish_method = publish_method
super(BenchmarkProcess, self).__init__(*args, **kwargs)
......@@ -348,6 +350,9 @@ class BenchmarkProcess(multiprocessing.Process):
self.runBenchmarkSuiteList()
self._current_repeat += 1
if self._current_repeat == 5 and self._publish_method:
self._publish_method(self._result_filename, result_file.tell())
except StopIteration, e:
exit_msg = str(e)
exit_status = 1
......@@ -357,5 +362,9 @@ class BenchmarkProcess(multiprocessing.Process):
exit_msg = "An error occured, see: %s" % self._log_filename
exit_status = 2
else:
if self._publish_method:
self._publish_method(self._result_filename, result_file.tell())
self._exit_msg_queue.put(exit_msg)
sys.exit(exit_status)
......@@ -33,7 +33,7 @@ import os
from benchmark import ArgumentType
def parseArguments():
def parseArguments(argv):
parser = argparse.ArgumentParser(description='Run ERP5 benchmarking suites.')
# Optional arguments
......@@ -105,7 +105,7 @@ def parseArguments():
metavar='BENCHMARK_SUITES',
help='Benchmark suite modules')
namespace = parser.parse_args()
namespace = parser.parse_args(argv)
namespace.user_tuple = ArgumentType.objectFromModule(namespace.user_info_filename,
object_name='user_tuple')
......@@ -130,13 +130,14 @@ import multiprocessing
from benchmark import BenchmarkProcess
def runConstantBenchmark(argument_namespace, nb_users):
def runConstantBenchmark(argument_namespace, nb_users, publish_method):
process_list = []
exit_msg_queue = multiprocessing.Queue(nb_users)
for user_index in range(nb_users):
process = BenchmarkProcess(exit_msg_queue, nb_users, user_index, argument_namespace)
process = BenchmarkProcess(exit_msg_queue, nb_users, user_index, argument_namespace,
publish_method)
process_list.append(process)
for process in process_list:
......@@ -171,13 +172,13 @@ def runConstantBenchmark(argument_namespace, nb_users):
sys.exit(1)
def runBenchmark():
argument_namespace = parseArguments()
def runBenchmark(publish_method=None, argv=None):
argument_namespace = parseArguments(argv)
if isinstance(argument_namespace.users, tuple):
nb_users, max_users = argument_namespace.users
while True:
runConstantBenchmark(argument_namespace, nb_users)
runConstantBenchmark(argument_namespace, nb_users, publish_method)
if nb_users == max_users:
break
......@@ -186,7 +187,20 @@ def runBenchmark():
max_users)
else:
runConstantBenchmark(argument_namespace, argument_namespace.users)
runConstantBenchmark(argument_namespace, argument_namespace.users,
publish_method)
from slapos.tool.nosqltester import NoSQLTester
class BenchmarkTester(NoSQLTester):
def run_tester(self):
runBenchmark(self.send_result_availability_notification,
self.params['argv'])
from slapos.tool.nosqltester import main
def runTester():
main(klass=BenchmarkTester)
if __name__ == '__main__':
runBenchmark()
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