Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add checks for object parts removal #826

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest_tests/lib/s3/s3_gate_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TestNeofsS3GateBase(NeofsEnvTestBase):

@pytest.fixture(scope="class", autouse=True)
@allure.title("[Class/Autouse]: Create S3 client")
def s3_client(
def s3_client_fixture(
self,
default_wallet: NodeWallet,
client_shell: Shell,
Expand Down
84 changes: 84 additions & 0 deletions pytest_tests/tests/object/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
INVALID_RANGE_ZERO_LENGTH,
INVALID_SEARCH_QUERY,
LINK_OBJECT_FOUND,
OBJECT_ALREADY_REMOVED,
OBJECT_HEADER_LENGTH_LIMIT,
OBJECT_NOT_FOUND,
OUT_OF_RANGE,
)
from helpers.neofs_verbs import (
NEOFS_API_HEADER_LIMIT,
delete_object,
get_object,
get_object_from_random_node,
get_range,
get_range_hash,
Expand All @@ -37,6 +40,7 @@
)
from helpers.storage_object_info import StorageObjectInfo, delete_objects
from helpers.test_control import expect_not_raises
from helpers.utility import wait_for_gc_pass_on_storage_nodes
from neofs_env.neofs_env_test_base import NeofsEnvTestBase
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
from neofs_testlib.shell import Shell
Expand Down Expand Up @@ -792,6 +796,86 @@ def test_object_parts_cannot_be_deleted(self, default_wallet: NodeWallet, contai
self.neofs_env.sn_rpc,
)

@allure.title("Big object parts are removed after deletion")
def test_object_parts_are_unavailable_after_deletion(
self, default_wallet: NodeWallet, container: str, complex_object_size: int
):
with allure.step("Upload big object"):
file_path = generate_file(complex_object_size)
oid = put_object_to_random_node(
default_wallet.path,
file_path,
container,
shell=self.shell,
neofs_env=self.neofs_env,
)
with allure.step("Get object parts"):
parts = get_object_chunks(default_wallet.path, container, oid, self.shell, self.neofs_env)

with allure.step("Delete big object"):
delete_object(
default_wallet.path,
container,
oid,
self.shell,
self.neofs_env.sn_rpc,
)

with allure.step("Check big object is deleted"):
with pytest.raises(Exception, match=OBJECT_ALREADY_REMOVED):
get_object_from_random_node(default_wallet.path, container, oid, self.shell, neofs_env=self.neofs_env)

with allure.step("Try to get object parts"):
for part in parts:
with pytest.raises(Exception, match=OBJECT_ALREADY_REMOVED):
get_object(
default_wallet.path,
container,
part[0],
self.shell,
self.neofs_env.sn_rpc,
)

@allure.title("Big object parts are removed after expiration")
def test_object_parts_are_unavailable_after_expiration(
self, default_wallet: NodeWallet, container: str, complex_object_size: int
):
with allure.step("Get current epoch"):
epoch = self.get_epoch()

with allure.step("Upload big object"):
file_path = generate_file(complex_object_size)
oid = put_object_to_random_node(
default_wallet.path,
file_path,
container,
shell=self.shell,
neofs_env=self.neofs_env,
expire_at=epoch + 1,
)
with allure.step("Get object parts"):
parts = get_object_chunks(default_wallet.path, container, oid, self.shell, self.neofs_env)

with allure.step("Tick two epochs"):
self.tick_epochs_and_wait(2)

wait_for_gc_pass_on_storage_nodes()

with allure.step("Check big object is deleted"):
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
get_object_from_random_node(default_wallet.path, container, oid, self.shell, neofs_env=self.neofs_env)

with allure.step("Try to get object parts"):
for part in parts:
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
get_object(
default_wallet.path,
container,
part[0],
self.shell,
self.neofs_env.sn_rpc,
)

def check_header_is_presented(self, head_info: dict, object_header: dict) -> None:
for key_to_check, val_to_check in object_header.items():
assert key_to_check in head_info["header"]["attributes"], f"Key {key_to_check} is found in {head_object}"
Expand Down
Loading