diff --git a/pytest_tests/testsuites/container/test_policy.py b/pytest_tests/testsuites/container/test_policy.py index 8b207615..e26142fa 100644 --- a/pytest_tests/testsuites/container/test_policy.py +++ b/pytest_tests/testsuites/container/test_policy.py @@ -25,7 +25,6 @@ from pytest_tests.resources.policy_error_patterns import ( @pytest.mark.policy class TestPolicy(ClusterTestBase): @allure.title("[NEGATIVE] Placement policy: Can't parse placement policy") - @pytest.mark.policy def test_placement_policy_negative(self, default_wallet): """ Negative test for placement policy: Can't parse placement policy. @@ -43,7 +42,6 @@ class TestPolicy(ClusterTestBase): ) @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): """ Negative test for placement policy: Not enough nodes to SELECT. @@ -61,7 +59,6 @@ class TestPolicy(ClusterTestBase): ) @allure.title("[NEGATIVE] Placement policy: Filter not found") - @pytest.mark.policy def test_placement_policy_negative_not_enough_nodes_to_filter(self, default_wallet): """ Negative test for placement policy: Filter not found. @@ -79,7 +76,6 @@ class TestPolicy(ClusterTestBase): ) @allure.title("[NEGATIVE] Placement policy: SELECTOR not found") - @pytest.mark.policy def test_placement_policy_negative_not_enough_nodes_to_selector(self, default_wallet): """ Negative test for placement policy: Filter not found. @@ -96,7 +92,6 @@ class TestPolicy(ClusterTestBase): endpoint=endpoint, ) - @pytest.mark.policy @allure.title("Simple policy results with one node") def test_simple_policy_results_with_one_node( self, @@ -134,7 +129,6 @@ class TestPolicy(ClusterTestBase): 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 one node") def test_policy_with_select_results_with_one_node( self, @@ -172,7 +166,6 @@ class TestPolicy(ClusterTestBase): 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 one node") def test_policy_with_select_and_filter_results_with_one_node( self, @@ -219,7 +212,6 @@ class TestPolicy(ClusterTestBase): 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 one node") def test_policy_with_select_and_complex_filter_results_with_one_nodes( self, @@ -270,7 +262,6 @@ class TestPolicy(ClusterTestBase): 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 one node") def test_policy_with_multi_selects_and_filters_results_with_one_node( self, @@ -321,7 +312,6 @@ class TestPolicy(ClusterTestBase): 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 UNIQUE nodes") def test_policy_with_select_and_filter_results_with_unique_nodes( self, @@ -335,6 +325,7 @@ class TestPolicy(ClusterTestBase): file_path = generate_file(simple_object_size.value) expected_copies = 2 endpoint = self.cluster.default_rpc_endpoint + expected_params = {"country": "Russia"} with allure.step(f"Create container with policy {placement_rule}"): cid = create_container( @@ -355,6 +346,13 @@ class TestPolicy(ClusterTestBase): with allure.step(f"Check the object appearance"): self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + netmap = parse_netmap_output(get_netmap_snapshot(node=resulting_copies[0], shell=self.shell)) + netmap = self.get_netmap_param(netmap) + for node in resulting_copies: + node_address = node.get_rpc_endpoint().split(":")[0] + assert ( + expected_params["country"] == netmap[node_address]["country"] + ), f"The node is selected from the wrong country. Expected {expected_params['country']} and got {netmap[node_address]['country']}" with allure.step(f"Delete the container"): delete_container(wallet=default_wallet, cid=cid, shell=self.shell, endpoint=endpoint) @@ -362,7 +360,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -400,7 +397,6 @@ class TestPolicy(ClusterTestBase): 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 25% of available nodes") def test_policy_with_select_results_with_25_of_available_nodes( self, @@ -438,7 +434,6 @@ class TestPolicy(ClusterTestBase): 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 25% of available nodes") def test_policy_with_select_and_filter_results_with_25_of_available_nodes( self, @@ -481,7 +476,6 @@ class TestPolicy(ClusterTestBase): 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 25% of available nodes") def test_policy_with_select_and_complex_filter_results_with_25_of_available_nodes( self, @@ -524,7 +518,6 @@ class TestPolicy(ClusterTestBase): 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 25% of available nodes") def test_policy_with_multi_selects_and_filters_results_with_25_of_available_nodes( self, @@ -568,7 +561,6 @@ class TestPolicy(ClusterTestBase): 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 50% of available nodes") def test_simple_policy_results_with_50_of_available_nodes( self, @@ -606,7 +598,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -644,7 +635,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -687,7 +677,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -730,7 +719,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -773,7 +761,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -811,7 +798,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -849,7 +835,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -892,7 +877,6 @@ class TestPolicy(ClusterTestBase): 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 test_policy_with_select_and_complex_filter_results_with_75_of_available_nodes( self, @@ -935,7 +919,6 @@ class TestPolicy(ClusterTestBase): 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 test_policy_with_multi_selects_and_filters_results_with_75_of_available_nodes( self, @@ -978,7 +961,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1016,7 +998,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1054,7 +1035,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1097,7 +1077,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1140,7 +1119,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1183,7 +1161,6 @@ class TestPolicy(ClusterTestBase): 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 test_simple_policy_results_with_unique_nodes( self, @@ -1225,7 +1202,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1266,7 +1242,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1277,6 +1252,8 @@ class TestPolicy(ClusterTestBase): 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" + expected_params = {"country": "Russia"} + unexpected_params = {"country_code": "FI", "country": "Sweden"} file_path = generate_file(simple_object_size.value) expected_copies = 2 endpoint = self.cluster.default_rpc_endpoint @@ -1300,6 +1277,15 @@ class TestPolicy(ClusterTestBase): with allure.step(f"Check the object appearance"): self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + netmap = parse_netmap_output(get_netmap_snapshot(node=resulting_copies[0], shell=self.shell)) + netmap = self.get_netmap_param(netmap) + for node in resulting_copies: + node_address = node.get_rpc_endpoint().split(":")[0] + assert not (unexpected_params["country"] == netmap[node_address]["country"]) or ( + not (unexpected_params["country"] == netmap[node_address]["country"]) + and not (expected_params["country_code"] == netmap[node_address]["country_code"]) + or (expected_params["country"] == netmap[node_address]["country"]) + ), f"The node is selected from the wrong country or country code. Expected {expected_params} and got {netmap[node_address]}" with allure.step(f"Delete the object from the container"): delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) @@ -1307,7 +1293,6 @@ class TestPolicy(ClusterTestBase): 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, @@ -1318,6 +1303,8 @@ class TestPolicy(ClusterTestBase): 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" + expected_params = {"country": ["Russia", "Sweden"], "country_code": "FI"} + unexpected_params = {"country": "Russia"} file_path = generate_file(simple_object_size.value) expected_copies = 3 endpoint = self.cluster.default_rpc_endpoint @@ -1341,6 +1328,15 @@ class TestPolicy(ClusterTestBase): with allure.step(f"Check the object appearance"): self.check_for_the_uniqueness_of_the_nodes(resulting_copies) + netmap = parse_netmap_output(get_netmap_snapshot(node=resulting_copies[0], shell=self.shell)) + netmap = self.get_netmap_param(netmap) + for node in resulting_copies: + node_address = node.get_rpc_endpoint().split(":")[0] + assert (expected_params["country"][0] == netmap[node_address]["country"]) or ( + not (unexpected_params["country"][0] == netmap[node_address]["country"]) + and (expected_params["country"][1] == netmap[node_address]["country"]) + or (expected_params["country_code"] == netmap[node_address]["country_code"]) + ), f"The node is selected from the wrong country or country code. Expected {expected_params} and got {netmap[node_address]}" with allure.step(f"Delete the object from the container"): delete_object(wallet=default_wallet, cid=cid, oid=oid, shell=self.shell, endpoint=endpoint) @@ -1348,7 +1344,6 @@ class TestPolicy(ClusterTestBase): 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: REP 1 IN SPB REP 1 IN MSK REP 3") def test_policy_rep_1_in_spb_rep_1_in_msk_rep_3( self,