From 2d042e2387d62f5fc0412007ada20e83ccc84925 Mon Sep 17 00:00:00 2001 From: Dmitriy Zayakin Date: Thu, 21 Mar 2024 14:51:18 +0300 Subject: [PATCH] [#212] Fix error shard test Signed-off-by: Dmitriy Zayakin --- .../testsuites/shard/test_control_shard.py | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pytest_tests/testsuites/shard/test_control_shard.py b/pytest_tests/testsuites/shard/test_control_shard.py index 79f195b2..3b96a5e4 100644 --- a/pytest_tests/testsuites/shard/test_control_shard.py +++ b/pytest_tests/testsuites/shard/test_control_shard.py @@ -13,7 +13,7 @@ from frostfs_testlib.storage.controllers import ClusterStateController, ShardsWa from frostfs_testlib.storage.controllers.state_managers.config_state_manager import ConfigStateManager from frostfs_testlib.storage.dataclasses.shard import Shard from frostfs_testlib.storage.dataclasses.wallet import WalletInfo -from frostfs_testlib.testing import parallel +from frostfs_testlib.testing import parallel, wait_for_success from frostfs_testlib.testing.cluster_test_base import ClusterTestBase from frostfs_testlib.utils.file_utils import generate_file @@ -21,18 +21,25 @@ from frostfs_testlib.utils.file_utils import generate_file @pytest.mark.shard class TestControlShard(ClusterTestBase): @staticmethod + @wait_for_success(180, 30) def get_object_path_and_name_file(oid: str, cid: str, node: ClusterNode) -> tuple[str, str]: oid_path = f"{oid[0]}/{oid[1]}/{oid[2]}/{oid[3]}" + object_path = None + with reporter.step("Search object file"): node_shell = node.storage_node.host.get_shell() data_path = node.storage_node.get_data_directory() - all_datas = node_shell.exec(f"ls -la {data_path} | awk '{{ print $9 }}'").stdout.strip() - for data in all_datas.replace(".", "").strip().split("\n"): - check_dir = node_shell.exec(f" [ -d {data_path}/{data}/{oid_path} ] && echo 1 || echo 0").stdout + all_datas = node_shell.exec(f"ls -la {data_path}/data | awk '{{ print $9 }}'").stdout.strip() + for data_dir in all_datas.replace(".", "").strip().split("\n"): + check_dir = node_shell.exec( + f" [ -d {data_path}/data/{data_dir}/data/{oid_path} ] && echo 1 || echo 0" + ).stdout if "1" in check_dir: - object_path = f"{data_path}/{data}/{oid_path}" + object_path = f"{data_path}/data/{data_dir}/data/{oid_path}" object_name = f"{oid[4:]}.{cid}" break + + assert object_path is not None, f"{oid} object not found in directory - {data_path}/data" return object_path, object_name def set_shard_rw_mode(self, node: ClusterNode): @@ -49,7 +56,7 @@ class TestControlShard(ClusterTestBase): parallel(self.set_shard_rw_mode, self.cluster.cluster_nodes) @pytest.fixture() - def oid_cid_node(self, default_wallet: WalletInfo) -> tuple[str, str, ClusterNode]: + def oid_cid_node(self, default_wallet: WalletInfo, max_object_size: int) -> tuple[str, str, ClusterNode]: with reporter.step("Create container, and put object"): cid = create_container( wallet=default_wallet, @@ -58,7 +65,7 @@ class TestControlShard(ClusterTestBase): rule="REP 1 CBF 1", basic_acl=EACL_PUBLIC_READ_WRITE, ) - file = generate_file(5242880) + file = generate_file(round(max_object_size * 0.8)) oid = put_object( wallet=default_wallet, path=file, cid=cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint ) @@ -119,7 +126,8 @@ class TestControlShard(ClusterTestBase): revert_all_shards_mode: None, ): oid, cid, node = oid_cid_node - object_path, object_name = self.get_object_path_and_name_file(*oid_cid_node) + with reporter.step("Search object in system."): + object_path, object_name = self.get_object_path_and_name_file(*oid_cid_node) with reporter.step("Block read file"): node.host.get_shell().exec(f"chmod a-r {object_path}/{object_name}") with reporter.step("Get object, expect 6 errors"):