Commit 1b087f29 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 d501e717
...@@ -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,21 +159,29 @@ class BenchmarkProcess(multiprocessing.Process): ...@@ -158,21 +159,29 @@ class BenchmarkProcess(multiprocessing.Process):
exit_status = 0 exit_status = 0
exit_msg = None 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: try:
with result_instance as result: with result_instance as result:
self._browser = self.getBrowser(result_instance.log_file) self._browser = self.getBrowser(result_instance.log_file)
if self._argument_namespace.duration > 0:
while self._current_repeat != (self._argument_namespace.repeat + 1): self._logger.info("Iterate until duration %d" % self._argument_namespace.duration)
self._logger.info("Iteration: %d" % self._current_repeat) start_time = time.time()
self.runBenchmarkSuiteList(result) while self._argument_namespace.duration > (time.time()-start_time):
runIteration(result)
if not self._current_repeat % REPEAT_NUMBER_BEFORE_FLUSHING: self._current_repeat += 1
try: else:
result.flush() self._logger.info("Iterate until repeat %d" % self._argument_namespace.repeat)
except NothingFlushedException: while self._current_repeat != (self._argument_namespace.repeat + 1):
pass runIteration(result)
self._current_repeat += 1
self._current_repeat += 1
except StopIteration, e: except StopIteration, e:
self._logger.error(e) self._logger.error(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