2022-11-25 12:44:47 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2024-11-16 11:31:05 +00:00
|
|
|
from frostfs_testlib.cli.frostfs_cli.cli import FrostfsCli
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.resources.common import STORAGE_GC_TIME
|
|
|
|
from frostfs_testlib.resources.error_patterns import (
|
2022-11-25 12:44:47 +00:00
|
|
|
LIFETIME_REQUIRED,
|
|
|
|
LOCK_NON_REGULAR_OBJECT,
|
|
|
|
LOCK_OBJECT_EXPIRATION,
|
|
|
|
LOCK_OBJECT_REMOVAL,
|
|
|
|
OBJECT_IS_LOCKED,
|
|
|
|
OBJECT_NOT_FOUND,
|
|
|
|
)
|
2023-02-17 15:12:11 +00:00
|
|
|
from frostfs_testlib.shell import Shell
|
2024-11-13 14:50:31 +00:00
|
|
|
from frostfs_testlib.steps.cli.container import StorageContainer, StorageContainerInfo
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.steps.cli.object import delete_object, head_object, lock_object
|
|
|
|
from frostfs_testlib.steps.complex_object_actions import get_link_object, get_storage_object_chunks
|
2024-11-13 14:50:31 +00:00
|
|
|
from frostfs_testlib.steps.epoch import ensure_fresh_epoch
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.steps.node_management import drop_object
|
|
|
|
from frostfs_testlib.steps.storage_object import delete_objects
|
|
|
|
from frostfs_testlib.steps.storage_policy import get_nodes_with_object
|
|
|
|
from frostfs_testlib.storage.cluster import Cluster
|
2023-08-02 11:54:03 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
2023-11-15 06:54:57 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.storage_object_info import LockObjectInfo, StorageObjectInfo
|
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
|
|
|
|
from frostfs_testlib.testing.test_control import expect_not_raises, wait_for_success
|
2024-11-16 11:31:05 +00:00
|
|
|
from frostfs_testlib.utils import datetime_utils
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2024-11-16 11:31:05 +00:00
|
|
|
from ...helpers.container_creation import create_container_with_ape
|
|
|
|
from ...helpers.container_request import EVERYONE_ALLOW_ALL
|
2024-10-29 10:32:07 +00:00
|
|
|
from ...helpers.utility import wait_for_gc_pass_on_storage_nodes
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger("NeoLogger")
|
|
|
|
|
|
|
|
FIXTURE_LOCK_LIFETIME = 5
|
|
|
|
FIXTURE_OBJECT_LIFETIME = 10
|
|
|
|
|
|
|
|
|
2024-03-11 16:34:54 +00:00
|
|
|
@pytest.fixture(scope="module")
|
2024-11-16 11:31:05 +00:00
|
|
|
def user_container(
|
|
|
|
frostfs_cli: FrostfsCli, default_wallet: WalletInfo, client_shell: Shell, cluster: Cluster, rpc_endpoint: str
|
|
|
|
) -> StorageContainer:
|
|
|
|
cid = create_container_with_ape(frostfs_cli, default_wallet, client_shell, cluster, rpc_endpoint, EVERYONE_ALLOW_ALL)
|
|
|
|
return StorageContainer(StorageContainerInfo(cid, default_wallet), client_shell, cluster)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
|
2024-03-11 16:34:54 +00:00
|
|
|
@pytest.fixture(scope="module")
|
2024-11-16 11:31:05 +00:00
|
|
|
def locked_storage_object(user_container: StorageContainer, client_shell: Shell, cluster: Cluster, object_size: ObjectSize):
|
2022-12-12 08:51:11 +00:00
|
|
|
"""
|
|
|
|
Intention of this fixture is to provide storage object which is NOT expected to be deleted during test act phase
|
|
|
|
"""
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Creating locked object"):
|
2024-11-16 11:31:05 +00:00
|
|
|
current_epoch = ensure_fresh_epoch(client_shell, cluster)
|
2022-11-25 12:44:47 +00:00
|
|
|
expiration_epoch = current_epoch + FIXTURE_LOCK_LIFETIME
|
|
|
|
|
2024-10-07 14:34:07 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + FIXTURE_OBJECT_LIFETIME)
|
2022-11-25 12:44:47 +00:00
|
|
|
lock_object_id = lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
client_shell,
|
2022-12-05 22:31:45 +00:00
|
|
|
cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
lifetime=FIXTURE_LOCK_LIFETIME,
|
|
|
|
)
|
2024-10-07 14:34:07 +00:00
|
|
|
storage_object.locks = [LockObjectInfo(storage_object.cid, lock_object_id, FIXTURE_LOCK_LIFETIME, expiration_epoch)]
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2024-11-13 14:50:31 +00:00
|
|
|
return storage_object
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
|
2023-08-30 11:38:03 +00:00
|
|
|
@wait_for_success(datetime_utils.parse_time(STORAGE_GC_TIME))
|
2024-03-11 16:34:54 +00:00
|
|
|
def check_object_not_found(wallet: WalletInfo, cid: str, oid: str, shell: Shell, rpc_endpoint: str):
|
2023-08-30 11:38:03 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
2024-11-16 11:31:05 +00:00
|
|
|
head_object(wallet, cid, oid, shell, rpc_endpoint)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2024-03-11 16:34:54 +00:00
|
|
|
def verify_object_available(wallet: WalletInfo, cid: str, oid: str, shell: Shell, rpc_endpoint: str):
|
2023-08-30 11:38:03 +00:00
|
|
|
with expect_not_raises():
|
2024-11-16 11:31:05 +00:00
|
|
|
head_object(wallet, cid, oid, shell, rpc_endpoint)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2024-10-11 09:30:23 +00:00
|
|
|
@pytest.mark.nightly
|
2024-11-16 11:31:05 +00:00
|
|
|
@pytest.mark.grpc_api
|
2022-11-25 12:44:47 +00:00
|
|
|
@pytest.mark.grpc_object_lock
|
2022-12-05 22:31:45 +00:00
|
|
|
class TestObjectLockWithGrpc(ClusterTestBase):
|
2022-12-12 08:51:11 +00:00
|
|
|
@pytest.fixture()
|
2023-11-15 06:54:57 +00:00
|
|
|
def new_locked_storage_object(self, user_container: StorageContainer, object_size: ObjectSize) -> StorageObjectInfo:
|
2022-12-12 08:51:11 +00:00
|
|
|
"""
|
|
|
|
Intention of this fixture is to provide new storage object for tests which may delete or corrupt the object or it's complementary objects
|
|
|
|
So we need a new one each time we ask for it
|
|
|
|
"""
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Creating locked object"):
|
2022-12-12 08:51:11 +00:00
|
|
|
current_epoch = self.get_epoch()
|
|
|
|
|
2024-10-07 14:34:07 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + FIXTURE_OBJECT_LIFETIME)
|
2022-12-12 08:51:11 +00:00
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-12-12 08:51:11 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
lifetime=FIXTURE_LOCK_LIFETIME,
|
|
|
|
)
|
|
|
|
|
|
|
|
return storage_object
|
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Locked object is protected from deletion (obj_size={object_size})")
|
2022-11-25 12:44:47 +00:00
|
|
|
def test_locked_object_cannot_be_deleted(
|
|
|
|
self,
|
|
|
|
locked_storage_object: StorageObjectInfo,
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Locked object should be protected from deletion
|
|
|
|
"""
|
|
|
|
with pytest.raises(Exception, match=OBJECT_IS_LOCKED):
|
|
|
|
delete_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
locked_storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
locked_storage_object.cid,
|
|
|
|
locked_storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Lock object itself is protected from deletion")
|
2022-11-25 12:44:47 +00:00
|
|
|
# We operate with only lock object here so no complex object needed in this test
|
2023-09-08 10:35:34 +00:00
|
|
|
@pytest.mark.parametrize("object_size", ["simple"], indirect=True)
|
2022-11-25 12:44:47 +00:00
|
|
|
def test_lock_object_itself_cannot_be_deleted(
|
|
|
|
self,
|
|
|
|
locked_storage_object: StorageObjectInfo,
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Lock object itself should be protected from deletion
|
|
|
|
"""
|
|
|
|
|
|
|
|
lock_object = locked_storage_object.locks[0]
|
2024-03-11 16:34:54 +00:00
|
|
|
wallet_path = locked_storage_object.wallet
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
with pytest.raises(Exception, match=LOCK_OBJECT_REMOVAL):
|
2022-12-05 22:31:45 +00:00
|
|
|
delete_object(
|
|
|
|
wallet_path,
|
|
|
|
lock_object.cid,
|
|
|
|
lock_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
@allure.title("Lock object itself cannot be locked")
|
|
|
|
# We operate with only lock object here so no complex object needed in this test
|
2023-09-08 10:35:34 +00:00
|
|
|
@pytest.mark.parametrize("object_size", ["simple"], indirect=True)
|
2022-11-25 12:44:47 +00:00
|
|
|
def test_lock_object_cannot_be_locked(
|
|
|
|
self,
|
|
|
|
locked_storage_object: StorageObjectInfo,
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Lock object itself cannot be locked
|
|
|
|
"""
|
|
|
|
|
|
|
|
lock_object_info = locked_storage_object.locks[0]
|
2024-03-11 16:34:54 +00:00
|
|
|
wallet_path = locked_storage_object.wallet
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
with pytest.raises(Exception, match=LOCK_NON_REGULAR_OBJECT):
|
2022-12-05 22:31:45 +00:00
|
|
|
lock_object(
|
|
|
|
wallet_path,
|
|
|
|
lock_object_info.cid,
|
|
|
|
lock_object_info.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
1,
|
|
|
|
)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2024-10-07 14:34:07 +00:00
|
|
|
@allure.title("Lock must contain valid lifetime or expire_at field: (lifetime={wrong_lifetime}, expire-at={wrong_expire_at})")
|
2022-11-25 12:44:47 +00:00
|
|
|
# We operate with only lock object here so no complex object needed in this test
|
2023-09-08 10:35:34 +00:00
|
|
|
@pytest.mark.parametrize("object_size", ["simple"], indirect=True)
|
2022-11-25 12:44:47 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"wrong_lifetime,wrong_expire_at,expected_error",
|
|
|
|
[
|
|
|
|
(None, None, LIFETIME_REQUIRED),
|
|
|
|
(0, 0, LIFETIME_REQUIRED),
|
|
|
|
(0, None, LIFETIME_REQUIRED),
|
|
|
|
(None, 0, LIFETIME_REQUIRED),
|
|
|
|
(-1, None, 'invalid argument "-1" for "--lifetime" flag'),
|
|
|
|
(None, -1, 'invalid argument "-1" for "-e, --expire-at" flag'),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_cannot_lock_object_without_lifetime(
|
|
|
|
self,
|
|
|
|
locked_storage_object: StorageObjectInfo,
|
|
|
|
wrong_lifetime: int,
|
|
|
|
wrong_expire_at: int,
|
|
|
|
expected_error: str,
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Cannot lock object without lifetime and expire_at fields
|
|
|
|
"""
|
|
|
|
|
|
|
|
lock_object_info = locked_storage_object.locks[0]
|
2024-03-11 16:34:54 +00:00
|
|
|
wallet_path = locked_storage_object.wallet
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
with pytest.raises(Exception, match=expected_error):
|
|
|
|
lock_object(
|
|
|
|
wallet_path,
|
|
|
|
lock_object_info.cid,
|
|
|
|
lock_object_info.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
lifetime=wrong_lifetime,
|
|
|
|
expire_at=wrong_expire_at,
|
|
|
|
)
|
|
|
|
|
2023-11-15 06:54:57 +00:00
|
|
|
@pytest.mark.sanity
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Expired object is deleted when locks are expired (obj_size={object_size})")
|
2022-11-25 12:44:47 +00:00
|
|
|
def test_expired_object_should_be_deleted_after_locks_are_expired(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
2023-08-02 11:54:03 +00:00
|
|
|
object_size: ObjectSize,
|
2022-11-25 12:44:47 +00:00
|
|
|
):
|
|
|
|
"""
|
|
|
|
Expired object should be deleted after locks are expired
|
|
|
|
"""
|
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
current_epoch = self.ensure_fresh_epoch()
|
2023-11-15 06:54:57 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + 1)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Lock object for couple epochs"):
|
2022-11-25 12:44:47 +00:00
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-12-23 18:40:30 +00:00
|
|
|
lifetime=2,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-12-23 18:40:30 +00:00
|
|
|
expire_at=current_epoch + 2,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check object is not deleted at expiration time"):
|
2022-12-23 18:40:30 +00:00
|
|
|
self.tick_epochs(2)
|
2022-11-25 12:44:47 +00:00
|
|
|
# Must wait to ensure object is not deleted
|
|
|
|
wait_for_gc_pass_on_storage_nodes()
|
|
|
|
with expect_not_raises():
|
|
|
|
head_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Wait for object to be deleted after third epoch"):
|
2022-12-05 22:31:45 +00:00
|
|
|
self.tick_epoch()
|
2023-09-08 10:35:34 +00:00
|
|
|
check_object_not_found(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-09-08 10:35:34 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Lock multiple objects at once (obj_size={object_size})")
|
2022-11-25 12:44:47 +00:00
|
|
|
def test_should_be_possible_to_lock_multiple_objects_at_once(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
2023-08-02 11:54:03 +00:00
|
|
|
object_size: ObjectSize,
|
2022-11-25 12:44:47 +00:00
|
|
|
):
|
|
|
|
"""
|
|
|
|
Should be possible to lock multiple objects at once
|
|
|
|
"""
|
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
current_epoch = ensure_fresh_epoch(self.shell, self.cluster)
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_objects: list[StorageObjectInfo] = []
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Generate three objects"):
|
2022-11-25 12:44:47 +00:00
|
|
|
for _ in range(3):
|
2023-11-15 06:54:57 +00:00
|
|
|
storage_objects.append(user_container.generate_object(object_size.value, expire_at=current_epoch + 5))
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_objects[0].wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_objects[0].cid,
|
|
|
|
",".join([storage_object.oid for storage_object in storage_objects]),
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
expire_at=current_epoch + 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
for storage_object in storage_objects:
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Try to delete object {storage_object.oid}"):
|
2022-11-25 12:44:47 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_IS_LOCKED):
|
|
|
|
delete_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick two epochs"):
|
2022-12-05 22:31:45 +00:00
|
|
|
self.tick_epoch()
|
|
|
|
self.tick_epoch()
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
with expect_not_raises():
|
2022-12-05 22:31:45 +00:00
|
|
|
delete_objects(storage_objects, self.shell, self.cluster)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Outdated lock cannot be applied (obj_size={object_size})")
|
2022-11-25 12:44:47 +00:00
|
|
|
def test_already_outdated_lock_should_not_be_applied(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
2023-08-02 11:54:03 +00:00
|
|
|
object_size: ObjectSize,
|
2022-11-25 12:44:47 +00:00
|
|
|
):
|
|
|
|
"""
|
|
|
|
Already outdated lock should not be applied
|
|
|
|
"""
|
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
current_epoch = self.ensure_fresh_epoch()
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-11-15 06:54:57 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + 1)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
expiration_epoch = current_epoch - 1
|
|
|
|
with pytest.raises(
|
|
|
|
Exception,
|
2023-11-15 06:54:57 +00:00
|
|
|
match=LOCK_OBJECT_EXPIRATION.format(expiration_epoch=expiration_epoch, current_epoch=current_epoch),
|
2022-11-25 12:44:47 +00:00
|
|
|
):
|
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
expire_at=expiration_epoch,
|
|
|
|
)
|
|
|
|
|
2023-11-15 06:54:57 +00:00
|
|
|
@pytest.mark.sanity
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Delete object when lock is expired by lifetime (obj_size={object_size})")
|
2022-11-25 12:44:47 +00:00
|
|
|
@expect_not_raises()
|
|
|
|
def test_after_lock_expiration_with_lifetime_user_should_be_able_to_delete_object(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
2023-08-02 11:54:03 +00:00
|
|
|
object_size: ObjectSize,
|
2022-11-25 12:44:47 +00:00
|
|
|
):
|
|
|
|
"""
|
|
|
|
After lock expiration with lifetime user should be able to delete object
|
|
|
|
"""
|
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
current_epoch = self.ensure_fresh_epoch()
|
2023-11-15 06:54:57 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + 5)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
lifetime=1,
|
|
|
|
)
|
|
|
|
|
2022-12-23 18:40:30 +00:00
|
|
|
self.tick_epochs(2)
|
2022-12-05 22:31:45 +00:00
|
|
|
with expect_not_raises():
|
|
|
|
delete_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Delete object when lock is expired by expire_at (obj_size={object_size})")
|
2022-11-25 12:44:47 +00:00
|
|
|
@expect_not_raises()
|
|
|
|
def test_after_lock_expiration_with_expire_at_user_should_be_able_to_delete_object(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
2023-08-02 11:54:03 +00:00
|
|
|
object_size: ObjectSize,
|
2022-11-25 12:44:47 +00:00
|
|
|
):
|
|
|
|
"""
|
|
|
|
After lock expiration with expire_at user should be able to delete object
|
|
|
|
"""
|
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
current_epoch = self.ensure_fresh_epoch()
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-11-15 06:54:57 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + 5)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
expire_at=current_epoch + 1,
|
|
|
|
)
|
|
|
|
|
2022-12-23 18:40:30 +00:00
|
|
|
self.tick_epochs(2)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
with expect_not_raises():
|
|
|
|
delete_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2022-11-25 12:44:47 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Complex object chunks are protected from deletion")
|
2022-11-25 12:44:47 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
# Only complex objects are required for this test
|
2023-09-08 10:35:34 +00:00
|
|
|
"object_size",
|
|
|
|
["complex"],
|
2022-11-25 12:44:47 +00:00
|
|
|
indirect=True,
|
|
|
|
)
|
|
|
|
def test_complex_object_chunks_should_also_be_protected_from_deletion(
|
|
|
|
self,
|
|
|
|
locked_storage_object: StorageObjectInfo,
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Complex object chunks should also be protected from deletion
|
|
|
|
"""
|
|
|
|
|
2023-11-15 06:54:57 +00:00
|
|
|
chunk_object_ids = get_storage_object_chunks(locked_storage_object, self.shell, self.cluster)
|
2022-11-25 12:44:47 +00:00
|
|
|
for chunk_object_id in chunk_object_ids:
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Try to delete chunk object {chunk_object_id}"):
|
2022-11-25 12:44:47 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_IS_LOCKED):
|
|
|
|
delete_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
locked_storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
locked_storage_object.cid,
|
|
|
|
chunk_object_id,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Drop link object of locked complex object")
|
2022-12-12 08:51:11 +00:00
|
|
|
@pytest.mark.grpc_control
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-08 10:35:34 +00:00
|
|
|
"object_size",
|
2022-12-12 08:51:11 +00:00
|
|
|
# Only complex object is required
|
2023-09-08 10:35:34 +00:00
|
|
|
["complex"],
|
2022-12-12 08:51:11 +00:00
|
|
|
indirect=True,
|
|
|
|
)
|
2023-11-15 06:54:57 +00:00
|
|
|
def test_link_object_of_locked_complex_object_can_be_dropped(self, new_locked_storage_object: StorageObjectInfo):
|
2022-12-12 08:51:11 +00:00
|
|
|
link_object_id = get_link_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
new_locked_storage_object.wallet,
|
2022-12-12 08:51:11 +00:00
|
|
|
new_locked_storage_object.cid,
|
|
|
|
new_locked_storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.storage_nodes,
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Drop link object with id {link_object_id} from nodes"):
|
2022-12-12 08:51:11 +00:00
|
|
|
nodes_with_object = get_nodes_with_object(
|
|
|
|
new_locked_storage_object.cid,
|
|
|
|
link_object_id,
|
|
|
|
shell=self.shell,
|
|
|
|
nodes=self.cluster.storage_nodes,
|
|
|
|
)
|
|
|
|
for node in nodes_with_object:
|
|
|
|
with expect_not_raises():
|
|
|
|
drop_object(node, new_locked_storage_object.cid, link_object_id)
|
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Drop chunks of locked complex object")
|
2022-12-12 08:51:11 +00:00
|
|
|
@pytest.mark.grpc_control
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-08 10:35:34 +00:00
|
|
|
"object_size",
|
2022-12-12 08:51:11 +00:00
|
|
|
# Only complex object is required
|
2023-09-08 10:35:34 +00:00
|
|
|
["complex"],
|
2022-12-12 08:51:11 +00:00
|
|
|
indirect=True,
|
|
|
|
)
|
2023-11-15 06:54:57 +00:00
|
|
|
def test_chunks_of_locked_complex_object_can_be_dropped(self, new_locked_storage_object: StorageObjectInfo):
|
|
|
|
chunk_objects = get_storage_object_chunks(new_locked_storage_object, self.shell, self.cluster)
|
2022-12-12 08:51:11 +00:00
|
|
|
|
|
|
|
for chunk_object_id in chunk_objects:
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Drop chunk object with id {chunk_object_id} from nodes"):
|
2022-12-12 08:51:11 +00:00
|
|
|
nodes_with_object = get_nodes_with_object(
|
|
|
|
new_locked_storage_object.cid,
|
|
|
|
chunk_object_id,
|
|
|
|
shell=self.shell,
|
|
|
|
nodes=self.cluster.storage_nodes,
|
|
|
|
)
|
|
|
|
for node in nodes_with_object:
|
|
|
|
with expect_not_raises():
|
|
|
|
drop_object(node, new_locked_storage_object.cid, chunk_object_id)
|
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Drop locked object (obj_size={object_size})")
|
2022-12-12 08:51:11 +00:00
|
|
|
@pytest.mark.grpc_control
|
2023-09-08 10:35:34 +00:00
|
|
|
def test_locked_object_can_be_dropped(self, new_locked_storage_object: StorageObjectInfo):
|
2022-12-12 08:51:11 +00:00
|
|
|
nodes_with_object = get_nodes_with_object(
|
|
|
|
new_locked_storage_object.cid,
|
|
|
|
new_locked_storage_object.oid,
|
|
|
|
shell=self.shell,
|
|
|
|
nodes=self.cluster.storage_nodes,
|
|
|
|
)
|
|
|
|
|
|
|
|
for node in nodes_with_object:
|
|
|
|
with expect_not_raises():
|
|
|
|
drop_object(node, new_locked_storage_object.cid, new_locked_storage_object.oid)
|
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Link object of complex object is protected from deletion")
|
2022-11-25 12:44:47 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
# Only complex objects are required for this test
|
2023-09-08 10:35:34 +00:00
|
|
|
"object_size",
|
|
|
|
["complex"],
|
2022-11-25 12:44:47 +00:00
|
|
|
indirect=True,
|
|
|
|
)
|
|
|
|
def test_link_object_of_complex_object_should_also_be_protected_from_deletion(
|
|
|
|
self,
|
|
|
|
locked_storage_object: StorageObjectInfo,
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Link object of complex object should also be protected from deletion
|
|
|
|
"""
|
|
|
|
|
|
|
|
link_object_id = get_link_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
locked_storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
locked_storage_object.cid,
|
|
|
|
locked_storage_object.oid,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.storage_nodes,
|
2022-11-25 12:44:47 +00:00
|
|
|
is_direct=False,
|
|
|
|
)
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Try to delete link object {link_object_id}"):
|
2022-11-25 12:44:47 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_IS_LOCKED):
|
|
|
|
delete_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
locked_storage_object.wallet,
|
2022-11-25 12:44:47 +00:00
|
|
|
locked_storage_object.cid,
|
|
|
|
link_object_id,
|
2022-12-05 22:31:45 +00:00
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
2022-11-25 12:44:47 +00:00
|
|
|
)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Expired object is removed after all locks are expired (obj_size={object_size})")
|
2023-08-30 11:38:03 +00:00
|
|
|
def test_expired_object_should_be_removed_after_relocks_expare_at(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
|
|
|
object_size: ObjectSize,
|
|
|
|
):
|
2023-09-08 10:35:34 +00:00
|
|
|
current_epoch = self.ensure_fresh_epoch()
|
2023-11-15 06:54:57 +00:00
|
|
|
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + 1)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Apply first lock to object for 3 epochs"):
|
2023-08-30 11:38:03 +00:00
|
|
|
lock_object_id_0 = lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
expire_at=current_epoch + 3,
|
|
|
|
)
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2023-08-30 11:38:03 +00:00
|
|
|
self.tick_epochs(2)
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check first lock is still available"):
|
2023-08-30 11:38:03 +00:00
|
|
|
verify_object_available(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
lock_object_id_0,
|
|
|
|
self.shell,
|
2023-09-08 10:35:34 +00:00
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Apply second lock to object for 3 more epochs"):
|
2023-08-30 11:38:03 +00:00
|
|
|
lock_object_id_1 = lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
expire_at=current_epoch + 5,
|
|
|
|
)
|
|
|
|
|
|
|
|
self.tick_epochs(2)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Verify first lock is expired and removed"):
|
2023-08-30 11:38:03 +00:00
|
|
|
check_object_not_found(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
lock_object_id_0,
|
|
|
|
self.shell,
|
2023-09-08 10:35:34 +00:00
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Verify second lock is still available"):
|
2023-08-30 11:38:03 +00:00
|
|
|
verify_object_available(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
lock_object_id_1,
|
|
|
|
self.shell,
|
2023-09-08 10:35:34 +00:00
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Apply third lock to object for 3 more epochs"):
|
2023-08-30 11:38:03 +00:00
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
expire_at=current_epoch + 7,
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Verify object is deleted after all locks are expired"):
|
2023-08-30 11:38:03 +00:00
|
|
|
self.tick_epochs(4)
|
|
|
|
check_object_not_found(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
2023-09-08 10:35:34 +00:00
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-11-15 06:54:57 +00:00
|
|
|
@pytest.mark.sanity
|
|
|
|
@allure.title("Two expired objects with one lock are deleted after lock expiration (obj_size={object_size})")
|
2023-08-30 11:38:03 +00:00
|
|
|
def test_two_objects_expiration_with_one_lock(
|
|
|
|
self,
|
|
|
|
user_container: StorageContainer,
|
|
|
|
object_size: ObjectSize,
|
|
|
|
):
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2023-08-30 11:38:03 +00:00
|
|
|
current_epoch = self.ensure_fresh_epoch()
|
|
|
|
storage_objects: list[StorageObjectInfo] = []
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Generate two objects"):
|
2023-08-30 11:38:03 +00:00
|
|
|
for epoch_i in range(2):
|
2024-10-07 14:34:07 +00:00
|
|
|
storage_objects.append(user_container.generate_object(object_size.value, expire_at=current_epoch + epoch_i + 3))
|
2023-08-30 11:38:03 +00:00
|
|
|
|
|
|
|
self.tick_epoch()
|
2023-09-08 10:35:34 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Lock objects for 4 epochs"):
|
2023-08-30 11:38:03 +00:00
|
|
|
lock_object(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_objects[0].wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_objects[0].cid,
|
|
|
|
",".join([storage_object.oid for storage_object in storage_objects]),
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
expire_at=current_epoch + 4,
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Verify objects are available during next three epochs"):
|
2023-08-30 11:38:03 +00:00
|
|
|
for epoch_i in range(3):
|
2023-09-08 10:35:34 +00:00
|
|
|
self.tick_epoch()
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Check objects at epoch {current_epoch + epoch_i + 2}"):
|
2023-09-08 10:35:34 +00:00
|
|
|
for storage_object in storage_objects:
|
|
|
|
verify_object_available(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-09-08 10:35:34 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
2023-08-30 11:38:03 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Verify objects are deleted after lock was expired"):
|
2023-08-30 11:38:03 +00:00
|
|
|
self.tick_epoch()
|
|
|
|
for storage_object in storage_objects:
|
|
|
|
check_object_not_found(
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet,
|
2023-08-30 11:38:03 +00:00
|
|
|
storage_object.cid,
|
|
|
|
storage_object.oid,
|
|
|
|
self.shell,
|
2023-09-08 10:35:34 +00:00
|
|
|
self.cluster.default_rpc_endpoint,
|
|
|
|
)
|