Skip to content

Commit

Permalink
tests/object: Add parts removal tests
Browse files Browse the repository at this point in the history
Such operations are prohibited with the new split scheme.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed May 2, 2024
1 parent 16532e2 commit a73da1f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pytest_tests/lib/helpers/complex_object_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@


def get_object_chunks(
storage_object: StorageObjectInfo,
wallet_file_path: string,
cid: string,
oid: string,
shell: Shell,
neofs_env: NeoFSEnv,
bearer: str = None,
Expand All @@ -25,6 +27,9 @@ def get_object_chunks(
Get complex objects' IDs and sizes (no link object)
Args:
wallet_file_path: wallet to use
cid: object's container
oid: object's ID
storage_object: storage_object to get it's chunks
shell: client shell to do cmd requests
bearer: bearer token to access chunks
Expand All @@ -34,20 +39,20 @@ def get_object_chunks(
list of tuples (object_id, object_size) of complex object chunks
"""

with allure.step(f"Get complex object chunks (f{storage_object.oid})"):
with allure.step(f"Get complex object chunks (f{oid})"):
link_object_id = get_link_object(
storage_object.wallet_file_path,
storage_object.cid,
storage_object.oid,
wallet_file_path,
cid,
oid,
shell,
neofs_env.storage_nodes,
bearer=bearer,
is_direct=False,
)

link_obj_path = get_object(
wallet=storage_object.wallet_file_path,
cid=storage_object.cid,
wallet=wallet_file_path,
cid=cid,
oid=link_object_id,
shell=shell,
endpoint=neofs_env.sn_rpc,
Expand Down
1 change: 1 addition & 0 deletions pytest_tests/lib/helpers/grpc_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# TODO: Due to https://github.com/nspcc-dev/neofs-node/issues/2092 we have to check only codes until fixed
# OBJECT_IS_LOCKED = "code = 2050.*message = object is locked"
# LOCK_NON_REGULAR_OBJECT = "code = 2051.*message = ..." will be available once 2092 is fixed
LINK_OBJECT_FOUND = "code = 1024.*message = found link object"
OBJECT_IS_LOCKED = "code = 2050"
LOCK_NON_REGULAR_OBJECT = "code = 2051"
OBJECT_HEADER_LENGTH_LIMIT = ".*object header length exceeds the limit.*"
Expand Down
45 changes: 45 additions & 0 deletions pytest_tests/tests/object/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
get_complex_object_copies,
get_complex_object_split_ranges,
get_simple_object_copies,
get_object_chunks,
get_link_object,
)
from helpers.container import create_container, delete_container
from helpers.file_helper import generate_file, get_file_content, get_file_hash
Expand All @@ -21,6 +23,7 @@
INVALID_SEARCH_QUERY,
OBJECT_HEADER_LENGTH_LIMIT,
OUT_OF_RANGE,
LINK_OBJECT_FOUND,
)
from helpers.neofs_verbs import (
NEOFS_API_HEADER_LIMIT,
Expand All @@ -30,6 +33,7 @@
head_object,
put_object_to_random_node,
search_object,
delete_object,
)
from helpers.storage_object_info import StorageObjectInfo, delete_objects
from helpers.test_control import expect_not_raises
Expand Down Expand Up @@ -755,6 +759,47 @@ def test_put_object_header_limitation(
attributes={attr_key: attr_val}
)

@allure.title("Finished objects (with link object found) cannot be deleted")
def test_object_parts_cannot_be_deleted(self, default_wallet: NodeWallet, container: str, complex_object_size: int):
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,
)

link_oid = get_link_object(
default_wallet.path,
container,
oid,
shell=self.shell,
nodes=self.neofs_env.storage_nodes
)

with allure.step(f"Trying to delete link object {link_oid}"):
with pytest.raises(Exception, match=LINK_OBJECT_FOUND):
delete_object(
default_wallet.path,
container,
link_oid,
self.shell,
self.neofs_env.sn_rpc,
)

with allure.step(f"Trying to delete children"):
parts = get_object_chunks(default_wallet.path, container, oid, self.shell, self.neofs_env)
for part in parts:
with pytest.raises(Exception, match=LINK_OBJECT_FOUND):
delete_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 (
Expand Down

0 comments on commit a73da1f

Please sign in to comment.