From 00f312dab917657b4f8fe2de7a365945fe007c6a Mon Sep 17 00:00:00 2001 From: Ekaterina Chernitsyna Date: Wed, 25 Oct 2023 14:33:23 +0300 Subject: [PATCH] Update check filters results with 25% node the object appearance --- .../testsuites/container/test_policy.py | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/pytest_tests/testsuites/container/test_policy.py b/pytest_tests/testsuites/container/test_policy.py index 7bc23b7d..b5ed6bad 100644 --- a/pytest_tests/testsuites/container/test_policy.py +++ b/pytest_tests/testsuites/container/test_policy.py @@ -445,6 +445,7 @@ class TestPolicy(ClusterTestBase): This test checks object's copies based on container's placement policy with SELECT and FILTER results with 25% of available nodes. """ placement_rule = "REP 1 IN Nodes25 SELECT 1 FROM LE10 AS Nodes25 FILTER Price LE 10 AS LE10" + expected_params = {"price": 10} file_path = generate_file(simple_object_size.value) expected_copies = 1 endpoint = self.cluster.default_rpc_endpoint @@ -467,9 +468,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) @@ -488,6 +493,7 @@ class TestPolicy(ClusterTestBase): This test checks object's copies based on container's placement policy with SELECT and Complex FILTER results with 25% of available nodes. """ 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" + expected_params = {"price": [10, 0]} file_path = generate_file(simple_object_size.value) expected_copies = 1 endpoint = self.cluster.default_rpc_endpoint @@ -510,9 +516,18 @@ 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] + or int(netmap[node_address]["price"]) <= expected_params["price"][0] + or ( + int(netmap[node_address]["price"]) > expected_params["price"][1] + and int(netmap[node_address]["price"]) <= expected_params["price"][0] + ) + ), 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) @@ -531,6 +546,7 @@ class TestPolicy(ClusterTestBase): This test checks object's copies based on container's placement policy with Multi SELECTs and FILTERs results with 25% of available nodes. """ 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" + expected_params = {"price": [15, 55]} file_path = generate_file(simple_object_size.value) expected_copies = 2 endpoint = self.cluster.default_rpc_endpoint @@ -553,9 +569,18 @@ 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] + or int(netmap[node_address]["price"]) < expected_params["price"][0] + or ( + int(netmap[node_address]["price"]) > expected_params["price"][1] + or int(netmap[node_address]["price"]) < expected_params["price"][0] + ) + ), f"The node is selected from the wrong price. Expected {expected_params} and got {netmap[node_address]}" self.check_for_the_uniqueness_of_the_nodes(resulting_copies) with allure.step(f"Delete the object from the container"):