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