diff --git a/src/frostfs_testlib/load/load_verifiers.py b/src/frostfs_testlib/load/load_verifiers.py index b691b02..d2440dd 100644 --- a/src/frostfs_testlib/load/load_verifiers.py +++ b/src/frostfs_testlib/load/load_verifiers.py @@ -49,30 +49,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 @@ -89,9 +79,17 @@ class LoadVerifier: ) return verify_issues - def _collect_verify_issues_on_process( - self, label, load_summary, verification_summary - ) -> list[str]: + 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 = [] load_metrics = get_metrics_object(self.load_params.scenario, load_summary)