From 3e64b523065828bcbb84ec9bede0959c03ffaec3 Mon Sep 17 00:00:00 2001 From: Ilyas Niyazov Date: Mon, 13 May 2024 13:34:37 +0300 Subject: [PATCH] [#220] add container metrics --- src/frostfs_testlib/storage/cluster.py | 3 +++ .../storage/dataclasses/metrics.py | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/frostfs_testlib/storage/dataclasses/metrics.py diff --git a/src/frostfs_testlib/storage/cluster.py b/src/frostfs_testlib/storage/cluster.py index 15827cf..9fcc4c9 100644 --- a/src/frostfs_testlib/storage/cluster.py +++ b/src/frostfs_testlib/storage/cluster.py @@ -14,6 +14,7 @@ from frostfs_testlib.storage.dataclasses.frostfs_services import HTTPGate, Inner from frostfs_testlib.storage.dataclasses.node_base import NodeBase, ServiceClass from frostfs_testlib.storage.dataclasses.storage_object_info import Interfaces from frostfs_testlib.storage.service_registry import ServiceRegistry +from frostfs_testlib.storage.dataclasses.metrics import Metrics class ClusterNode: @@ -24,11 +25,13 @@ class ClusterNode: class_registry: ServiceRegistry id: int host: Host + metrics: Metrics def __init__(self, host: Host, id: int) -> None: self.host = host self.id = id self.class_registry = get_service_registry() + self.metrics = Metrics(host=self.host, metrics_endpoint=self.storage_node.get_metrics_endpoint()) @property def host_ip(self): diff --git a/src/frostfs_testlib/storage/dataclasses/metrics.py b/src/frostfs_testlib/storage/dataclasses/metrics.py new file mode 100644 index 0000000..49c59bc --- /dev/null +++ b/src/frostfs_testlib/storage/dataclasses/metrics.py @@ -0,0 +1,22 @@ +from frostfs_testlib.hosting import Host +from frostfs_testlib.shell.interfaces import CommandResult + + +class Metrics: + def __init__(self, host: Host, metrics_endpoint: str) -> None: + self.storage = StorageMetrics(host, metrics_endpoint) + + + +class StorageMetrics: + """ + Class represents storage metrics in a cluster + """ + def __init__(self, host: Host, metrics_endpoint: str) -> None: + self.host = host + self.metrics_endpoint = metrics_endpoint + + def get_metric_container(self, metric: str, cid: str) -> CommandResult: + shell = self.host.get_shell() + result = shell.exec(f"curl -s {self.metrics_endpoint} | grep {metric} |grep {cid}") + return result