From 2976d3f936a7767d61aa58b52bc88f9fd911f92d Mon Sep 17 00:00:00 2001 From: Ilyas Niyazov Date: Tue, 21 Jan 2025 11:12:37 +0300 Subject: [PATCH] [#360] Added epoch metrics test Signed-off-by: Ilyas Niyazov --- .../testsuites/metrics/test_epoch_metrics.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 pytest_tests/testsuites/metrics/test_epoch_metrics.py diff --git a/pytest_tests/testsuites/metrics/test_epoch_metrics.py b/pytest_tests/testsuites/metrics/test_epoch_metrics.py new file mode 100644 index 00000000..275a6aa9 --- /dev/null +++ b/pytest_tests/testsuites/metrics/test_epoch_metrics.py @@ -0,0 +1,40 @@ +import allure +from frostfs_testlib.testing import parallel +import pytest +from frostfs_testlib import reporter +from frostfs_testlib.steps.metrics import get_metrics_value +from frostfs_testlib.storage.cluster import ClusterNode +from frostfs_testlib.testing.cluster_test_base import ClusterTestBase + + +@pytest.mark.order(-11) +@pytest.mark.nightly +@pytest.mark.metrics +class TestEpochMetrics(ClusterTestBase): + @reporter.step("Get metrics value from node: {node}") + def get_metrics_search_by_greps_parallel(self, node: ClusterNode, **greps): + try: + return get_metrics_value(node, parse_from_command=True, **greps) + except Exception as e: + return None + + @allure.title("Check changes in metric frostfs_node_ir_epoch value") + def test_check_increase_epoch_metric(self): + metric_name = "frostfs_node_ir_epoch" + with reporter.step("Get current value of metric: {metric_name} from each nodes"): + futures = parallel(self.get_metrics_search_by_greps_parallel, self.cluster.cluster_nodes, command=metric_name) + metrics_results = [future.result() for future in futures if future.result() is not None] + + with reporter.step("Check that the metric values are the same in all nodes"): + assert len(set(metrics_results)) == 1, f"Metric {metric_name} values aren't same in all nodes" + assert len(metrics_results) == len(self.cluster.cluster_nodes), "Metrics are not available in some nodes" + + with reporter.step("Tick epoch"): + self.tick_epoch(wait_block=2) + + with reporter.step('Check that metric value increase'): + futures = parallel(self.get_metrics_search_by_greps_parallel, self.cluster.cluster_nodes, command=metric_name) + new_metrics_results = [future.result() for future in futures if future.result() is not None] + + assert len(set(new_metrics_results)) == 1, f"Metric {metric_name} values aren't same in all nodes" + assert new_metrics_results[0] > metrics_results[0], "Metric value doesn't increased"