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
|
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
|
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-11-13 14:50:31 +00:00
|
|
|
from frostfs_testlib.testing.test_control import expect_not_raises
|
|
|
|
from frostfs_testlib.utils.file_utils import TestFile
|
2022-11-01 16:11:26 +00:00
|
|
|
|
2024-10-29 10:32:07 +00:00
|
|
|
from ...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")
|
|
|
|
|
|
|
|
|
2024-10-11 09:30:23 +00:00
|
|
|
@pytest.mark.nightly
|
2022-11-01 16:11:26 +00:00
|
|
|
@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-11-16 11:31:05 +00:00
|
|
|
def test_object_api_lifetime(self, container: str, test_file: TestFile, default_wallet: WalletInfo):
|
2022-12-05 22:31:45 +00:00
|
|
|
"""
|
|
|
|
Test object deleted after expiration epoch.
|
|
|
|
"""
|
|
|
|
|
|
|
|
wallet = default_wallet
|
|
|
|
|
|
|
|
epoch = get_epoch(self.shell, self.cluster)
|
|
|
|
|
2024-11-13 14:50:31 +00:00
|
|
|
oid = put_object_to_random_node(wallet, test_file.path, container, self.shell, self.cluster, expire_at=epoch + 1)
|
|
|
|
with expect_not_raises():
|
|
|
|
head_object(wallet, container, oid, self.shell, self.cluster.default_rpc_endpoint)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick two epochs"):
|
2024-11-13 14:50:31 +00:00
|
|
|
self.tick_epochs(2)
|
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):
|
2024-11-13 14:50:31 +00:00
|
|
|
head_object(wallet, container, oid, self.shell, self.cluster.default_rpc_endpoint)
|
2023-05-12 15:13:14 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
2024-11-13 14:50:31 +00:00
|
|
|
get_object_from_random_node(wallet, container, oid, self.shell, self.cluster)
|
2023-05-12 15:13:14 +00:00
|
|
|
|
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):
|
2024-11-13 14:50:31 +00:00
|
|
|
head_object(wallet, container, oid, self.shell, self.cluster.default_rpc_endpoint)
|
2022-12-05 22:31:45 +00:00
|
|
|
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
2024-11-13 14:50:31 +00:00
|
|
|
get_object_from_random_node(wallet, container, oid, self.shell, self.cluster)
|