From 78b0fd5b2a50d81610c18202f48c4c7f03761465 Mon Sep 17 00:00:00 2001 From: Ekaterina Chernitsyna Date: Tue, 17 Oct 2023 14:00:21 +0300 Subject: [PATCH] Update policy tests --- .../testsuites/container/test_policy.py | 1481 +++++++++++++---- 1 file changed, 1196 insertions(+), 285 deletions(-) diff --git a/pytest_tests/testsuites/container/test_policy.py b/pytest_tests/testsuites/container/test_policy.py index 6104d14..ac65a7d 100644 --- a/pytest_tests/testsuites/container/test_policy.py +++ b/pytest_tests/testsuites/container/test_policy.py @@ -1,37 +1,29 @@ -from frostfs_testlib.steps.cli.container import ( - create_container, - delete_container, - get_container, -) -from frostfs_testlib.testing.cluster_test_base import ClusterTestBase -from pytest_tests.helpers.utility import placement_policy_from_container -from frostfs_testlib.storage.dataclasses.object_size import ObjectSize -from frostfs_testlib.utils.file_utils import generate_file import allure import pytest from frostfs_testlib.resources.wellknown_acl import PUBLIC_ACL -from frostfs_testlib.steps.cli.container import create_container, get_container -from frostfs_testlib.steps.cli.object import ( - put_object_to_random_node, -) -from frostfs_testlib.steps.node_management import ( - check_node_in_map, -) -from frostfs_testlib.steps.storage_policy import get_nodes_with_object, get_simple_object_copies -from pytest_tests.helpers.utility import ( - placement_policy_from_container, +from frostfs_testlib.steps.cli.container import create_container, delete_container, get_container +from frostfs_testlib.steps.cli.object import delete_object, put_object_to_random_node, search_object +from frostfs_testlib.steps.node_management import check_node_in_map +from frostfs_testlib.steps.storage_policy import ( + get_nodes_with_object, + get_nodes_without_object, + get_object_copies, + get_simple_object_copies, ) +from frostfs_testlib.storage.dataclasses.object_size import ObjectSize +from frostfs_testlib.testing.cluster_test_base import ClusterTestBase +from frostfs_testlib.utils.file_utils import generate_file + +from pytest_tests.helpers.utility import placement_policy_from_container + @pytest.mark.container @pytest.mark.policy class TestPolicy(ClusterTestBase): - @pytest.mark.skip(reason="ошибка с фикстурой") @allure.title("[NEGATIVE] Placement policy") @pytest.mark.policy - def test_placement_policy_negative( - self, default_wallet, placement_rule - ): + def test_placement_policy_negative(self, default_wallet, placement_rule): """ Negative test for placement policy. """ @@ -45,16 +37,12 @@ class TestPolicy(ClusterTestBase): got_policy = placement_policy_from_container( get_container(wallet, cid, json_mode=False, shell=self.shell, endpoint=endpoint) ) - assert got_policy == placement_rule.replace( - "'", "" - ), f"Can't parse placement policy" + assert got_policy == placement_rule.replace("'", ""), f"Can't parse placement policy" @pytest.mark.skip(reason="ошибка с фикстурой") - @allure.title("110569 [NEGATIVE] Placement policy: Not enough nodes to SELECT") + @allure.title("[NEGATIVE] Placement policy: Not enough nodes to SELECT") @pytest.mark.policy - def test_placement_policy_negative_not_enough_nodes_to_select( - self, default_wallet, placement_rule - ): + def test_placement_policy_negative_not_enough_nodes_to_select(self, default_wallet, placement_rule): """ Negative test for placement policy: Not enough nodes to SELECT. """ @@ -64,13 +52,11 @@ class TestPolicy(ClusterTestBase): cid = create_container( wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint ) - - @pytest.mark.skip(reason="ошибка с фикстурой") - @allure.title("110570 [NEGATIVE] Placement policy: Filter not found") + + @pytest.mark.skip(reason="ошибка с фикстурой") + @allure.title("[NEGATIVE] Placement policy: Filter not found") @pytest.mark.policy - def test_placement_policy_negative_not_enough_nodes_to_filter( - self, default_wallet, placement_rule - ): + def test_placement_policy_negative_not_enough_nodes_to_filter(self, default_wallet, placement_rule): """ Negative test for placement policy: Filter not found. """ @@ -80,13 +66,11 @@ class TestPolicy(ClusterTestBase): cid = create_container( wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint ) - - @pytest.mark.skip(reason="ошибка с фикстурой") - @allure.title("110572 [NEGATIVE] Placement policy: SELECTOR not found") + + @pytest.mark.skip(reason="ошибка с фикстурой") + @allure.title("[NEGATIVE] Placement policy: SELECTOR not found") @pytest.mark.policy - def test_placement_policy_negative_not_enough_nodes_to_selector( - self, default_wallet, placement_rule - ): + def test_placement_policy_negative_not_enough_nodes_to_selector(self, default_wallet, placement_rule): """ Negative test for placement policy: Filter not found. """ @@ -97,351 +81,1302 @@ class TestPolicy(ClusterTestBase): wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint ) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("REP 1 REP 1 CBF 1", 2, {2, 2}), - ] - ) @pytest.mark.policy - @allure.title("110571 Object should have {expected_copies} copies with policy {placement_rule}") + @allure.title("Simple policy results with one node") def test_simple_policy_results_with_one_node( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ This test checks object's copies based on container's placement simple policy results with one node. """ - wallet = default_wallet + placement_rule = "REP 1 REP 1 CBF 1" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("UNIQUE REP 1 IN AnyNode REP 1 IN AnyNode CBF 1 SELECT 1 FROM * AS AnyNode", 2, {2, 3}), - ] - ) @pytest.mark.policy - @allure.title("110544 Object should have {expected_copies} copies with policy {placement_rule}") - def test_policy_with_select_results_with_unique_nodes( + @allure.title("Policy with SELECT results with one node") + def test_policy_with_select_results_with_one_node( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ - This test checks object's copies based on container's placement policy with SELECT results with UNIQUE nodes. + This test checks object's copies based on container's placement policy with SELECT results with one node. """ - wallet = default_wallet + placement_rule = "REP 1 IN AnyNode REP 1 IN AnyNode CBF 1 SELECT 1 FROM * AS AnyNode" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ('UNIQUE REP 1 IN RUS REP 1 IN RUS CBF 1 SELECT 1 FROM RU AS RUS FILTER Country NE Sweden AS NotSE FILTER @NotSE AND NOT (CountryCode EQ FI) AND Country EQ "Russia" AS RU', 2, {3, 1}), - ] - ) @pytest.mark.policy - @allure.title("110545 Object should have {expected_copies} copies with policy {placement_rule}") - def test_policy_with_select_and_complex_filter_results_with_unique_nodes( + @allure.title("Policy with SELECT and FILTER results with one node") + def test_policy_with_select_and_filter_results_with_one_node( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ - This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with UNIQUE nodes. + This test checks object's copies based on container's placement policy with SELECT and FILTER results with one node. """ - wallet = default_wallet + placement_rule = "REP 1 IN MyRussianNodes REP 1 IN MyRussianNodes CBF 1 SELECT 1 FROM RussianNodes AS MyRussianNodes FILTER Country EQ Russia AS RussianNodes" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("""REP 4""", - 4, {3, 2, 1, 4}), - ] - ) @pytest.mark.policy - @allure.title("110610 Object should have {expected_copies} copies with policy {placement_rule}") - def test_simple_policy_results_with_100_of_available_nodes( + @allure.title("Policy with SELECT and Complex FILTER results with one node") + def test_policy_with_select_and_complex_filter_results_with_one_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ - This test checks object's copies based on container's placement simple policy results with 100% of available nodes. + This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with one node. """ - wallet = default_wallet + placement_rule = "REP 1 IN RUS REP 1 IN RUS CBF 1 SELECT 1 FROM RU AS RUS FILTER Country NE Sweden AS NotSE FILTER @NotSE AND NOT (CountryCode EQ FI) AND Country EQ Russia AS RU" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("UNIQUE REP 1 REP 1 CBF 1", 2, {2, 3}), - ] - ) @pytest.mark.policy - @allure.title("110537 Object should have {expected_copies} copies with policy {placement_rule}") - def test_policy_with_select_and_complex_filter_results_with_unique_nodes( - self, - default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], - simple_object_size: ObjectSize, - ): - """ - This test checks object's copies based on container's placement simple policy results with UNIQUE nodes. - """ - wallet = default_wallet - file_path = generate_file(simple_object_size.value) - - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) - - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) - - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("UNIQUE REP 1 REP 1 CBF 1", 2, {2, 3}), - ] - ) - @pytest.mark.policy - @allure.title("110587 Object should have {expected_copies} copies with policy {placement_rule}") + @allure.title("Policy with Multi SELECTs and FILTERs results with one node") def test_policy_with_multi_selects_and_filters_results_with_one_node( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with one nodes. """ - wallet = default_wallet + placement_rule = "REP 1 IN RU REP 1 IN EU REP 1 IN RU CBF 1 SELECT 1 FROM RUS AS RU SELECT 1 FROM EUR AS EU FILTER Country EQ Russia AS RUS FILTER NOT @RUS AND (Country EQ Sweden OR CountryCode EQ FI) AS EUR" file_path = generate_file(simple_object_size.value) + expected_copies = 3 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("REP 1 CBF 1", 1, {2}), - ] - ) @pytest.mark.policy - @allure.title("110593 Object should have {expected_copies} copies with policy {placement_rule}") + @allure.title("Policy with SELECT and FILTER results with UNIQUE nodes") + def test_policy_with_select_and_filter_results_with_unique_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT and FILTER results with UNIQUE nodes. + """ + placement_rule = "UNIQUE REP 1 IN MyRussianNodes REP 1 IN MyRussianNodes CBF 1 SELECT 1 FROM RussianNodes AS MyRussianNodes FILTER Country EQ Russia AS RussianNodes" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Simple policy results with 25% of available nodes") def test_simple_policy_results_with_25_of_available_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ This test checks object's copies based on container's placement policy results with 25% of available nodes. """ - wallet = default_wallet + placement_rule = "REP 1 CBF 1" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("REP 1 IN One CBF 1 SELECT 1 FROM * AS One", 1, {2}), - ] - ) @pytest.mark.policy - @allure.title("110594 Object should have {expected_copies} copies with policy {placement_rule}") + @allure.title("Policy with SELECT results with 25% of available nodes") def test_policy_with_select_results_with_25_of_available_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ - This test checks object's copies based on container's placement policy with SELECT results with 25% of available nodes. + This test checks object's copies based on container's placement policy with SELECT results with 25% of available nodes. """ - wallet = default_wallet + placement_rule = "REP 1 IN One CBF 1 SELECT 1 FROM * AS One" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) - - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("REP 1 IN Nodes25 SELECT 1 FROM LE10 AS Nodes25 FILTER Price LE 10 AS LE10", 1, {2}), - ] - ) @pytest.mark.policy - @allure.title("110595 Object should have {expected_copies} copies with policy {placement_rule}") + @allure.title("Policy with SELECT and FILTER results with 25% of available nodes") def test_policy_with_select_and_filter_results_with_25_of_available_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ This test checks object's copies based on container's placement policy with SELECT and FILTER results with 25% of available nodes. """ - wallet = default_wallet + placement_rule = "REP 1 IN Nodes25 SELECT 1 FROM LE10 AS Nodes25 FILTER Price LE 10 AS LE10" file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) - - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("""REP 1 IN Nodes25 SELECT 1 FROM BET0AND10 AS Nodes25 FILTER Price LE 10 AS LE10 FILTER Price GT 0 AS GT0 FILTER @LE10 AND @GT0 AS BET0AND10""", - 1, {1}), - ] - ) @pytest.mark.policy - @allure.title("110596 Object should have {expected_copies} copies with policy {placement_rule}") + @allure.title("Policy with select and complex filter results with 25% of available nodes") def test_policy_with_select_and_complex_filter_results_with_25_of_available_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], - complex_object_size: ObjectSize, + simple_object_size: ObjectSize, ): """ 110596 This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with 25% of available nodes. """ - wallet = default_wallet - file_path = generate_file(complex_object_size.value) + placement_rule = "REP 1 IN Nodes25 SELECT 1 FROM BET0AND10 AS Nodes25 FILTER Price LE 10 AS LE10 FILTER Price GT 0 AS GT0 FILTER @LE10 AND @GT0 AS BET0AND10" + file_path = generate_file(simple_object_size.value) + expected_copies = 1 + endpoint = self.cluster.default_rpc_endpoint - - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) - - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("""UNIQUE REP 1 IN MyRussianNodes REP 1 IN MyRussianNodes CBF 1 SELECT 1 FROM RussianNodes AS MyRussianNodes FILTER Country EQ Russia AS RussianNodes""", - 2, {3, 1}), - ] - ) @pytest.mark.policy - @allure.title("110588 Object should have {expected_copies} copies with policy {placement_rule}") - def test_policy_with_select_and_filter_results_with_unique_nodes( + @allure.title("Policy with Multi SELECTs and FILTERs results with 25% of available nodes") + def test_policy_with_multi_selects_and_filters_results_with_25_of_available_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ - This test checks object's copies based on container's placement policy with SELECT and FILTER results with UNIQUE nodes. + This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with 25% of available nodes. """ - wallet = default_wallet + placement_rule = "UNIQUE REP 1 IN One REP 1 IN One CBF 1 SELECT 1 FROM MINMAX AS One FILTER Price LT 15 AS LT15 FILTER Price GT 55 AS GT55 FILTER @LT15 OR @GT55 AS MINMAX" file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) - @pytest.mark.parametrize( - "placement_rule,expected_copies,expected_nodes_id", - [ - ("""UNIQUE REP 1 IN MyRussianNodes REP 1 IN MyRussianNodes CBF 1 SELECT 1 FROM RussianNodes AS MyRussianNodes FILTER Country EQ Russia AS RussianNodes""", - 2, {3, 1}), - ] - ) @pytest.mark.policy - @allure.title("110586 Object should have {expected_copies} copies with policy {placement_rule}") - def test_policy_with_select_and_filter_results_with_unique_nodes( + @allure.title("Simple policy results with 50% of available nodes") + def test_simple_policy_results_with_50_of_available_nodes( self, default_wallet, - placement_rule, - expected_copies, - expected_nodes_id: set[int], simple_object_size: ObjectSize, ): """ - This test checks object's copies based on container's placement policy with SELECT and FILTER results with UNIQUE nodes. + This test checks object's copies based on container's placement simple policy results with 50% of available nodes. """ - wallet = default_wallet + placement_rule = "REP 2 CBF 1" file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint - cid, oid = self.validate_object_copies( - wallet, placement_rule, file_path - ) + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) - self.check_expected_copies(cid, oid, expected_copies, expected_nodes_id) + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) - @allure.step("Validate policy") - def validate_object_policy( - self, wallet: str, placement_rule: str, cid: str, endpoint: str + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT results with 50% of available nodes") + def test_policy_with_select_results_with_50_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, ): + """ + This test checks object's copies based on container's placement policy with SELECT results with 50% of available nodes. + """ + placement_rule = "REP 2 IN HALF CBF 1 SELECT 2 FROM * AS HALF" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and FILTER results with 50% of available nodes") + def test_policy_with_select_and_filter_results_with_50_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT and FILTER results with 50% of available nodes. + """ + placement_rule = "REP 2 IN HALF CBF 1 SELECT 2 FROM GT15 AS HALF FILTER Price GT 15 AS GT15" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and Complex FILTER results with 50% of available nodes") + def test_policy_with_select_and_complex_filter_results_with_50_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with 50% of available nodes. + """ + placement_rule = "REP 2 IN HALF CBF 2 SELECT 2 FROM GE15 AS HALF FILTER CountryCode NE RU AS NOTRU FILTER @NOTRU AND Price GE 15 AS GE15" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with Multi SELECTs and FILTERs results with 50% of available nodes") + def test_policy_with_multi_selects_and_filters_results_with_50_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with 50% of available nodes. + """ + placement_rule = "REP 2 IN FH REP 1 IN SH CBF 2 SELECT 2 FROM LE55 AS FH SELECT 2 FROM GE15 AS SH FILTER UN-LOCODE EQ RU_LED OR UN-LOCODE EQ RU_MOW AS RU FILTER NOT(@RU) AS NOTRU FILTER @NOTRU AND Price GE 15 AS GE15 FILTER @RU AND Price LE 55 AS LE55" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Simple policy results with 75% of available nodes") + def test_simple_policy_results_with_75_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement simple policy results with 75% of available nodes. + """ + placement_rule = "REP 1" + file_path = generate_file(simple_object_size.value) + expected_copies = 3 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT results with 75% of available nodes") + def test_policy_with_select_results_with_75_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + 110606 This test checks object's copies based on container's placement policy with SELECT results with 75% of available nodes. + """ + placement_rule = "REP 2 IN DS CBF 1 SELECT 3 IN DISTINCT Country FROM * AS DS" + file_path = generate_file(simple_object_size.value) + expected_copies = 3 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and FILTER results with 75% of available nodes") + def test_policy_with_select_and_filter_results_with_75_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + 110607 This test checks object's copies based on container's placement policy with SELECT and FILTER results with 75% of available nodes. + """ + placement_rule = "REP 2 IN NODES75 SELECT 2 FROM LT65 AS NODES75 FILTER Price LT 65 AS LT65" + file_path = generate_file(simple_object_size.value) + expected_copies = 3 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and Complex FILTER results with 75% of available nodes") + def tets_policy_with_select_and_complex_filter_results_with_75_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + 110608 This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with 75% of available nodes. + """ + placement_rule = "REP 2 IN NODES75 SELECT 2 FROM LT65 AS NODES75 FILTER Price LT 65 AS LT65" + file_path = generate_file(simple_object_size.value) + expected_copies = 3 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with Multi SELECTs and FILTERs results with 75% of available nodes") + def tets_policy_with_multi_selects_and_filters_results_with_75_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + 110608 This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with 75% of available nodes. + """ + placement_rule = "REP 2 IN EXPNSV REP 2 IN CHEAP SELECT 3 FROM GT10 AS EXPNSV SELECT 3 FROM LT65 AS CHEAP FILTER NOT(Continent EQ America) AS NOAM FILTER @NOAM AND Price LT 65 AS LT65 FILTER @NOAM AND Price GT 10 AS GT10" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Simple policy results with 100% of available nodes") + def test_simple_policy_results_with_100_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement simple policy results with 100% of available nodes. + """ + placement_rule = "REP 4" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT results with 100% of available nodes") + def test_policy_with_select_results_with_100_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT results with 100% of available nodes. + """ + placement_rule = "REP 1 IN All SELECT 4 FROM * AS All" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and FILTER results with 100% of available nodes") + def test_policy_with_select_and_filter_results_with_100_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT and FILTER results with 100% of available nodes. + """ + placement_rule = "REP 1 IN All SELECT 4 FROM AllNodes AS All FILTER Price GE 0 AS AllNodes" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and Complex FILTER results with 100% of available nodes") + def test_policy_with_select_and_complex_filter_results_with_100_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with 100% of available nodes. + """ + placement_rule = "REP 2 IN All SELECT 4 FROM AllNodes AS All FILTER Country EQ Russia OR Country EQ Sweden OR Country EQ Finland AS AllCountries FILTER @AllCountries AND Continent EQ Europe AS AllNodes" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with Multi SELECTs and FILTERs results with 100% of available nodes") + def test_policy_with_multi_selects_and_filters_results_with_100_of_available_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with 100% of available nodes. + """ + placement_rule = "REP 4 IN AllOne REP 4 IN AllTwo CBF 4 SELECT 2 FROM GEZero AS AllOne SELECT 2 FROM AllCountries AS AllTwo FILTER Country EQ Russia OR Country EQ Sweden OR Country EQ Finland AS AllCountries FILTER Price GE 0 AS GEZero" + file_path = generate_file(simple_object_size.value) + expected_copies = 4 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Simple policy results with UNIQUE nodes") + def simple_policy_results_with_unique_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement simple policy results with UNIQUE nodes. + """ + placement_rule = "UNIQUE REP 1 REP 1 CBF 1" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT results with UNIQUE nodes") + def test_policy_with_select_results_with_unique_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT results with UNIQUE nodes. + """ + placement_rule = "UNIQUE REP 1 IN AnyNode REP 1 IN AnyNode CBF 1 SELECT 1 FROM * AS AnyNode" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with SELECT and Complex FILTER results with UNIQUE nodes") + def test_policy_with_select_and_complex_filter_results_with_unique_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with UNIQUE nodes. + """ + placement_rule = "UNIQUE REP 1 IN RUS REP 1 IN RUS CBF 1 SELECT 1 FROM RU AS RUS FILTER Country NE Sweden AS NotSE FILTER @NotSE AND NOT (CountryCode EQ FI) AND Country EQ Russia AS RU" + file_path = generate_file(simple_object_size.value) + expected_copies = 2 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + @pytest.mark.policy + @allure.title("Policy with Multi SELECTs and FILTERs results with UNIQUE nodes") + def test_policy_with_multi_selects_and_filters_results_with_unique_nodes( + self, + default_wallet, + simple_object_size: ObjectSize, + ): + """ + This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with UNIQUE nodes. + """ + placement_rule = "UNIQUE REP 1 IN RU REP 1 IN EU REP 1 IN RU CBF 1 SELECT 1 FROM RUS AS RU SELECT 1 FROM EUR AS EU FILTER Country EQ Russia AS RUS FILTER NOT @RUS AND (Country EQ Sweden OR CountryCode EQ FI) AS EUR" + file_path = generate_file(simple_object_size.value) + expected_copies = 3 + endpoint = self.cluster.default_rpc_endpoint + + with allure.step(f"Create container with policy {placement_rule}"): + cid = create_container( + wallet=default_wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint + ) + + with allure.step(f"Check container policy"): + self.validate_object_policy(default_wallet, placement_rule, cid, endpoint) + + with allure.step(f"Put object in container"): + oid = put_object_to_random_node(default_wallet, file_path, cid, shell=self.shell, cluster=self.cluster) + + with allure.step(f"Check object expected copies"): + resulting_copies = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) + assert ( + len(resulting_copies) == expected_copies + ), f"Expected {expected_copies} copies, got {len(resulting_copies)}" + + with allure.step(f"Check the object appearance"): + nodes_without_object = get_nodes_without_object( + wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, nodes=self.cluster.storage_nodes + ) + self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + + with allure.step(f"Delete the object from the container"): + delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) + + with allure.step(f"Delete the container"): + delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) + + def validate_object_policy(self, wallet: str, placement_rule: str, cid: str, endpoint: str): got_policy = placement_policy_from_container( get_container(wallet, cid, json_mode=False, shell=self.shell, endpoint=endpoint) ) @@ -449,29 +1384,5 @@ class TestPolicy(ClusterTestBase): "'", "" ), f"Expected \n{placement_rule} and got policy \n{got_policy} are the same" - @allure.step("Validate expected copies") - def check_expected_copies(self, cid: str, oid: str, expected_copies: int, expected_copies_id: set): - nodes = get_nodes_with_object(cid, oid, shell=self.shell, nodes=self.cluster.storage_nodes) - assert len(nodes) == expected_copies, f"Expected {expected_copies} copies, got {len(nodes)}" - - nodes_id = {node.id for node in nodes} - assert nodes_id == expected_copies_id, f"Expected {expected_copies_id} copies, got {nodes_id}" - - @allure.step("Validate object copies") - def validate_object_copies( - self, wallet: str, placement_rule: str, file_path: str - ) -> set[int]: - endpoint = self.cluster.default_rpc_endpoint - - with allure.step(f"Create container"): - cid = create_container( - wallet, rule=placement_rule, basic_acl=PUBLIC_ACL, shell=self.shell, endpoint=endpoint - ) - - self.validate_object_policy(wallet, placement_rule, cid, endpoint) - - with allure.step(f"Put object"): - oid = put_object_to_random_node( - wallet, file_path, cid, shell=self.shell, cluster=self.cluster - ) - return cid, oid \ No newline at end of file + def check_for_the_uniqueness_of_the_nodes(self, nodes: list): + assert len(set(nodes)) == len(nodes), f"The nodes found must be unique, but {nodes}"