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

Add asserts for zero ranges #964

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
46 changes: 46 additions & 0 deletions pytest_tests/tests/object/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,28 @@ def test_object_get_range_hash(
f"Expected range hash to match {range_cut} slice of file payload"
)

if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) > "0.44.2":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offtop: how often we cmp versions like this? May break upon reaching 0.100.0. Still better to check nums

with allure.step("Verify zero payload ranges"):
range_hash = get_range_hash(
wallet,
cid,
oid,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will both simple and complex objects be tested here?

shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="0:0",
)
assert get_file_hash(file_path) == range_hash, "Expected range hash to match full file payload"

with pytest.raises(Exception, match=r".*zero length with non-zero offset.*"):
get_range_hash(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="5:0",
)

@allure.title("Validate native object API get_range")
def test_object_get_range(self, request: FixtureRequest, storage_objects: list[StorageObjectInfo], max_object_size):
"""
Expand Down Expand Up @@ -594,6 +616,30 @@ def test_object_get_range(self, request: FixtureRequest, storage_objects: list[S
== range_content
), f"Expected range content to match {range_cut} slice of file payload"

if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) > "0.44.2":
with allure.step("Verify zero payload ranges"):
_, range_content = get_range(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="0:0",
)
assert get_file_content(file_path, mode="rb") == range_content, (
"Expected range content to match full file payload"
)

with pytest.raises(Exception, match=r".*zero length with non-zero offset.*"):
get_range(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="5:0",
)

@allure.title("Validate native object API get_range for a complex object")
def test_object_get_range_complex(self, default_wallet: NodeWallet, container: str, complex_object_size: int):
"""
Expand Down
Loading