From e14579f026bb4e763a06eb3fb9abd1cc320ffdc4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zayakin Date: Tue, 12 Dec 2023 09:57:34 +0300 Subject: [PATCH] [#173] Update network test Signed-off-by: Dmitriy Zayakin --- pytest_tests/testsuites/conftest.py | 2 +- .../failovers/test_failover_network.py | 72 ++++++++++--------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 8dbe6fa..8d57ba7 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -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)) diff --git a/pytest_tests/testsuites/failovers/test_failover_network.py b/pytest_tests/testsuites/failovers/test_failover_network.py index 2f7358a..1ca34a1 100644 --- a/pytest_tests/testsuites/failovers/test_failover_network.py +++ b/pytest_tests/testsuites/failovers/test_failover_network.py @@ -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,43 +149,45 @@ 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 - ] - blocked_nodes.append(*block_node) - excluded_nodes.append(node) - cluster_state_controller.drop_traffic( - mode="ports", - node=node, - wakeup_timeout=wakeup_node_timeout, - ports=PORTS_TO_BLOCK, - ) + 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 + ] + 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( + 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}"): - new_nodes = wait_object_replication( - cid, - oid, - 2, - shell=self.shell, - nodes=list(set(self.cluster.storage_nodes) - set(excluded_nodes)), - ) - assert node not in new_nodes + with reporter.step(f"Check object is not stored on node {node}"): + new_nodes = wait_object_replication( + cid, + oid, + 2, + shell=self.shell, + nodes=list(set(self.cluster.storage_nodes) - set(nodes_non_block)), + ) + 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) - assert get_file_hash(source_file_path) == get_file_hash(got_file_path) + 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 + ) + 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) - block_node = [ - cluster_node for cluster_node in self.cluster.cluster_nodes if cluster_node.storage_node == node - ] - blocked_nodes.remove(*block_node) - sleep(wakeup_node_timeout) + 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.storage_node + ] + blocked_nodes.remove(*block_node) + sleep(wakeup_node_timeout) with reporter.step("Check object data is not corrupted"): new_nodes = wait_object_replication(cid, oid, 2, shell=self.shell, nodes=self.cluster.storage_nodes)