From d0ec77834638099775ebfdd3294f06624a2c59c3 Mon Sep 17 00:00:00 2001 From: anikeev-yadro Date: Thu, 2 Nov 2023 12:19:23 +0300 Subject: [PATCH] Change sanity makrs first step Signed-off-by: anikeev-yadro --- .../testsuites/object/test_object_api.py | 59 ++++--------------- .../object/test_object_api_bearer.py | 1 - .../testsuites/services/test_binaries.py | 12 ++-- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/pytest_tests/testsuites/object/test_object_api.py b/pytest_tests/testsuites/object/test_object_api.py index 01e4426..c62d9d2 100755 --- a/pytest_tests/testsuites/object/test_object_api.py +++ b/pytest_tests/testsuites/object/test_object_api.py @@ -79,9 +79,7 @@ def generate_ranges( range_length = random.randint(RANGE_MIN_LEN, RANGE_MAX_LEN) range_start = random.randint(offset, offset + length) - file_ranges_to_test.append( - (range_start, min(range_length, storage_object.size - range_start)) - ) + file_ranges_to_test.append((range_start, min(range_length, storage_object.size - range_start))) file_ranges_to_test.extend(STATIC_RANGES.get(storage_object.size, [])) @@ -250,9 +248,7 @@ class TestObjectApi(ClusterTestBase): assert sorted(expected_oids) == sorted(result) @allure.title("Search objects with removed items (obj_size={object_size})") - def test_object_search_should_return_tombstone_items( - self, default_wallet: str, object_size: ObjectSize - ): + def test_object_search_should_return_tombstone_items(self, default_wallet: str, object_size: ObjectSize): """ Validate object search with removed items """ @@ -275,9 +271,7 @@ class TestObjectApi(ClusterTestBase): with allure.step("Search object"): # Root Search object should return root object oid - result = search_object( - wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint, root=True - ) + result = search_object(wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint, root=True) assert result == [storage_object.oid] with allure.step("Delete file"): @@ -285,22 +279,14 @@ class TestObjectApi(ClusterTestBase): with allure.step("Search deleted object with --root"): # Root Search object should return nothing - result = search_object( - wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint, root=True - ) + result = search_object(wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint, root=True) assert len(result) == 0 with allure.step("Search deleted object with --phy should return only tombstones"): # Physical Search object should return only tombstones - result = search_object( - wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint, phy=True - ) - assert ( - storage_object.tombstone in result - ), "Search result should contain tombstone of removed object" - assert ( - storage_object.oid not in result - ), "Search result should not contain ObjectId of removed object" + result = search_object(wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint, phy=True) + assert storage_object.tombstone in result, "Search result should contain tombstone of removed object" + assert storage_object.oid not in result, "Search result should not contain ObjectId of removed object" for tombstone_oid in result: header = head_object( wallet, @@ -315,7 +301,6 @@ class TestObjectApi(ClusterTestBase): ), f"Object wasn't deleted properly. Found object {tombstone_oid} with type {object_type}" @allure.title("Get range hash by native API (obj_size={object_size})") - @pytest.mark.sanity @pytest.mark.grpc_api def test_object_get_range_hash(self, storage_objects: list[StorageObjectInfo], max_object_size): """ @@ -327,9 +312,7 @@ class TestObjectApi(ClusterTestBase): oids = [storage_object.oid for storage_object in storage_objects[:2]] file_path = storage_objects[0].file_path - file_ranges_to_test = generate_ranges( - storage_objects[0], max_object_size, self.shell, self.cluster - ) + file_ranges_to_test = generate_ranges(storage_objects[0], max_object_size, self.shell, self.cluster) logging.info(f"Ranges used in test {file_ranges_to_test}") for range_start, range_len in file_ranges_to_test: @@ -349,7 +332,6 @@ class TestObjectApi(ClusterTestBase): ), f"Expected range hash to match {range_cut} slice of file payload" @allure.title("Get range by native API (obj_size={object_size})") - @pytest.mark.sanity @pytest.mark.grpc_api def test_object_get_range(self, storage_objects: list[StorageObjectInfo], max_object_size): """ @@ -361,9 +343,7 @@ class TestObjectApi(ClusterTestBase): oids = [storage_object.oid for storage_object in storage_objects[:2]] file_path = storage_objects[0].file_path - file_ranges_to_test = generate_ranges( - storage_objects[0], max_object_size, self.shell, self.cluster - ) + file_ranges_to_test = generate_ranges(storage_objects[0], max_object_size, self.shell, self.cluster) logging.info(f"Ranges used in test {file_ranges_to_test}") for range_start, range_len in file_ranges_to_test: @@ -379,14 +359,11 @@ class TestObjectApi(ClusterTestBase): range_cut=range_cut, ) assert ( - get_file_content( - file_path, content_len=range_len, mode="rb", offset=range_start - ) + get_file_content(file_path, content_len=range_len, mode="rb", offset=range_start) == range_content ), f"Expected range content to match {range_cut} slice of file payload" @allure.title("[NEGATIVE] Get invalid range by native API (obj_size={object_size})") - @pytest.mark.sanity @pytest.mark.grpc_api def test_object_get_range_negatives( self, @@ -421,11 +398,7 @@ class TestObjectApi(ClusterTestBase): for range_start, range_len, expected_error in file_ranges_to_test: range_cut = f"{range_start}:{range_len}" - expected_error = ( - expected_error.format(range=range_cut) - if "{range}" in expected_error - else expected_error - ) + expected_error = expected_error.format(range=range_cut) if "{range}" in expected_error else expected_error with allure.step(f"Get range ({range_cut})"): for oid in oids: with pytest.raises(Exception, match=expected_error): @@ -472,11 +445,7 @@ class TestObjectApi(ClusterTestBase): for range_start, range_len, expected_error in file_ranges_to_test: range_cut = f"{range_start}:{range_len}" - expected_error = ( - expected_error.format(range=range_cut) - if "{range}" in expected_error - else expected_error - ) + expected_error = expected_error.format(range=range_cut) if "{range}" in expected_error else expected_error with allure.step(f"Get range hash ({range_cut})"): for oid in oids: with pytest.raises(Exception, match=expected_error): @@ -491,9 +460,7 @@ class TestObjectApi(ClusterTestBase): 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}" + assert key_to_check in head_info["header"]["attributes"], f"Key {key_to_check} is found in {head_object}" assert head_info["header"]["attributes"].get(key_to_check) == str( val_to_check ), f"Value {val_to_check} is equal" diff --git a/pytest_tests/testsuites/object/test_object_api_bearer.py b/pytest_tests/testsuites/object/test_object_api_bearer.py index 430739b..c0afe6e 100644 --- a/pytest_tests/testsuites/object/test_object_api_bearer.py +++ b/pytest_tests/testsuites/object/test_object_api_bearer.py @@ -79,7 +79,6 @@ def storage_objects( return storage_objects -@pytest.mark.sanity @pytest.mark.smoke @pytest.mark.bearer class TestObjectApiWithBearerToken(ClusterTestBase): diff --git a/pytest_tests/testsuites/services/test_binaries.py b/pytest_tests/testsuites/services/test_binaries.py index c7dc036..894e683 100644 --- a/pytest_tests/testsuites/services/test_binaries.py +++ b/pytest_tests/testsuites/services/test_binaries.py @@ -1,7 +1,7 @@ import logging import os from http import HTTPStatus -from re import match, fullmatch +from re import fullmatch, match import allure import pytest @@ -14,8 +14,8 @@ from pytest import FixtureRequest logger = logging.getLogger("NeoLogger") + @allure.title("Check binaries versions") -@pytest.mark.sanity @pytest.mark.check_binaries def test_binaries_versions(request: FixtureRequest, hosting: Hosting): """ @@ -31,8 +31,8 @@ def test_binaries_versions(request: FixtureRequest, hosting: Hosting): # compare versions from servers and file exeptions = [] additional_env_properties = {} - - for binary, version in got_versions.items(): + + for binary, version in got_versions.items(): if not fullmatch(r"^\d+\.\d+\.\d+(-.*)?(? dict: response = requests.get(url) - assert ( - response.status_code == HTTPStatus.OK - ), f"Got {response.status_code} code. Content {response.json()}" + assert response.status_code == HTTPStatus.OK, f"Got {response.status_code} code. Content {response.json()}" content = response.text assert content, f"Expected file with content, got {response}"