forked from TrueCloudLab/frostfs-testlib
1. Increase wait time for k6 teardown after stop signal 2. Remove duplicated code
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
32a8c5274a
commit
123b5425a8
9 changed files with 40 additions and 371 deletions
|
@ -13,9 +13,10 @@ from frostfs_testlib.load.load_config import (
|
|||
)
|
||||
from frostfs_testlib.processes.remote_process import RemoteProcess
|
||||
from frostfs_testlib.reporter import get_reporter
|
||||
from frostfs_testlib.resources.load_params import LOAD_NODE_SSH_USER
|
||||
from frostfs_testlib.resources.load_params import K6_STOP_SIGNAL_TIMEOUT, LOAD_NODE_SSH_USER
|
||||
from frostfs_testlib.shell import Shell
|
||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||
from frostfs_testlib.testing.test_control import wait_for_success
|
||||
|
||||
EXIT_RESULT_CODE = 0
|
||||
|
||||
|
@ -34,8 +35,6 @@ class LoadResults:
|
|||
|
||||
class K6:
|
||||
_k6_process: RemoteProcess
|
||||
_k6_stop_attempts: int = 5
|
||||
_k6_stop_check_interval: int = 15
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -178,7 +177,7 @@ class K6:
|
|||
if timeout > 0:
|
||||
sleep(wait_interval)
|
||||
timeout -= wait_interval
|
||||
self._stop()
|
||||
self.stop()
|
||||
raise TimeoutError(f"Expected K6 finished in {timeout} sec.")
|
||||
|
||||
def get_results(self) -> Any:
|
||||
|
@ -200,21 +199,12 @@ class K6:
|
|||
reporter.attach(summary_text, allure_filename)
|
||||
return summary_json
|
||||
|
||||
@reporter.step_deco("Assert K6 should be finished")
|
||||
def _k6_should_be_finished(self) -> None:
|
||||
k6_rc = self._k6_process.rc()
|
||||
assert k6_rc == 0, f"K6 unexpectedly finished with RC {k6_rc}"
|
||||
|
||||
@reporter.step_deco("Terminate K6 on initiator")
|
||||
@reporter.step_deco("Stop K6")
|
||||
def stop(self) -> None:
|
||||
if not self.is_running:
|
||||
self.get_results()
|
||||
raise AssertionError("K6 unexpectedly finished")
|
||||
if self.is_running:
|
||||
self._k6_process.stop()
|
||||
|
||||
self._stop()
|
||||
|
||||
k6_rc = self._k6_process.rc()
|
||||
assert k6_rc == EXIT_RESULT_CODE, f"Return code of K6 job should be 0, but {k6_rc}"
|
||||
self._wait_until_process_end()
|
||||
|
||||
@property
|
||||
def is_running(self) -> bool:
|
||||
|
@ -222,20 +212,12 @@ class K6:
|
|||
return self._k6_process.running()
|
||||
return False
|
||||
|
||||
@reporter.step_deco("Try to stop K6 with SIGTERM")
|
||||
def _stop(self) -> None:
|
||||
self._k6_process.stop()
|
||||
with reporter.step("Wait until process end"):
|
||||
for _ in range(self._k6_stop_attempts):
|
||||
if not self._k6_process.running():
|
||||
break
|
||||
|
||||
sleep(self._k6_stop_check_interval)
|
||||
else:
|
||||
raise AssertionError("Can not stop K6 process within timeout")
|
||||
|
||||
def _kill(self) -> None:
|
||||
self._k6_process.kill()
|
||||
@reporter.step_deco("Wait until process end")
|
||||
@wait_for_success(
|
||||
K6_STOP_SIGNAL_TIMEOUT, 15, False, False, "Can not stop K6 process within timeout"
|
||||
)
|
||||
def _wait_until_process_end(self):
|
||||
return self._k6_process.running()
|
||||
|
||||
def __log_output(self) -> None:
|
||||
reporter.attach(self._k6_process.stdout(full=True), "K6 stdout")
|
||||
|
|
|
@ -143,6 +143,9 @@ class LoadParams:
|
|||
min_iteration_duration: Optional[str] = metadata_field(
|
||||
all_load_scenarios, None, "K6_MIN_ITERATION_DURATION"
|
||||
)
|
||||
# Specifies K6 setupTimeout time. Currently hardcoded in xk6 as 5 seconds for all scenarios
|
||||
# https://k6.io/docs/using-k6/k6-options/reference/#setup-timeout
|
||||
setup_timeout: Optional[str] = metadata_field(all_scenarios, None, "K6_SETUP_TIMEOUT")
|
||||
|
||||
# ------- CONSTANT VUS SCENARIO PARAMS -------
|
||||
# Amount of Writers VU.
|
||||
|
@ -202,7 +205,7 @@ class LoadParams:
|
|||
# Maximum verification time for k6 to verify objects. Default is BACKGROUND_LOAD_MAX_VERIFY_TIME (3600).
|
||||
verify_time: Optional[int] = metadata_field([LoadScenario.VERIFY], None, "TIME_LIMIT")
|
||||
# Amount of Verification VU.
|
||||
clients: Optional[int] = metadata_field([LoadScenario.VERIFY], None, "CLIENTS")
|
||||
verify_clients: Optional[int] = metadata_field([LoadScenario.VERIFY], None, "CLIENTS", True)
|
||||
|
||||
def set_id(self, load_id):
|
||||
self.load_id = load_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue