2022-11-01 16:11:26 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
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.error_patterns import OBJECT_NOT_FOUND
|
|
|
|
from frostfs_testlib.steps.cli.container import create_container
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib.steps.cli.object import get_object_from_random_node, head_object, put_object_to_random_node
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.steps.epoch import get_epoch
|
2023-08-02 11:54:03 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
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.utils.file_utils import generate_file, get_file_hash
|
2022-11-01 16:11:26 +00:00
|
|
|
|
2023-02-27 16:54:27 +00:00
|
|
|
from pytest_tests.helpers.utility import wait_for_gc_pass_on_storage_nodes
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2022-11-01 16:11:26 +00:00
|
|
|
logger = logging.getLogger("NeoLogger")
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sanity
|
|
|
|
@pytest.mark.grpc_api
|
2022-12-08 10:21:38 +00:00
|
|
|
class TestObjectApiLifetime(ClusterTestBase):
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Object is removed when lifetime expired (obj_size={object_size})")
|
2024-03-11 16:34:54 +00:00
|
|
|
def test_object_api_lifetime(self, default_wallet: WalletInfo, object_size: ObjectSize):
|
2022-12-05 22:31:45 +00:00
|
|
|
"""
|
|
|
|
Test object deleted after expiration epoch.
|
|
|
|
"""
|
|
|
|
|
|
|
|
wallet = default_wallet
|
|
|
|
endpoint = self.cluster.default_rpc_endpoint
|
|
|
|
cid = create_container(wallet, self.shell, endpoint)
|
|
|
|
|
2023-08-02 11:54:03 +00:00
|
|
|
file_path = generate_file(object_size.value)
|
2022-12-05 22:31:45 +00:00
|
|
|
file_hash = get_file_hash(file_path)
|
|
|
|
epoch = get_epoch(self.shell, self.cluster)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster, expire_at=epoch + 1)
|
2022-12-05 22:31:45 +00:00
|
|
|
got_file = get_object_from_random_node(wallet, cid, oid, self.shell, self.cluster)
|
|
|
|
assert get_file_hash(got_file) == file_hash
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick two epochs"):
|
2022-12-05 22:31:45 +00:00
|
|
|
for _ in range(2):
|
2022-12-23 11:42:41 +00:00
|
|
|
self.tick_epoch()
|
2022-12-05 22:31:45 +00:00
|
|
|
|
|
|
|
# Wait for GC, because object with expiration is counted as alive until GC removes it
|
|
|
|
wait_for_gc_pass_on_storage_nodes()
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check object deleted because it expires on epoch"):
|
2023-05-12 15:13:14 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
|
|
|
head_object(wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint)
|
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
|
|
|
get_object_from_random_node(wallet, cid, oid, self.shell, self.cluster)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick additional epoch"):
|
2023-05-12 15:13:14 +00:00
|
|
|
self.tick_epoch()
|
|
|
|
|
|
|
|
wait_for_gc_pass_on_storage_nodes()
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check object deleted because it expires on previous epoch"):
|
2023-05-12 15:13:14 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
|
|
|
head_object(wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint)
|
2022-12-05 22:31:45 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
|
|
|
get_object_from_random_node(wallet, cid, oid, self.shell, self.cluster)
|