Commit 4fb11202 authored by Benjamin Blanc's avatar Benjamin Blanc Committed by Sebastien Robin

performance_tester: add command line options to use different paths.

Add option to specify several path where to find users file(s),
and benchmark suite file(s).
parent c64d2536
...@@ -41,7 +41,7 @@ class ArgumentType(object): ...@@ -41,7 +41,7 @@ class ArgumentType(object):
@classmethod @classmethod
def objectFromModule(cls, module_name, object_name=None, def objectFromModule(cls, module_name, object_name=None,
callable_object=False): callable_object=False, searchable_path_list=None):
if module_name.endswith('.py'): if module_name.endswith('.py'):
module_name = module_name[:-3] module_name = module_name[:-3]
...@@ -50,6 +50,10 @@ class ArgumentType(object): ...@@ -50,6 +50,10 @@ class ArgumentType(object):
import sys import sys
sys.path.append(os.getcwd()) sys.path.append(os.getcwd())
if searchable_path_list:
for path in searchable_path_list:
sys.path.append(path)
try: try:
module = __import__(module_name, globals(), locals(), [object_name], -1) module = __import__(module_name, globals(), locals(), [object_name], -1)
......
...@@ -77,6 +77,10 @@ class PerformanceTester(object): ...@@ -77,6 +77,10 @@ class PerformanceTester(object):
metavar='MODULE', metavar='MODULE',
help="Import users from ``user_tuple'' in MODULE") help="Import users from ``user_tuple'' in MODULE")
parser.add_argument('--users-file-path',
metavar='USER_FILE_PATH',
help='User file path')
parser.add_argument('--users-range-increment', parser.add_argument('--users-range-increment',
type=ArgumentType.checkIntValueWrapper(minimum=1), type=ArgumentType.checkIntValueWrapper(minimum=1),
default=1, default=1,
...@@ -132,6 +136,13 @@ class PerformanceTester(object): ...@@ -132,6 +136,13 @@ class PerformanceTester(object):
metavar='ERP5_PUBLISH_PROJECT', metavar='ERP5_PUBLISH_PROJECT',
help='ERP5 publish project') help='ERP5 publish project')
parser.add_argument('--benchmark-path-list',
default=[],
nargs='+',
metavar='BENCHMARK_PATH',
help='Benchmark paths')
# Mandatory arguments # Mandatory arguments
parser.add_argument('erp5_base_url', metavar='ERP5_URL') parser.add_argument('erp5_base_url', metavar='ERP5_URL')
...@@ -144,16 +155,25 @@ class PerformanceTester(object): ...@@ -144,16 +155,25 @@ class PerformanceTester(object):
nargs='+', nargs='+',
metavar='BENCHMARK_SUITES', metavar='BENCHMARK_SUITES',
help='Benchmark suite modules') help='Benchmark suite modules')
@staticmethod @staticmethod
def _check_parsed_arguments(namespace): def _check_parsed_arguments(namespace):
if namespace.users_file_path:
users_file_path_list = [namespace.users_file_path]
else:
users_file_path_list = []
namespace.user_tuple = ArgumentType.objectFromModule(namespace.user_info_filename, namespace.user_tuple = ArgumentType.objectFromModule(namespace.user_info_filename,
object_name='user_tuple') object_name='user_tuple',
searchable_path_list=users_file_path_list)
namespace.benchmark_suite_list = namespace.benchmark_suite_list[0].split(" ")
object_benchmark_suite_list = [] object_benchmark_suite_list = []
for benchmark_suite in namespace.benchmark_suite_list: for benchmark_suite in namespace.benchmark_suite_list:
object_benchmark_suite_list.append(ArgumentType.objectFromModule(benchmark_suite, object_benchmark_suite_list.append(ArgumentType.objectFromModule(benchmark_suite,
callable_object=True)) callable_object=True,
searchable_path_list=namespace.benchmark_path_list))
if namespace.repeat > 0: if namespace.repeat > 0:
namespace.max_error_number = \ namespace.max_error_number = \
......
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