2022-11-01 16:11:26 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
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-08-02 11:54:03 +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
|
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-08-07 09:43:16 +00:00
|
|
|
@allure.title("Object should be removed when lifetime expired for {object_size}")
|
2022-12-05 22:31:45 +00:00
|
|
|
@pytest.mark.parametrize(
|
2022-12-07 12:38:56 +00:00
|
|
|
"object_size",
|
|
|
|
[pytest.lazy_fixture("simple_object_size"), pytest.lazy_fixture("complex_object_size")],
|
2023-08-02 11:54:03 +00:00
|
|
|
ids=["simple object size", "complex object size"],
|
2022-12-05 22:31:45 +00:00
|
|
|
)
|
2023-08-07 09:43:16 +00:00
|
|
|
def test_object_api_lifetime(self, default_wallet: str, 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)
|
|
|
|
|
|
|
|
oid = put_object_to_random_node(
|
|
|
|
wallet, file_path, cid, self.shell, self.cluster, expire_at=epoch + 1
|
|
|
|
)
|
|
|
|
got_file = get_object_from_random_node(wallet, cid, oid, self.shell, self.cluster)
|
|
|
|
assert get_file_hash(got_file) == file_hash
|
|
|
|
|
|
|
|
with allure.step("Tick two epochs"):
|
|
|
|
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-05-12 15:13:14 +00:00
|
|
|
with allure.step("Check object deleted because it expires on epoch"):
|
|
|
|
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)
|
|
|
|
|
|
|
|
with allure.step("Tick additional epoch"):
|
|
|
|
self.tick_epoch()
|
|
|
|
|
|
|
|
wait_for_gc_pass_on_storage_nodes()
|
|
|
|
|
|
|
|
with allure.step("Check object deleted because it expires on previous epoch"):
|
|
|
|
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)
|