[#173] Update network test

Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
Dmitriy Zayakin 2023-12-12 09:57:34 +03:00 committed by Dmitriy Zayakin
parent 7b688af84d
commit e14579f026
2 changed files with 38 additions and 36 deletions

View file

@ -57,7 +57,7 @@ def pytest_collection_modifyitems(items: list[pytest.Item]):
def priority(item: pytest.Item) -> int:
is_node_mgmt_test = 1 if item.get_closest_marker("node_mgmt") else 0
is_logs_check_test = 100 if item.get_closest_marker("logs_after_session") else 0
is_system_time_test = 10 if item.get_closest_marker("system_time") else 0
is_system_time_test = 10 if item.get_closest_marker("time") else 0
return is_node_mgmt_test + is_logs_check_test + is_system_time_test
items.sort(key=lambda item: priority(item))

View file

@ -51,7 +51,7 @@ class TestFailoverNetwork(ClusterTestBase):
not_empty = len(blocked_nodes) != 0
for node in list(blocked_nodes):
with reporter.step(f"Restore network for {node}"):
cluster_state_controller.restore_traffic(mode="ports", node=node)
cluster_state_controller.restore_traffic(node=node)
blocked_nodes.remove(node)
if not_empty:
parallel(healthcheck.storage_healthcheck, self.cluster.cluster_nodes)
@ -149,19 +149,16 @@ class TestFailoverNetwork(ClusterTestBase):
# TODO: the intent of this logic is not clear, need to revisit
nodes_to_block = random.choices(nodes, k=2)
excluded_nodes = []
for node in nodes_to_block:
with reporter.step(f"Block incoming traffic at node {node} on port {PORTS_TO_BLOCK}"):
block_node = [
cluster_node for cluster_node in self.cluster.cluster_nodes if cluster_node.storage_node == node
nodes_non_block = list(set(self.cluster.storage_nodes) - set(nodes_to_block))
nodes_non_block_cluster = [
cluster_node for cluster_node in self.cluster.cluster_nodes if cluster_node.storage_node in nodes_non_block
]
blocked_nodes.append(*block_node)
excluded_nodes.append(node)
with reporter.step("Block traffic and check corrupted object"):
for node in nodes_non_block_cluster:
with reporter.step(f"Block incoming traffic at node {node}"):
blocked_nodes.append(node)
cluster_state_controller.drop_traffic(
mode="ports",
node=node,
wakeup_timeout=wakeup_node_timeout,
ports=PORTS_TO_BLOCK,
node=node, wakeup_timeout=wakeup_node_timeout, name_interface="data", block_nodes=nodes_to_block
)
with reporter.step(f"Check object is not stored on node {node}"):
@ -170,19 +167,24 @@ class TestFailoverNetwork(ClusterTestBase):
oid,
2,
shell=self.shell,
nodes=list(set(self.cluster.storage_nodes) - set(excluded_nodes)),
nodes=list(set(self.cluster.storage_nodes) - set(nodes_non_block)),
)
assert node not in new_nodes
assert node.storage_node not in new_nodes
with reporter.step("Check object data is not corrupted"):
got_file_path = get_object(wallet, cid, oid, endpoint=new_nodes[0].get_rpc_endpoint(), shell=self.shell)
got_file_path = get_object(
wallet, cid, oid, endpoint=new_nodes[0].get_rpc_endpoint(), shell=self.shell
)
assert get_file_hash(source_file_path) == get_file_hash(got_file_path)
for node in nodes_to_block:
with reporter.step(f"Unblock incoming traffic at host {node} on port {PORTS_TO_BLOCK}"):
cluster_state_controller.restore_traffic(mode="ports", node=node)
with reporter.step(f"Unblock incoming traffic"):
for node in nodes_non_block_cluster:
with reporter.step(f"Unblock at host {node}"):
cluster_state_controller.restore_traffic(node=node)
block_node = [
cluster_node for cluster_node in self.cluster.cluster_nodes if cluster_node.storage_node == node
cluster_node
for cluster_node in self.cluster.cluster_nodes
if cluster_node.storage_node == node.storage_node
]
blocked_nodes.remove(*block_node)
sleep(wakeup_node_timeout)