Commit 1cb29cf1 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Introduce --max-errors parameter to stop after a given number of errors and

rewrite integer check function to allow specifying a minimum value
parent 4e61a570
...@@ -70,21 +70,26 @@ class ArgumentType(object): ...@@ -70,21 +70,26 @@ class ArgumentType(object):
return obj return obj
@classmethod @classmethod
def strictlyPositiveIntType(cls, value): def checkIntValueWrapper(cls, minimum):
try: def checkIntValue(value):
converted_value = int(value) try:
except ValueError: converted_value = int(value)
pass except ValueError:
else: pass
if converted_value > 0: else:
return converted_value if converted_value >= minimum:
return converted_value
raise argparse.ArgumentTypeError('expects a strictly positive integer') raise argparse.ArgumentTypeError('Expected an integer >= %d' % minimum)
return checkIntValue
@classmethod @classmethod
def strictlyPositiveIntOrRangeType(cls, value): def strictlyPositiveIntOrRangeType(cls, value):
checkIntValue = cls.checkIntValueWrapper(minimum=1)
try: try:
return cls.strictlyPositiveIntType(value) return checkIntValue(value)
except argparse.ArgumentTypeError: except argparse.ArgumentTypeError:
try: try:
min_max_list = value.split(',') min_max_list = value.split(',')
...@@ -92,8 +97,8 @@ class ArgumentType(object): ...@@ -92,8 +97,8 @@ class ArgumentType(object):
pass pass
else: else:
if len(min_max_list) == 2: if len(min_max_list) == 2:
minimum, maximum = cls.strictlyPositiveIntType(min_max_list[0]), \ minimum, maximum = checkIntValue(min_max_list[0]), \
cls.strictlyPositiveIntType(min_max_list[1]) checkIntValue(min_max_list[1])
if minimum >= maximum: if minimum >= maximum:
raise argparse.ArgumentTypeError('%d >= %d' % (minimum, maximum)) raise argparse.ArgumentTypeError('%d >= %d' % (minimum, maximum))
......
...@@ -80,12 +80,19 @@ class PerformanceTester(object): ...@@ -80,12 +80,19 @@ class PerformanceTester(object):
help="Import users from ``user_tuple'' in MODULE") help="Import users from ``user_tuple'' in MODULE")
parser.add_argument('--users-range-increment', parser.add_argument('--users-range-increment',
type=ArgumentType.strictlyPositiveIntType, type=ArgumentType.checkIntValueWrapper(minimum=1),
default=1, default=1,
metavar='N', metavar='N',
help='Number of users being added after each repetition ' help='Number of users being added after each repetition '
'(default: 1)') '(default: 1)')
parser.add_argument('--max-errors',
dest='max_error_number',
type=ArgumentType.checkIntValueWrapper(minimum=0),
default=10,
help='Stop execution after N consecutive errors '
'(default: 10)')
parser.add_argument('--enable-debug', '-d', parser.add_argument('--enable-debug', '-d',
action='store_true', action='store_true',
default=False, default=False,
...@@ -98,7 +105,7 @@ class PerformanceTester(object): ...@@ -98,7 +105,7 @@ class PerformanceTester(object):
help='Enable legacy listbox for Browser') help='Enable legacy listbox for Browser')
parser.add_argument('--repeat', parser.add_argument('--repeat',
type=ArgumentType.strictlyPositiveIntType, type=ArgumentType.checkIntValueWrapper(minimum=1),
default=-1, default=-1,
metavar='N', metavar='N',
help='Repeat the benchmark suite N times ' help='Repeat the benchmark suite N times '
......
...@@ -36,7 +36,6 @@ import sys ...@@ -36,7 +36,6 @@ import sys
from ..testbrowser.browser import Browser from ..testbrowser.browser import Browser
MAXIMUM_ERROR_COUNTER = 10
RESULT_NUMBER_BEFORE_FLUSHING = 100 RESULT_NUMBER_BEFORE_FLUSHING = 100
class BenchmarkProcess(multiprocessing.Process): class BenchmarkProcess(multiprocessing.Process):
...@@ -90,11 +89,11 @@ class BenchmarkProcess(multiprocessing.Process): ...@@ -90,11 +89,11 @@ class BenchmarkProcess(multiprocessing.Process):
except: except:
pass pass
self._error_counter += 1
if (self._current_repeat == 1 or if (self._current_repeat == 1 or
self._error_counter == MAXIMUM_ERROR_COUNTER): self._error_counter >= self._argument_namespace.max_error_number):
raise RuntimeError(msg) raise RuntimeError(msg)
self._error_counter += 1
self._logger.warning(msg) self._logger.warning(msg)
for stat in result.getCurrentSuiteStatList(): for stat in result.getCurrentSuiteStatList():
......
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