forked from TrueCloudLab/frostfs-testlib
[#137] Ability to control remote processes id and reports for load
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
e65fc359fe
commit
81dfc723da
5 changed files with 159 additions and 63 deletions
|
@ -34,7 +34,6 @@ class LoadResults:
|
|||
|
||||
class K6:
|
||||
_k6_process: RemoteProcess
|
||||
_start_time: datetime
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -61,6 +60,18 @@ class K6:
|
|||
|
||||
self._k6_dir: str = k6_dir
|
||||
|
||||
command = (
|
||||
f"{self._k6_dir}/k6 run {self._generate_env_variables()} "
|
||||
f"{self._k6_dir}/scenarios/{self.load_params.scenario.value}.js"
|
||||
)
|
||||
user = STORAGE_USER_NAME if self.load_params.scenario == LoadScenario.LOCAL else None
|
||||
process_id = (
|
||||
self.load_params.load_id
|
||||
if self.load_params.scenario != LoadScenario.VERIFY
|
||||
else f"{self.load_params.load_id}_verify"
|
||||
)
|
||||
self._k6_process = RemoteProcess.create(command, self.shell, self.load_params.working_dir, user, process_id)
|
||||
|
||||
@property
|
||||
def process_dir(self) -> str:
|
||||
return self._k6_process.process_dir
|
||||
|
@ -111,15 +122,15 @@ class K6:
|
|||
reporter.attach("\n".join(f"{param}: {value}" for param, value in env_vars.items()), "K6 ENV variables")
|
||||
return " ".join([f"-e {param}='{value}'" for param, value in env_vars.items() if value is not None])
|
||||
|
||||
def get_start_time(self) -> datetime:
|
||||
return datetime.fromtimestamp(self._k6_process.start_time())
|
||||
|
||||
def get_end_time(self) -> datetime:
|
||||
return datetime.fromtimestamp(self._k6_process.end_time())
|
||||
|
||||
def start(self) -> None:
|
||||
with reporter.step(f"Start load from loader {self.loader.ip} on endpoints {self.endpoints}"):
|
||||
self._start_time = int(datetime.utcnow().timestamp())
|
||||
command = (
|
||||
f"{self._k6_dir}/k6 run {self._generate_env_variables()} "
|
||||
f"{self._k6_dir}/scenarios/{self.load_params.scenario.value}.js"
|
||||
)
|
||||
user = STORAGE_USER_NAME if self.load_params.scenario == LoadScenario.LOCAL else None
|
||||
self._k6_process = RemoteProcess.create(command, self.shell, self.load_params.working_dir, user)
|
||||
self._k6_process.start()
|
||||
|
||||
def wait_until_finished(self, soft_timeout: int = 0) -> None:
|
||||
with reporter.step(f"Wait until load is finished from loader {self.loader.ip} on endpoints {self.endpoints}"):
|
||||
|
@ -128,8 +139,10 @@ class K6:
|
|||
else:
|
||||
timeout = self.load_params.load_time or 0
|
||||
|
||||
start_time = int(self.get_start_time().timestamp())
|
||||
|
||||
current_time = int(datetime.utcnow().timestamp())
|
||||
working_time = current_time - self._start_time
|
||||
working_time = current_time - start_time
|
||||
remaining_time = timeout - working_time
|
||||
|
||||
setup_teardown_time = (
|
||||
|
@ -146,7 +159,7 @@ class K6:
|
|||
original_timeout = timeout
|
||||
|
||||
timeouts = {
|
||||
"K6 start time": self._start_time,
|
||||
"K6 start time": start_time,
|
||||
"Current time": current_time,
|
||||
"K6 working time": working_time,
|
||||
"Remaining time for load": remaining_time,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue