Commit 981ff042 authored by Roque's avatar Roque Committed by Klaus Wölfel

scalability-benchmark: refactoring and parametrizable test duration

- test duration is get from testsuite definition
- refactoring and cleanup in runScalabilityTestSuite and benchmark
- request timeout in metric thread

/reviewed-on nexedi/erp5!607
parent f9bde339
......@@ -113,6 +113,11 @@ class PerformanceTester(object):
help='Repeat the benchmark suite N times for a given '
'number of users (default: infinite)')
parser.add_argument('--duration',
type=int,
default=0,
help='Repeat the benchmark suite until time duration is reached')
parser.add_argument('--repeat-range',
type=ArgumentType.checkIntValueWrapper(minimum=1),
default=-1,
......
......@@ -31,6 +31,7 @@ import traceback
import signal
import sys
import socket
import time
from ..testbrowser.browser import Browser
from .result import NothingFlushedException
......@@ -158,21 +159,29 @@ class BenchmarkProcess(multiprocessing.Process):
exit_status = 0
exit_msg = None
def runIteration(result):
self._logger.info("Iteration: %d" % self._current_repeat)
self.runBenchmarkSuiteList(result)
if not self._current_repeat % REPEAT_NUMBER_BEFORE_FLUSHING:
try:
result.flush()
except NothingFlushedException:
pass
try:
with result_instance as result:
self._browser = self.getBrowser(result_instance.log_file)
while self._current_repeat != (self._argument_namespace.repeat + 1):
self._logger.info("Iteration: %d" % self._current_repeat)
self.runBenchmarkSuiteList(result)
if not self._current_repeat % REPEAT_NUMBER_BEFORE_FLUSHING:
try:
result.flush()
except NothingFlushedException:
pass
self._current_repeat += 1
if self._argument_namespace.duration > 0:
self._logger.info("Iterate until duration %d" % self._argument_namespace.duration)
start_time = time.time()
while self._argument_namespace.duration > (time.time()-start_time):
runIteration(result)
self._current_repeat += 1
else:
self._logger.info("Iterate until repeat %d" % self._argument_namespace.repeat)
while self._current_repeat != (self._argument_namespace.repeat + 1):
runIteration(result)
self._current_repeat += 1
except StopIteration, e:
self._logger.error(e)
......
......@@ -56,7 +56,7 @@ class TestMetricThread(threading.Thread):
while(not self.stop_event.is_set()):
self.stop_event.wait(-time.time() % self.interval)
try:
response = requests.get(self.metric_url)
response = requests.get(self.metric_url, timeout=60)
if response.status_code == 200:
self.metric_list.append(response.text)
else:
......@@ -71,6 +71,3 @@ class TestMetricThread(threading.Thread):
def getErrorMessage(self):
return self.error_message
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