2022-08-01 06:16:36 +00:00
|
|
|
import logging
|
2023-05-15 09:59:33 +00:00
|
|
|
import random
|
2022-08-01 06:16:36 +00:00
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2023-11-22 14:26:59 +00:00
|
|
|
from frostfs_testlib.healthcheck.interfaces import Healthcheck
|
2024-01-22 11:29:49 +00:00
|
|
|
from frostfs_testlib.resources.wellknown_acl import EACL_PUBLIC_READ_WRITE, PUBLIC_ACL
|
2023-10-03 10:54:53 +00:00
|
|
|
from frostfs_testlib.steps.cli.container import create_container
|
2024-07-29 13:43:19 +00:00
|
|
|
from frostfs_testlib.steps.cli.object import get_object, get_object_nodes, neo_go_query_height, put_object, put_object_to_random_node
|
2023-10-10 13:39:24 +00:00
|
|
|
from frostfs_testlib.steps.storage_object import delete_objects
|
2023-10-03 10:54:53 +00:00
|
|
|
from frostfs_testlib.storage.cluster import ClusterNode
|
2023-08-16 08:53:14 +00:00
|
|
|
from frostfs_testlib.storage.controllers import ClusterStateController
|
2023-08-02 11:54:03 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
2023-10-24 12:17:30 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.storage_object_info import Interfaces, StorageObjectInfo
|
2024-03-11 16:34:54 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
2023-11-22 14:26:59 +00:00
|
|
|
from frostfs_testlib.testing.parallel import parallel
|
|
|
|
from frostfs_testlib.utils.failover_utils import wait_object_replication
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.utils.file_utils import generate_file, get_file_hash
|
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
logger = logging.getLogger("NeoLogger")
|
|
|
|
STORAGE_NODE_COMMUNICATION_PORT = "8080"
|
|
|
|
STORAGE_NODE_COMMUNICATION_PORT_TLS = "8082"
|
2022-08-01 06:16:36 +00:00
|
|
|
PORTS_TO_BLOCK = [STORAGE_NODE_COMMUNICATION_PORT, STORAGE_NODE_COMMUNICATION_PORT_TLS]
|
2023-08-16 08:53:14 +00:00
|
|
|
blocked_nodes: list[ClusterNode] = []
|
2023-10-10 13:39:24 +00:00
|
|
|
|
|
|
|
OBJECT_ATTRIBUTES = [
|
|
|
|
None,
|
|
|
|
{"key1": 1, "key2": "abc", "common_key": "common_value"},
|
|
|
|
{"key1": 2, "common_key": "common_value"},
|
|
|
|
]
|
2023-08-16 08:53:14 +00:00
|
|
|
|
|
|
|
|
2022-08-01 06:16:36 +00:00
|
|
|
@pytest.mark.failover
|
2022-11-10 05:27:52 +00:00
|
|
|
@pytest.mark.failover_network
|
2022-12-05 22:31:45 +00:00
|
|
|
class TestFailoverNetwork(ClusterTestBase):
|
|
|
|
@pytest.fixture(autouse=True)
|
2023-07-12 09:05:36 +00:00
|
|
|
@allure.title("Restore network")
|
2023-11-22 14:26:59 +00:00
|
|
|
def restore_network(self, healthcheck: Healthcheck, cluster_state_controller: ClusterStateController):
|
2022-12-05 22:31:45 +00:00
|
|
|
yield
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Count blocked nodes {len(blocked_nodes)}"):
|
2023-07-12 09:05:36 +00:00
|
|
|
not_empty = len(blocked_nodes) != 0
|
2022-12-05 22:31:45 +00:00
|
|
|
for node in list(blocked_nodes):
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Restore network for {node}"):
|
2023-12-12 06:57:34 +00:00
|
|
|
cluster_state_controller.restore_traffic(node=node)
|
2022-12-05 22:31:45 +00:00
|
|
|
blocked_nodes.remove(node)
|
|
|
|
if not_empty:
|
2023-11-22 14:26:59 +00:00
|
|
|
parallel(healthcheck.storage_healthcheck, self.cluster.cluster_nodes)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-10-10 13:39:24 +00:00
|
|
|
@pytest.fixture()
|
|
|
|
@allure.title("Restore drop traffic to system")
|
2023-10-24 12:17:30 +00:00
|
|
|
def restore_down_interfaces(self, cluster_state_controller: ClusterStateController):
|
2023-10-10 13:39:24 +00:00
|
|
|
yield
|
|
|
|
cluster_state_controller.restore_interfaces()
|
|
|
|
|
|
|
|
@pytest.fixture()
|
2023-10-12 07:30:13 +00:00
|
|
|
def storage_objects(
|
|
|
|
self,
|
|
|
|
simple_object_size: ObjectSize,
|
2024-03-11 16:34:54 +00:00
|
|
|
default_wallet: WalletInfo,
|
2023-10-12 07:30:13 +00:00
|
|
|
) -> list[StorageObjectInfo]:
|
2023-10-10 13:39:24 +00:00
|
|
|
|
|
|
|
file_path = generate_file(simple_object_size.value)
|
|
|
|
file_hash = get_file_hash(file_path)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create container"):
|
2023-10-12 07:30:13 +00:00
|
|
|
placement_rule = "REP 1 CBF 1"
|
2023-10-10 13:39:24 +00:00
|
|
|
cid = create_container(
|
|
|
|
wallet=default_wallet,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
|
|
|
rule=placement_rule,
|
|
|
|
await_mode=True,
|
2024-01-22 11:29:49 +00:00
|
|
|
basic_acl=EACL_PUBLIC_READ_WRITE,
|
2023-10-10 13:39:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
storage_objects = []
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put object"):
|
2023-10-10 13:39:24 +00:00
|
|
|
for attribute in OBJECT_ATTRIBUTES:
|
|
|
|
oid = put_object_to_random_node(
|
|
|
|
wallet=default_wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
|
|
|
)
|
|
|
|
|
|
|
|
storage_object = StorageObjectInfo(cid=cid, oid=oid)
|
|
|
|
storage_object.size = simple_object_size.value
|
2024-03-11 16:34:54 +00:00
|
|
|
storage_object.wallet = default_wallet
|
2023-10-10 13:39:24 +00:00
|
|
|
storage_object.file_path = file_path
|
|
|
|
storage_object.file_hash = file_hash
|
|
|
|
storage_object.attributes = attribute
|
|
|
|
|
|
|
|
storage_objects.append(storage_object)
|
|
|
|
|
2024-07-29 13:43:19 +00:00
|
|
|
return storage_objects
|
2023-10-10 13:39:24 +00:00
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
@allure.title("Block Storage node traffic")
|
2022-12-07 12:38:56 +00:00
|
|
|
def test_block_storage_node_traffic(
|
2023-07-12 09:05:36 +00:00
|
|
|
self,
|
2024-03-11 16:34:54 +00:00
|
|
|
default_wallet: WalletInfo,
|
2023-07-12 09:05:36 +00:00
|
|
|
require_multiple_hosts,
|
2023-08-02 11:54:03 +00:00
|
|
|
simple_object_size: ObjectSize,
|
2023-08-16 08:53:14 +00:00
|
|
|
cluster_state_controller: ClusterStateController,
|
2022-12-07 12:38:56 +00:00
|
|
|
):
|
2022-12-05 22:31:45 +00:00
|
|
|
"""
|
|
|
|
Block storage nodes traffic using iptables and wait for replication for objects.
|
|
|
|
"""
|
|
|
|
wallet = default_wallet
|
|
|
|
placement_rule = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"
|
|
|
|
wakeup_node_timeout = 10 # timeout to let nodes detect that traffic has blocked
|
|
|
|
nodes_to_block_count = 2
|
|
|
|
|
2023-08-02 11:54:03 +00:00
|
|
|
source_file_path = generate_file(simple_object_size.value)
|
2022-12-05 22:31:45 +00:00
|
|
|
cid = create_container(
|
|
|
|
wallet,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
|
|
|
rule=placement_rule,
|
|
|
|
basic_acl=PUBLIC_ACL,
|
|
|
|
)
|
2023-10-10 13:39:24 +00:00
|
|
|
oid = put_object_to_random_node(wallet, source_file_path, cid, shell=self.shell, cluster=self.cluster)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-10-10 13:39:24 +00:00
|
|
|
nodes = wait_object_replication(cid, oid, 2, shell=self.shell, nodes=self.cluster.storage_nodes)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
|
|
|
logger.info(f"Nodes are {nodes}")
|
|
|
|
nodes_to_block = nodes
|
|
|
|
if nodes_to_block_count > len(nodes):
|
|
|
|
# TODO: the intent of this logic is not clear, need to revisit
|
2023-05-15 09:59:33 +00:00
|
|
|
nodes_to_block = random.choices(nodes, k=2)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-12-12 06:57:34 +00:00
|
|
|
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(nodes_non_block)),
|
|
|
|
)
|
|
|
|
assert node.storage_node not in new_nodes
|
|
|
|
|
|
|
|
with reporter.step("Check object data is not corrupted"):
|
2024-07-29 13:43:19 +00:00
|
|
|
got_file_path = get_object(wallet, cid, oid, endpoint=new_nodes[0].get_rpc_endpoint(), shell=self.shell)
|
2023-12-12 06:57:34 +00:00
|
|
|
assert get_file_hash(source_file_path) == get_file_hash(got_file_path)
|
|
|
|
|
|
|
|
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 = [
|
2024-07-29 13:43:19 +00:00
|
|
|
cluster_node for cluster_node in self.cluster.cluster_nodes if cluster_node.storage_node == node.storage_node
|
2023-12-12 06:57:34 +00:00
|
|
|
]
|
|
|
|
blocked_nodes.remove(*block_node)
|
|
|
|
sleep(wakeup_node_timeout)
|
2022-10-13 16:13:45 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check object data is not corrupted"):
|
2023-10-10 13:39:24 +00:00
|
|
|
new_nodes = wait_object_replication(cid, oid, 2, shell=self.shell, nodes=self.cluster.storage_nodes)
|
|
|
|
|
|
|
|
got_file_path = get_object(wallet, cid, oid, shell=self.shell, endpoint=new_nodes[0].get_rpc_endpoint())
|
|
|
|
assert get_file_hash(source_file_path) == get_file_hash(got_file_path)
|
|
|
|
|
2023-10-12 07:30:13 +00:00
|
|
|
@pytest.mark.interfaces
|
2023-10-10 13:39:24 +00:00
|
|
|
@allure.title("Block DATA interface node")
|
|
|
|
def test_block_data_interface(
|
|
|
|
self,
|
|
|
|
cluster_state_controller: ClusterStateController,
|
2024-03-11 16:34:54 +00:00
|
|
|
default_wallet: WalletInfo,
|
2023-10-24 12:17:30 +00:00
|
|
|
restore_down_interfaces: None,
|
2023-10-10 13:39:24 +00:00
|
|
|
storage_objects: list[StorageObjectInfo],
|
|
|
|
):
|
|
|
|
storage_object = storage_objects[0]
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Search nodes with object"):
|
2023-10-10 13:39:24 +00:00
|
|
|
nodes_with_object = get_object_nodes(
|
|
|
|
cluster=self.cluster,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
oid=storage_object.oid,
|
2024-01-22 11:29:49 +00:00
|
|
|
alive_node=self.cluster.cluster_nodes[0],
|
2022-12-05 22:31:45 +00:00
|
|
|
)
|
2022-08-01 06:16:36 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get data interface to node"):
|
2023-10-10 13:39:24 +00:00
|
|
|
config_interfaces = list(nodes_with_object[0].host.config.interfaces.keys())
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Get data in {config_interfaces}"):
|
2023-10-12 07:30:13 +00:00
|
|
|
data_interfaces = [interface for interface in config_interfaces if "data" in interface]
|
2023-10-10 13:39:24 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Block data interfaces for node"):
|
2023-10-10 13:39:24 +00:00
|
|
|
for interface in data_interfaces:
|
|
|
|
cluster_state_controller.down_interface(nodes=nodes_with_object, interface=interface)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick epoch and wait 2 block"):
|
2023-10-10 13:39:24 +00:00
|
|
|
nodes_without_an_object = list(set(self.cluster.cluster_nodes) - set(nodes_with_object))
|
|
|
|
self.tick_epochs(1, alive_node=nodes_without_an_object[0].storage_node, wait_block=2)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get object for target nodes to data interfaces, expect false"):
|
2024-08-16 09:07:50 +00:00
|
|
|
with pytest.raises(RuntimeError, match="can't create API client: can't init SDK client: gRPC dial: context deadline exceeded"):
|
2023-10-10 13:39:24 +00:00
|
|
|
get_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
oid=storage_object.oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=nodes_with_object[0].storage_node.get_rpc_endpoint(),
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Get object others nodes, expect true"):
|
2023-10-10 13:39:24 +00:00
|
|
|
input_file = get_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
oid=storage_object.oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=nodes_without_an_object[0].storage_node.get_rpc_endpoint(),
|
2022-12-05 22:31:45 +00:00
|
|
|
)
|
2023-10-12 07:30:13 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Restore interface and tick 1 epoch, wait 2 block"):
|
2023-10-12 07:30:13 +00:00
|
|
|
cluster_state_controller.restore_interfaces()
|
|
|
|
self.tick_epochs(1, alive_node=nodes_without_an_object[0].storage_node, wait_block=2)
|
|
|
|
|
|
|
|
@pytest.mark.interfaces
|
|
|
|
@allure.title("Block INTERNAL interface node")
|
|
|
|
def test_block_internal_interface(
|
|
|
|
self,
|
|
|
|
cluster_state_controller: ClusterStateController,
|
2024-03-11 16:34:54 +00:00
|
|
|
default_wallet: WalletInfo,
|
2023-10-24 12:17:30 +00:00
|
|
|
restore_down_interfaces: None,
|
2023-10-12 07:30:13 +00:00
|
|
|
storage_objects: list[StorageObjectInfo],
|
|
|
|
simple_object_size: ObjectSize,
|
|
|
|
):
|
|
|
|
storage_object = storage_objects[0]
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Search nodes with object"):
|
2023-10-12 07:30:13 +00:00
|
|
|
nodes_with_object = get_object_nodes(
|
|
|
|
cluster=self.cluster,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
oid=storage_object.oid,
|
2024-01-22 11:29:49 +00:00
|
|
|
alive_node=self.cluster.cluster_nodes[0],
|
2023-10-12 07:30:13 +00:00
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get internal interface to node"):
|
2023-10-12 07:30:13 +00:00
|
|
|
config_interfaces = list(nodes_with_object[0].host.config.interfaces.keys())
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Get internal in {config_interfaces}"):
|
2023-10-12 07:30:13 +00:00
|
|
|
internal_interfaces = [interface for interface in config_interfaces if "internal" in interface]
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Block internal interfaces for node"):
|
2023-10-12 07:30:13 +00:00
|
|
|
for interface in internal_interfaces:
|
|
|
|
cluster_state_controller.down_interface(nodes=nodes_with_object, interface=interface)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick epoch and wait 2 block"):
|
2023-10-12 07:30:13 +00:00
|
|
|
nodes_without_an_object = list(set(self.cluster.cluster_nodes) - set(nodes_with_object))
|
|
|
|
self.tick_epochs(1, alive_node=nodes_without_an_object[0].storage_node, wait_block=2)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get object others node, expect false"):
|
2024-07-29 13:43:19 +00:00
|
|
|
with pytest.raises(RuntimeError, match="rpc error"):
|
2023-10-12 07:30:13 +00:00
|
|
|
get_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
oid=storage_object.oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=nodes_without_an_object[0].storage_node.get_rpc_endpoint(),
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put object, others node, expect false"):
|
2024-07-29 13:43:19 +00:00
|
|
|
with pytest.raises(RuntimeError, match="rpc error"):
|
2023-10-12 07:30:13 +00:00
|
|
|
put_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
path=storage_object.file_path,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=nodes_without_an_object[0].storage_node.get_rpc_endpoint(),
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Get object nodes with object, expect true"):
|
2023-10-12 07:30:13 +00:00
|
|
|
input_file = get_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
oid=storage_object.oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=nodes_with_object[0].storage_node.get_rpc_endpoint(),
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Put object nodes with object, expect true"):
|
2023-10-12 07:30:13 +00:00
|
|
|
temp_file_path = generate_file(simple_object_size.value)
|
|
|
|
_ = put_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
path=temp_file_path,
|
|
|
|
cid=storage_object.cid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=nodes_with_object[0].storage_node.get_rpc_endpoint(),
|
|
|
|
)
|
2024-07-29 13:43:19 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Restore interface and tick 1 epoch, wait 2 block"):
|
2023-10-12 07:30:13 +00:00
|
|
|
cluster_state_controller.restore_interfaces()
|
|
|
|
self.tick_epochs(1, alive_node=nodes_without_an_object[0].storage_node, wait_block=2)
|
2023-10-24 12:17:30 +00:00
|
|
|
|
|
|
|
@pytest.mark.interfaces
|
2023-10-25 12:56:59 +00:00
|
|
|
@pytest.mark.failover_baremetal
|
2023-10-24 12:17:30 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"block_interface, other_interface",
|
|
|
|
[(Interfaces.DATA_O, Interfaces.DATA_1), (Interfaces.DATA_1, Interfaces.DATA_O)],
|
|
|
|
)
|
|
|
|
@allure.title("Down data interfaces to all nodes(interface={block_interface})")
|
|
|
|
def test_down_data_interface(
|
|
|
|
self,
|
2023-10-25 12:56:59 +00:00
|
|
|
require_multiple_interfaces,
|
2023-10-24 12:17:30 +00:00
|
|
|
cluster_state_controller: ClusterStateController,
|
2024-03-11 16:34:54 +00:00
|
|
|
default_wallet: WalletInfo,
|
2023-10-24 12:17:30 +00:00
|
|
|
simple_object_size: ObjectSize,
|
|
|
|
restore_down_interfaces: None,
|
|
|
|
block_interface: Interfaces,
|
|
|
|
other_interface: Interfaces,
|
|
|
|
):
|
|
|
|
cluster_nodes = self.cluster.cluster_nodes
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Block {block_interface.value} interfaces"):
|
2023-10-24 12:17:30 +00:00
|
|
|
cluster_state_controller.down_interface(cluster_nodes, block_interface.value)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick 1 epoch and wait 2 block for sync all nodes"):
|
2023-10-24 12:17:30 +00:00
|
|
|
self.tick_epochs(1, alive_node=cluster_nodes[0].storage_node, wait_block=2)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create container"):
|
2023-10-24 12:17:30 +00:00
|
|
|
cid = create_container(
|
|
|
|
wallet=default_wallet,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=f"{cluster_nodes[0].get_data_interface(other_interface.value)[0]}:8080",
|
|
|
|
rule="REP 4 CBF 1",
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put object"):
|
2023-10-24 12:17:30 +00:00
|
|
|
file_path = generate_file(simple_object_size.value)
|
|
|
|
|
|
|
|
oid = put_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=f"{cluster_nodes[0].get_data_interface(other_interface.value)[0]}:8080",
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get object"):
|
2023-10-24 12:17:30 +00:00
|
|
|
file_get_path = get_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
cid=cid,
|
|
|
|
oid=oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=f"{cluster_nodes[0].get_data_interface(other_interface.value)[0]}:8080",
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Restore interfaces all nodes"):
|
2023-10-24 12:17:30 +00:00
|
|
|
cluster_state_controller.restore_interfaces()
|
|
|
|
self.tick_epochs(1, alive_node=cluster_nodes[0].storage_node, wait_block=2)
|
|
|
|
|
|
|
|
@pytest.mark.interfaces
|
2023-10-25 12:56:59 +00:00
|
|
|
@pytest.mark.failover_baremetal
|
2023-10-24 12:17:30 +00:00
|
|
|
@pytest.mark.parametrize("interface", [Interfaces.INTERNAL_0, Interfaces.INTERNAL_1])
|
|
|
|
@allure.title("Down internal interfaces to all nodes(interface={interface})")
|
|
|
|
def test_down_internal_interface(
|
|
|
|
self,
|
2023-10-25 12:56:59 +00:00
|
|
|
require_multiple_interfaces,
|
2023-10-24 12:17:30 +00:00
|
|
|
cluster_state_controller: ClusterStateController,
|
2024-03-11 16:34:54 +00:00
|
|
|
default_wallet: WalletInfo,
|
2023-10-24 12:17:30 +00:00
|
|
|
simple_object_size: ObjectSize,
|
|
|
|
restore_down_interfaces: None,
|
|
|
|
interface: Interfaces,
|
|
|
|
):
|
|
|
|
cluster_nodes = self.cluster.cluster_nodes
|
|
|
|
latest_block = {}
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get block all nodes"):
|
2023-10-24 12:17:30 +00:00
|
|
|
for cluster_node in cluster_nodes:
|
|
|
|
latest_block[cluster_node] = neo_go_query_height(
|
|
|
|
shell=cluster_node.host.get_shell(), endpoint=cluster_node.morph_chain.get_http_endpoint()
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Block {interface} interfaces"):
|
2023-10-24 12:17:30 +00:00
|
|
|
cluster_state_controller.down_interface(cluster_nodes, interface.value)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Tick 1 epoch and wait 2 block for sync all nodes"):
|
2023-10-24 12:17:30 +00:00
|
|
|
self.tick_epochs(1, alive_node=cluster_nodes[0].storage_node, wait_block=2)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create container"):
|
2023-10-24 12:17:30 +00:00
|
|
|
cid = create_container(
|
|
|
|
wallet=default_wallet,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
|
|
|
rule="REP 4 CBF 1",
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Put object, after down {interface}"):
|
2023-10-24 12:17:30 +00:00
|
|
|
file_path = generate_file(simple_object_size.value)
|
|
|
|
|
|
|
|
oid = put_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get object"):
|
2023-10-24 12:17:30 +00:00
|
|
|
file_get_path = get_object(
|
|
|
|
wallet=default_wallet,
|
|
|
|
cid=cid,
|
|
|
|
oid=oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
|
|
|
)
|
|
|
|
|
|
|
|
now_block = {}
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get actual block"):
|
2023-10-24 12:17:30 +00:00
|
|
|
for cluster_node in cluster_nodes:
|
|
|
|
now_block[cluster_node] = neo_go_query_height(
|
|
|
|
shell=cluster_node.host.get_shell(), endpoint=cluster_node.morph_chain.get_http_endpoint()
|
|
|
|
)
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Compare block"):
|
2023-10-24 12:17:30 +00:00
|
|
|
for cluster_node, items in now_block.items():
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(
|
2023-10-24 12:17:30 +00:00
|
|
|
f"Node - {cluster_node.host_ip}, old block - {latest_block[cluster_node]['Latest block']}, "
|
|
|
|
f"now block - {now_block[cluster_node]['Latest block']}"
|
|
|
|
):
|
|
|
|
assert latest_block[cluster_node]["Latest block"] < now_block[cluster_node]["Latest block"]
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Restore interfaces all nodes"):
|
2023-10-24 12:17:30 +00:00
|
|
|
cluster_state_controller.restore_interfaces()
|
|
|
|
self.tick_epochs(1, alive_node=self.cluster.cluster_nodes[0].storage_node, wait_block=2)
|