From be964e731f8b0ff81873ea7d39684bebee2db371 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Wed, 13 Dec 2023 13:59:37 +0300 Subject: [PATCH] [#146] Prettify verifier messages for error rates Signed-off-by: Andrey Berezin --- src/frostfs_testlib/load/load_verifiers.py | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/frostfs_testlib/load/load_verifiers.py b/src/frostfs_testlib/load/load_verifiers.py index fe39862..5ca92dc 100644 --- a/src/frostfs_testlib/load/load_verifiers.py +++ b/src/frostfs_testlib/load/load_verifiers.py @@ -44,22 +44,20 @@ class LoadVerifier: if deleters and not delete_operations: issues.append(f"No any delete operation was performed") - if write_operations and writers and write_errors / write_operations * 100 > self.load_params.error_threshold: - issues.append( - f"Write error rate is greater than threshold: {write_errors / write_operations * 100} > {self.load_params.error_threshold}" - ) - if read_operations and readers and read_errors / read_operations * 100 > self.load_params.error_threshold: - issues.append( - f"Read error rate is greater than threshold: {read_errors / read_operations * 100} > {self.load_params.error_threshold}" - ) - if ( - delete_operations - and deleters - and delete_errors / delete_operations * 100 > self.load_params.error_threshold - ): - issues.append( - f"Delete error rate is greater than threshold: {delete_errors / delete_operations * 100} > {self.load_params.error_threshold}" - ) + error_rate = self._get_error_rate(writers, write_operations, write_errors) + if error_rate > self.load_params.error_threshold: + rate_str = self._get_rate_str(error_rate) + issues.append(f"Write errors exceeded threshold: {rate_str} > {self.load_params.error_threshold}%") + + error_rate = self._get_error_rate(readers, read_operations, read_errors) + if error_rate > self.load_params.error_threshold: + rate_str = self._get_rate_str(error_rate) + issues.append(f"Read errors exceeded threshold: {rate_str} > {self.load_params.error_threshold}%") + + error_rate = self._get_error_rate(deleters, delete_operations, delete_errors) + if error_rate > self.load_params.error_threshold: + rate_str = self._get_rate_str(error_rate) + issues.append(f"Delete errors exceeded threshold: {rate_str} > {self.load_params.error_threshold}%") return issues @@ -76,6 +74,16 @@ class LoadVerifier: ) return verify_issues + def _get_error_rate(self, vus: int, operations: int, errors: int) -> float: + if not operations or not vus: + return 0 + + error_rate = errors / operations * 100 + return error_rate + + def _get_rate_str(self, rate: float, minimal: float = 0.01) -> str: + return f"{rate:.2f}%" if rate >= minimal else f"~{minimal}%" + def _collect_verify_issues_on_process(self, label, load_summary, verification_summary) -> list[str]: issues = []