forked from TrueCloudLab/frostfs-testcases
[#212] Fix error shard test
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
3e878444ce
commit
2d042e2387
1 changed files with 16 additions and 8 deletions
|
@ -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.controllers.state_managers.config_state_manager import ConfigStateManager
|
||||||
from frostfs_testlib.storage.dataclasses.shard import Shard
|
from frostfs_testlib.storage.dataclasses.shard import Shard
|
||||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
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.testing.cluster_test_base import ClusterTestBase
|
||||||
from frostfs_testlib.utils.file_utils import generate_file
|
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
|
@pytest.mark.shard
|
||||||
class TestControlShard(ClusterTestBase):
|
class TestControlShard(ClusterTestBase):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@wait_for_success(180, 30)
|
||||||
def get_object_path_and_name_file(oid: str, cid: str, node: ClusterNode) -> tuple[str, str]:
|
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]}"
|
oid_path = f"{oid[0]}/{oid[1]}/{oid[2]}/{oid[3]}"
|
||||||
|
object_path = None
|
||||||
|
|
||||||
with reporter.step("Search object file"):
|
with reporter.step("Search object file"):
|
||||||
node_shell = node.storage_node.host.get_shell()
|
node_shell = node.storage_node.host.get_shell()
|
||||||
data_path = node.storage_node.get_data_directory()
|
data_path = node.storage_node.get_data_directory()
|
||||||
all_datas = node_shell.exec(f"ls -la {data_path} | awk '{{ print $9 }}'").stdout.strip()
|
all_datas = node_shell.exec(f"ls -la {data_path}/data | awk '{{ print $9 }}'").stdout.strip()
|
||||||
for data in all_datas.replace(".", "").strip().split("\n"):
|
for data_dir in all_datas.replace(".", "").strip().split("\n"):
|
||||||
check_dir = node_shell.exec(f" [ -d {data_path}/{data}/{oid_path} ] && echo 1 || echo 0").stdout
|
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:
|
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}"
|
object_name = f"{oid[4:]}.{cid}"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
assert object_path is not None, f"{oid} object not found in directory - {data_path}/data"
|
||||||
return object_path, object_name
|
return object_path, object_name
|
||||||
|
|
||||||
def set_shard_rw_mode(self, node: ClusterNode):
|
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)
|
parallel(self.set_shard_rw_mode, self.cluster.cluster_nodes)
|
||||||
|
|
||||||
@pytest.fixture()
|
@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"):
|
with reporter.step("Create container, and put object"):
|
||||||
cid = create_container(
|
cid = create_container(
|
||||||
wallet=default_wallet,
|
wallet=default_wallet,
|
||||||
|
@ -58,7 +65,7 @@ class TestControlShard(ClusterTestBase):
|
||||||
rule="REP 1 CBF 1",
|
rule="REP 1 CBF 1",
|
||||||
basic_acl=EACL_PUBLIC_READ_WRITE,
|
basic_acl=EACL_PUBLIC_READ_WRITE,
|
||||||
)
|
)
|
||||||
file = generate_file(5242880)
|
file = generate_file(round(max_object_size * 0.8))
|
||||||
oid = put_object(
|
oid = put_object(
|
||||||
wallet=default_wallet, path=file, cid=cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint
|
wallet=default_wallet, path=file, cid=cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint
|
||||||
)
|
)
|
||||||
|
@ -119,6 +126,7 @@ class TestControlShard(ClusterTestBase):
|
||||||
revert_all_shards_mode: None,
|
revert_all_shards_mode: None,
|
||||||
):
|
):
|
||||||
oid, cid, node = oid_cid_node
|
oid, cid, node = oid_cid_node
|
||||||
|
with reporter.step("Search object in system."):
|
||||||
object_path, object_name = self.get_object_path_and_name_file(*oid_cid_node)
|
object_path, object_name = self.get_object_path_and_name_file(*oid_cid_node)
|
||||||
with reporter.step("Block read file"):
|
with reporter.step("Block read file"):
|
||||||
node.host.get_shell().exec(f"chmod a-r {object_path}/{object_name}")
|
node.host.get_shell().exec(f"chmod a-r {object_path}/{object_name}")
|
||||||
|
|
Loading…
Reference in a new issue