From 6128468310ccd96b8d75d0f464960541534bbe34 Mon Sep 17 00:00:00 2001 From: Ekaterina Chernitsyna Date: Wed, 25 Oct 2023 11:01:02 +0300 Subject: [PATCH] Update check filters results with 75% node the object appearance --- .../testsuites/container/test_policy.py | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/pytest_tests/testsuites/container/test_policy.py b/pytest_tests/testsuites/container/test_policy.py index 4978cff6..40087807 100644 --- a/pytest_tests/testsuites/container/test_policy.py +++ b/pytest_tests/testsuites/container/test_policy.py @@ -852,6 +852,7 @@ class TestPolicy(ClusterTestBase): 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" + expected_params = {"price": 65} file_path = generate_file(simple_object_size.value) expected_copies = 2 endpoint = self.cluster.default_rpc_endpoint @@ -874,9 +875,13 @@ class TestPolicy(ClusterTestBase): ), 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 - ) + 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 ( + int(netmap[node_address]["price"]) < expected_params["price"] + ), f"The node is selected from the wrong price. 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) @@ -894,7 +899,9 @@ class TestPolicy(ClusterTestBase): """ 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" + placement_rule = "REP 2 IN NODES75 SELECT 2 FROM LT65 AS NODES75 FILTER Continent NE America AS NOAM FILTER @NOAM AND Price LT 65 AS LT65" + expected_params = {"price": 65} + unexpected_params = {"continent": "America"} file_path = generate_file(simple_object_size.value) expected_copies = 3 endpoint = self.cluster.default_rpc_endpoint @@ -917,9 +924,16 @@ class TestPolicy(ClusterTestBase): ), 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 - ) + 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 ( + int(netmap[node_address]["price"]) < expected_params["price"] + and netmap[node_address]["continent"] == unexpected_params["continent"] + ) or ( + netmap[node_address]["continent"] == unexpected_params["continent"] + ), f"The node is selected from the wrong price or continent. 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) @@ -938,6 +952,8 @@ class TestPolicy(ClusterTestBase): 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" + expected_params = {"price": [65, 10]} + unexpected_params = {"continent": "America"} file_path = generate_file(simple_object_size.value) expected_copies = 4 endpoint = self.cluster.default_rpc_endpoint @@ -960,9 +976,21 @@ class TestPolicy(ClusterTestBase): ), 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 - ) + 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 ( + ( + int(netmap[node_address]["price"]) > expected_params["price"][1] + and netmap[node_address]["continent"] == unexpected_params["continent"] + ) + or ( + int(netmap[node_address]["price"]) < expected_params["price"][0] + and netmap[node_address]["continent"] == unexpected_params["continent"] + ) + or (netmap[node_address]["continent"] == unexpected_params["continent"]) + ), f"The node is selected from the wrong price or continent. 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) @@ -1055,7 +1083,7 @@ class TestPolicy(ClusterTestBase): 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" - expected_params = {"price": "0"} + expected_params = {"price": 0} file_path = generate_file(simple_object_size.value) expected_copies = 1 endpoint = self.cluster.default_rpc_endpoint @@ -1082,8 +1110,8 @@ class TestPolicy(ClusterTestBase): netmap = parse_netmap_output(get_netmap_snapshot(node=resulting_copies[0], shell=self.shell)) netmap = self.get_netmap_param(netmap) node_address = resulting_copies[0].get_rpc_endpoint().split(":")[0] - assert ( - expected_params["price"] == netmap[node_address]["price"] + assert expected_params["price"] >= int( + netmap[node_address]["price"] ), f"The node is selected from the wrong price. Expected {expected_params} and got {netmap[node_address]}" with allure.step(f"Delete the object from the container"):