From aa8c83b6829b8bf22cf3a4f84d2b88747f99c3e5 Mon Sep 17 00:00:00 2001 From: "m.malygina" Date: Thu, 28 Mar 2024 14:54:39 +0300 Subject: [PATCH] port fix fill_percent Signed-off-by: m.malygina --- src/frostfs_testlib/load/k6.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/frostfs_testlib/load/k6.py b/src/frostfs_testlib/load/k6.py index 38167d2..0cfe0af 100644 --- a/src/frostfs_testlib/load/k6.py +++ b/src/frostfs_testlib/load/k6.py @@ -4,6 +4,7 @@ import math import os from dataclasses import dataclass from datetime import datetime +from threading import Event from time import sleep from typing import Any from urllib.parse import urlparse @@ -73,14 +74,16 @@ class K6: self._k6_process = RemoteProcess.create(command, self.shell, self.load_params.working_dir, user, process_id) def _get_fill_percents(self): - fill_percents = self.shell.exec("df -H --output=source,pcent,target | grep frostfs").stdout.split("\n") + fill_percents = self.shell.exec("df -H --output=source,pcent,target | grep frostfs | grep data").stdout.split( + "\n" + ) return [line.split() for line in fill_percents][:-1] - + def check_fill_percent(self): fill_percents = self._get_fill_percents() percent_mean = 0 for line in fill_percents: - percent_mean += float(line[1].split('%')[0]) + percent_mean += float(line[1].split("%")[0]) percent_mean = percent_mean / len(fill_percents) logger.info(f"{self.loader.ip} mean fill percent is {percent_mean}") return percent_mean >= self.load_params.fill_percent @@ -145,7 +148,7 @@ class K6: with reporter.step(f"Start load from loader {self.loader.ip} on endpoints {self.endpoints}"): self._k6_process.start() - def wait_until_finished(self, event, soft_timeout: int = 0) -> None: + def wait_until_finished(self, event: Event, soft_timeout: int = 0) -> None: with reporter.step(f"Wait until load is finished from loader {self.loader.ip} on endpoints {self.endpoints}"): if self.load_params.scenario == LoadScenario.VERIFY: timeout = self.load_params.verify_time or 0 @@ -188,23 +191,25 @@ class K6: wait_interval = min_wait_interval if self._k6_process is None: assert "No k6 instances were executed" - + while timeout > 0: if not self.load_params.fill_percent is None: with reporter.step(f"Check the percentage of filling of all data disks on the node"): if self.check_fill_percent(): - logger.info(f"Stopping load on because disks is filled more then {self.load_params.fill_percent}%") + logger.info( + f"Stopping load on because disks is filled more then {self.load_params.fill_percent}%" + ) event.set() self.stop() return - + if event.is_set(): self.stop() return - + if not self._k6_process.running(): return - + remaining_time_hours = f"{timeout//3600}h" if timeout // 3600 != 0 else "" remaining_time_minutes = f"{timeout//60%60}m" if timeout // 60 % 60 != 0 else "" logger.info(