forked from TrueCloudLab/frostfs-testcases
[#312] Extend container metrics tests
This commit is contained in:
parent
77126f2706
commit
6b83a89b94
2 changed files with 52 additions and 4 deletions
|
@ -4,11 +4,11 @@ import allure
|
||||||
from frostfs_testlib.testing.parallel import parallel
|
from frostfs_testlib.testing.parallel import parallel
|
||||||
import pytest
|
import pytest
|
||||||
from frostfs_testlib import reporter
|
from frostfs_testlib import reporter
|
||||||
from frostfs_testlib.steps.cli.container import create_container, search_nodes_with_container
|
from frostfs_testlib.steps.cli.container import create_container, delete_container, search_nodes_with_container, wait_for_container_deletion
|
||||||
from frostfs_testlib.steps.cli.object import delete_object, head_object, put_object_to_random_node
|
from frostfs_testlib.steps.cli.object import delete_object, head_object, put_object_to_random_node
|
||||||
from frostfs_testlib.steps.metrics import check_metrics_counter, get_metrics_value
|
from frostfs_testlib.steps.metrics import calc_metrics_count_from_stdout, check_metrics_counter, get_metrics_value
|
||||||
from frostfs_testlib.steps.storage_policy import get_nodes_with_object
|
from frostfs_testlib.steps.storage_policy import get_nodes_with_object
|
||||||
from frostfs_testlib.storage.cluster import Cluster
|
from frostfs_testlib.storage.cluster import Cluster, ClusterNode
|
||||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||||
|
@ -24,6 +24,14 @@ class TestContainerMetrics(ClusterTestBase):
|
||||||
def put_object_parallel(self, file_path: str, wallet: WalletInfo, cid: str):
|
def put_object_parallel(self, file_path: str, wallet: WalletInfo, cid: str):
|
||||||
oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster)
|
oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster)
|
||||||
return oid
|
return oid
|
||||||
|
|
||||||
|
@reporter.step("Get metrics value from node")
|
||||||
|
def get_metrics_search_by_greps_parallel(self, node: ClusterNode, **greps):
|
||||||
|
try:
|
||||||
|
content_stdout = node.metrics.storage.get_metrics_search_by_greps(greps)
|
||||||
|
return calc_metrics_count_from_stdout(content_stdout)
|
||||||
|
except Exception as e:
|
||||||
|
return None
|
||||||
|
|
||||||
@allure.title("Container metrics (obj_size={object_size},policy={policy})")
|
@allure.title("Container metrics (obj_size={object_size},policy={policy})")
|
||||||
@pytest.mark.parametrize("placement_policy, policy", [("REP 2 IN X CBF 2 SELECT 2 FROM * AS X", "REP"), ("EC 1.1 CBF 1", "EC")])
|
@pytest.mark.parametrize("placement_policy, policy", [("REP 2 IN X CBF 2 SELECT 2 FROM * AS X", "REP"), ("EC 1.1 CBF 1", "EC")])
|
||||||
|
@ -164,3 +172,43 @@ class TestContainerMetrics(ClusterTestBase):
|
||||||
for act_metric in metrics_value_nodes:
|
for act_metric in metrics_value_nodes:
|
||||||
assert act_metric >= 0, "Metrics value is negative"
|
assert act_metric >= 0, "Metrics value is negative"
|
||||||
assert sum(metrics_value_nodes) // len(self.cluster.cluster_nodes) == tombstones_size, "tomstone size of objects not correct"
|
assert sum(metrics_value_nodes) // len(self.cluster.cluster_nodes) == tombstones_size, "tomstone size of objects not correct"
|
||||||
|
|
||||||
|
|
||||||
|
@allure.title("Container metrics (policy={policy})")
|
||||||
|
@pytest.mark.parametrize("placement_policy, policy", [("REP 2 IN X CBF 2 SELECT 2 FROM * AS X", "REP"), ("EC 1.1 CBF 1", "EC")])
|
||||||
|
def test_container_metrics_delete_complex_objects(
|
||||||
|
self,
|
||||||
|
complex_object_size: ObjectSize,
|
||||||
|
default_wallet: WalletInfo,
|
||||||
|
cluster: Cluster,
|
||||||
|
placement_policy: str,
|
||||||
|
policy: str
|
||||||
|
):
|
||||||
|
copies = 2 if policy == "REP" else 1
|
||||||
|
objects_count = 2
|
||||||
|
metric_name = "frostfs_node_engine_container_objects_total"
|
||||||
|
with reporter.step(f"Create container"):
|
||||||
|
cid = create_container(default_wallet, self.shell, cluster.default_rpc_endpoint, rule=placement_policy)
|
||||||
|
|
||||||
|
with reporter.step(f"Put {objects_count} objects"):
|
||||||
|
files_path = [generate_file(complex_object_size.value) for _ in range(objects_count)]
|
||||||
|
futures = parallel(self.put_object_parallel, files_path, wallet=default_wallet, cid=cid)
|
||||||
|
oids = [future.result() for future in futures]
|
||||||
|
|
||||||
|
with reporter.step(f"Check metrics value in each nodes, should be {objects_count} for 'user'"):
|
||||||
|
check_metrics_counter(cluster.cluster_nodes, counter_exp=objects_count * copies, command=metric_name, cid=cid, type="user")
|
||||||
|
|
||||||
|
with reporter.step("Delete objects and container"):
|
||||||
|
for oid in oids:
|
||||||
|
delete_object(default_wallet, cid, oid, self.shell, cluster.default_rpc_endpoint)
|
||||||
|
|
||||||
|
delete_container(default_wallet, cid, self.shell, cluster.default_rpc_endpoint)
|
||||||
|
|
||||||
|
with reporter.step("Tick epoch and check container was deleted"):
|
||||||
|
self.tick_epoch()
|
||||||
|
wait_for_container_deletion(default_wallet, cid, shell=self.shell, endpoint=cluster.default_rpc_endpoint)
|
||||||
|
|
||||||
|
with reporter.step(f"Check metrics value in each nodes, should not be show any result"):
|
||||||
|
futures = parallel(self.get_metrics_search_by_greps_parallel, cluster.cluster_nodes, command=metric_name, cid=cid)
|
||||||
|
metrics_results = [future.result() for future in futures if future.result() is not None]
|
||||||
|
assert len(metrics_results) == 0, f"Metrics value is not empty in Prometheus, actual value in nodes: {metrics_results}"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
allure-pytest==2.13.2
|
allure-pytest==2.13.2
|
||||||
allure-python-commons==2.13.2
|
allure-python-commons==2.13.2
|
||||||
base58==2.1.0
|
base58==2.1.0
|
||||||
boto3==1.16.33
|
boto3==1.35.30
|
||||||
botocore==1.19.33
|
botocore==1.19.33
|
||||||
configobj==5.0.6
|
configobj==5.0.6
|
||||||
neo-mamba==1.0.0
|
neo-mamba==1.0.0
|
||||||
|
|
Loading…
Reference in a new issue