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