From 5098e4021adf702e67d40e7235ebec5f4d0937b6 Mon Sep 17 00:00:00 2001 From: Ilyas Niyazov Date: Tue, 17 Dec 2024 14:53:34 +0300 Subject: [PATCH] [#343] Fixed test logs metrics Signed-off-by: Ilyas Niyazov --- pytest_tests/testsuites/metrics/test_logs_metrics.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pytest_tests/testsuites/metrics/test_logs_metrics.py b/pytest_tests/testsuites/metrics/test_logs_metrics.py index b3e9ab09..1a25d5eb 100644 --- a/pytest_tests/testsuites/metrics/test_logs_metrics.py +++ b/pytest_tests/testsuites/metrics/test_logs_metrics.py @@ -13,6 +13,8 @@ from frostfs_testlib.storage.dataclasses.frostfs_services import StorageNode from frostfs_testlib.testing.cluster_test_base import ClusterTestBase from frostfs_testlib.testing.test_control import wait_for_success +from ...helpers.utility import are_numbers_similar + @pytest.mark.nightly @pytest.mark.metrics @@ -34,7 +36,12 @@ class TestLogsMetrics(ClusterTestBase): current_time = datetime.now(timezone.utc) counter_metrics = get_metrics_value(cluster_node, **metrics_greps) counter_logs = self.get_count_logs_by_level(cluster_node, metrics_greps.get("level"), restart_time, current_time, log_priority) - assert counter_logs == counter_metrics, f"counter_logs: {counter_logs}, counter_metrics: {counter_metrics} in node: {cluster_node}" + assert counter_logs == pytest.approx( + counter_metrics, rel=0.02 + ), f"counter_logs: {counter_logs}, counter_metrics: {counter_metrics} in node: {cluster_node}" + assert are_numbers_similar( + counter_logs, counter_metrics, tolerance_percentage=2 + ), f"counter_logs: {counter_logs}, counter_metrics: {counter_metrics} in node: {cluster_node}" @staticmethod def get_count_logs_by_level(cluster_node: ClusterNode, log_level: str, after_time: datetime, until_time: datetime, log_priority: str):