From d6e08c477b8fedeef29ebb72e02f03569c0cd531 Mon Sep 17 00:00:00 2001 From: "m.malygina" Date: Wed, 26 Jul 2023 13:35:35 +0300 Subject: [PATCH] fix divizion by zero, when total operations is zero --- src/frostfs_testlib/load/load_report.py | 14 ++++++++------ src/frostfs_testlib/load/load_verifiers.py | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/frostfs_testlib/load/load_report.py b/src/frostfs_testlib/load/load_report.py index e1056b70..a2cecf62 100644 --- a/src/frostfs_testlib/load/load_report.py +++ b/src/frostfs_testlib/load/load_report.py @@ -100,7 +100,7 @@ class LoadReport: return model_map[self.load_params.scenario] - def _get_oprations_sub_section_html( + def _get_operations_sub_section_html( self, operation_type: str, total_operations: int, @@ -132,7 +132,9 @@ class LoadReport: model = self._get_model_string() # write 8KB 15h49m 50op/sec 50th open model/closed model/min_iteration duration=1s - 1.636MB/s 199.57451/s short_summary = f"{operation_type} {object_size}{object_size_unit} {duration} {requested_rate_str} {vus_str} {model} - {throughput:.2f}{unit}/s {total_rate:.2f}/s" - + errors_percent = 0 + if total_operations: + errors_percent = total_errors/total_operations*100.0 html = f""" @@ -143,7 +145,7 @@ class LoadReport: {per_node_errors_html} - {self._row("Total", f"{total_errors} ({total_errors/total_operations*100.0:.2f}%)")} + {self._row("Total", f"{total_errors} ({errors_percent:.2f}%)")} {self._row("Threshold", f"{self.load_params.error_threshold:.2f}%")}
{short_summary}
Errors


""" @@ -228,7 +230,7 @@ class LoadReport: delete_errors[node_key] = metrics.delete_failed_iterations if write_section_required: - html += self._get_oprations_sub_section_html( + html += self._get_operations_sub_section_html( "Write", write_operations, requested_write_rate_str, @@ -239,7 +241,7 @@ class LoadReport: ) if read_section_required: - html += self._get_oprations_sub_section_html( + html += self._get_operations_sub_section_html( "Read", read_operations, requested_read_rate_str, @@ -250,7 +252,7 @@ class LoadReport: ) if delete_section_required: - html += self._get_oprations_sub_section_html( + html += self._get_operations_sub_section_html( "Delete", delete_operations, requested_delete_rate_str, diff --git a/src/frostfs_testlib/load/load_verifiers.py b/src/frostfs_testlib/load/load_verifiers.py index f2a3e7eb..80c3962a 100644 --- a/src/frostfs_testlib/load/load_verifiers.py +++ b/src/frostfs_testlib/load/load_verifiers.py @@ -49,15 +49,15 @@ class LoadVerifier: if deleters and not delete_operations: exceptions.append(f"No any delete operation was performed") - if writers and write_errors / write_operations * 100 > self.load_params.error_threshold: + if write_operations and writers and write_errors / write_operations * 100 > self.load_params.error_threshold: exceptions.append( f"Write error rate is greater than threshold: {write_errors / write_operations * 100} > {self.load_params.error_threshold}" ) - if readers and read_errors / read_operations * 100 > self.load_params.error_threshold: + if read_operations and readers and read_errors / read_operations * 100 > self.load_params.error_threshold: exceptions.append( f"Read error rate is greater than threshold: {read_errors / read_operations * 100} > {self.load_params.error_threshold}" ) - if deleters and delete_errors / delete_operations * 100 > self.load_params.error_threshold: + if delete_operations and deleters and delete_errors / delete_operations * 100 > self.load_params.error_threshold: exceptions.append( f"Delete error rate is greater than threshold: {delete_errors / delete_operations * 100} > {self.load_params.error_threshold}" )