2022-07-08 17:24:55 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.resources.wellknown_acl import PRIVATE_ACL_F
|
|
|
|
from frostfs_testlib.steps.cli.container import (
|
2022-09-28 12:07:16 +00:00
|
|
|
create_container,
|
|
|
|
delete_container,
|
|
|
|
get_container,
|
|
|
|
list_containers,
|
|
|
|
wait_for_container_creation,
|
|
|
|
wait_for_container_deletion,
|
|
|
|
)
|
2024-03-11 16:34:54 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
|
|
|
|
2024-10-29 10:32:07 +00:00
|
|
|
from ...helpers.utility import placement_policy_from_container
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2024-10-11 09:30:23 +00:00
|
|
|
@pytest.mark.nightly
|
2022-07-08 17:24:55 +00:00
|
|
|
@pytest.mark.sanity
|
2024-10-11 09:30:23 +00:00
|
|
|
@pytest.mark.container
|
2022-12-05 22:31:45 +00:00
|
|
|
class TestContainer(ClusterTestBase):
|
2024-11-16 11:33:56 +00:00
|
|
|
PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 2 FROM * AS X"
|
|
|
|
|
2024-08-12 09:56:33 +00:00
|
|
|
@allure.title("Create container (name={name})")
|
2022-12-05 22:31:45 +00:00
|
|
|
@pytest.mark.parametrize("name", ["", "test-container"], ids=["No name", "Set particular name"])
|
|
|
|
@pytest.mark.smoke
|
2024-11-16 11:33:56 +00:00
|
|
|
def test_container_creation(self, default_wallet: WalletInfo, name: str, rpc_endpoint: str):
|
2022-12-05 22:31:45 +00:00
|
|
|
wallet = default_wallet
|
|
|
|
|
2024-11-16 11:33:56 +00:00
|
|
|
cid = create_container(wallet, self.shell, rpc_endpoint, self.PLACEMENT_RULE, name=name)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2024-11-16 11:33:56 +00:00
|
|
|
containers = list_containers(wallet, self.shell, rpc_endpoint)
|
2022-12-05 22:31:45 +00:00
|
|
|
assert cid in containers, f"Expected container {cid} in containers: {containers}"
|
|
|
|
|
2024-11-16 11:33:56 +00:00
|
|
|
container_info: str = get_container(wallet, cid, self.shell, rpc_endpoint, False)
|
2023-11-01 07:43:43 +00:00
|
|
|
container_info = container_info.casefold() # To ignore case when comparing with expected values
|
2022-12-05 22:31:45 +00:00
|
|
|
|
|
|
|
info_to_check = {
|
|
|
|
f"basic ACL: {PRIVATE_ACL_F} (private)",
|
2024-03-11 16:34:54 +00:00
|
|
|
f"owner ID: {wallet.get_address_from_json(0)}",
|
2024-02-09 08:08:16 +00:00
|
|
|
f"CID: {cid}",
|
2022-12-05 22:31:45 +00:00
|
|
|
}
|
|
|
|
if name:
|
|
|
|
info_to_check.add(f"Name={name}")
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check container has correct information"):
|
2024-11-16 11:33:56 +00:00
|
|
|
expected_policy = self.PLACEMENT_RULE.casefold()
|
2022-12-05 22:31:45 +00:00
|
|
|
actual_policy = placement_policy_from_container(container_info)
|
2024-08-12 09:56:33 +00:00
|
|
|
assert actual_policy == expected_policy, f"Expected policy\n{expected_policy} but got policy\n{actual_policy}"
|
2022-12-05 22:31:45 +00:00
|
|
|
|
|
|
|
for info in info_to_check:
|
|
|
|
expected_info = info.casefold()
|
2023-11-01 07:43:43 +00:00
|
|
|
assert expected_info in container_info, f"Expected {expected_info} in container info:\n{container_info}"
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Delete container and check it was deleted"):
|
2024-11-16 11:33:56 +00:00
|
|
|
# Force to skip frostfs-cli verifictions before delete.
|
|
|
|
# Because no APE rules assigned to container, those verifications will fail due to APE requests denial.
|
|
|
|
delete_container(wallet, cid, self.shell, rpc_endpoint, force=True, await_mode=True)
|
|
|
|
self.tick_epoch()
|
|
|
|
wait_for_container_deletion(wallet, cid, self.shell, rpc_endpoint)
|
|
|
|
|
|
|
|
@allure.title("Delete container without force (name={name})")
|
|
|
|
@pytest.mark.smoke
|
|
|
|
def test_container_deletion_no_force(self, container: str, default_wallet: WalletInfo, rpc_endpoint: str):
|
|
|
|
with reporter.step("Delete container and check it was deleted"):
|
|
|
|
delete_container(default_wallet, container, self.shell, rpc_endpoint, await_mode=True)
|
2022-12-23 11:42:41 +00:00
|
|
|
self.tick_epoch()
|
2024-11-16 11:33:56 +00:00
|
|
|
wait_for_container_deletion(default_wallet, container, self.shell, rpc_endpoint)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
@allure.title("Parallel container creation and deletion")
|
2024-11-16 11:33:56 +00:00
|
|
|
def test_container_creation_deletion_parallel(self, default_wallet: WalletInfo, rpc_endpoint: str):
|
2022-12-05 22:31:45 +00:00
|
|
|
containers_count = 3
|
|
|
|
wallet = default_wallet
|
2023-12-20 12:00:53 +00:00
|
|
|
iteration_count = 10
|
|
|
|
|
2024-11-16 11:33:56 +00:00
|
|
|
for _ in range(iteration_count):
|
2023-12-20 12:00:53 +00:00
|
|
|
cids: list[str] = []
|
|
|
|
with reporter.step(f"Create {containers_count} containers"):
|
|
|
|
for _ in range(containers_count):
|
|
|
|
cids.append(
|
2024-11-16 11:33:56 +00:00
|
|
|
create_container(wallet, self.shell, rpc_endpoint, self.PLACEMENT_RULE, await_mode=False, wait_for_creation=False)
|
2023-12-20 12:00:53 +00:00
|
|
|
)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-12-20 12:00:53 +00:00
|
|
|
with reporter.step("Wait for containers occur in container list"):
|
|
|
|
for cid in cids:
|
2024-11-16 11:33:56 +00:00
|
|
|
wait_for_container_creation(wallet, cid, self.shell, rpc_endpoint, sleep_interval=containers_count)
|
2023-12-20 12:00:53 +00:00
|
|
|
|
|
|
|
with reporter.step("Delete containers and check they were deleted"):
|
|
|
|
for cid in cids:
|
2024-11-16 11:33:56 +00:00
|
|
|
# Force to skip frostfs-cli verifictions before delete.
|
|
|
|
# Because no APE rules assigned to container, those verifications will fail due to APE requests denial.
|
|
|
|
delete_container(wallet, cid, self.shell, rpc_endpoint, force=True, await_mode=True)
|
|
|
|
containers_list = list_containers(wallet, self.shell, rpc_endpoint)
|
2024-02-09 08:08:16 +00:00
|
|
|
assert cid not in containers_list, "Container not deleted"
|