Update check filters results with 50% node the object appearance

This commit is contained in:
Ekaterina Chernitsyna 2023-10-25 14:23:23 +03:00 committed by Andrey Berezin
parent e7e963b1a1
commit eee02d1346

View file

@ -649,6 +649,7 @@ class TestPolicy(ClusterTestBase):
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"
expected_params = {"price": 15}
file_path = generate_file(simple_object_size.value)
expected_copies = 2
endpoint = self.cluster.default_rpc_endpoint
@ -671,9 +672,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)
@ -692,6 +697,8 @@ class TestPolicy(ClusterTestBase):
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"
expected_params = {"price": 15}
unexpected_params = {"country_code": "RU"}
file_path = generate_file(simple_object_size.value)
expected_copies = 2
endpoint = self.cluster.default_rpc_endpoint
@ -714,9 +721,14 @@ 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 (not netmap[node_address]["country_code"] == unexpected_params["country_code"]) or (
not netmap[node_address]["country_code"] == unexpected_params["country_code"]
and int(netmap[node_address]["price"]) >= expected_params["price"]
), f"The node is selected from the wrong price 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)
@ -735,6 +747,7 @@ class TestPolicy(ClusterTestBase):
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"
expected_params = {"un_locode": ["RU_LED", "RU_MOW"], "price": [15, 55]}
file_path = generate_file(simple_object_size.value)
expected_copies = 4
endpoint = self.cluster.default_rpc_endpoint
@ -757,9 +770,22 @@ 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 (
(netmap[node_address]["un_locode"] in expected_params["un_locode"])
or (not netmap[node_address]["un_locode"] in expected_params["un_locode"])
or (
not netmap[node_address]["un_locode"] in expected_params["un_locode"]
and int(netmap[node_address]["price"]) >= expected_params["price"][0]
)
or (
netmap[node_address]["un_locode"] in expected_params["un_locode"]
and int(netmap[node_address]["price"]) <= expected_params["price"][1]
)
), f"The node is selected from the wrong price or un_locode. 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)
@ -1110,8 +1136,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"] >= int(
netmap[node_address]["price"]
assert netmap[node_address]["price"] >= int(
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"):
@ -1465,5 +1491,6 @@ class TestPolicy(ClusterTestBase):
"country_code": node.country_code,
"price": node.price,
"continent": node.continent,
"un_locode": node.un_locode,
}
return dict_external