Fix test shutdown node
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
dd7f91e66b
commit
6f77a6ab08
1 changed files with 26 additions and 37 deletions
|
@ -13,12 +13,9 @@ from frostfs_testlib.steps.cli.container import (
|
||||||
create_container,
|
create_container,
|
||||||
)
|
)
|
||||||
from frostfs_testlib.steps.cli.object import get_object
|
from frostfs_testlib.steps.cli.object import get_object
|
||||||
from frostfs_testlib.steps.node_management import (
|
from frostfs_testlib.steps.node_management import check_node_in_map, check_node_not_in_map
|
||||||
check_node_in_map,
|
|
||||||
check_node_not_in_map,
|
|
||||||
wait_for_node_to_be_ready,
|
|
||||||
)
|
|
||||||
from frostfs_testlib.storage.cluster import ClusterNode, StorageNode
|
from frostfs_testlib.storage.cluster import ClusterNode, StorageNode
|
||||||
|
from frostfs_testlib.storage.controllers import ClusterStateController
|
||||||
from frostfs_testlib.storage.dataclasses.storage_object_info import StorageObjectInfo
|
from frostfs_testlib.storage.dataclasses.storage_object_info import StorageObjectInfo
|
||||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||||
|
@ -72,27 +69,21 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
|
|
||||||
return containers
|
return containers
|
||||||
|
|
||||||
@pytest.fixture(
|
|
||||||
params=[
|
|
||||||
pytest.lazy_fixture("simple_object_size"),
|
|
||||||
pytest.lazy_fixture("complex_object_size"),
|
|
||||||
],
|
|
||||||
ids=["simple object", "complex object"],
|
|
||||||
# Scope session to upload/delete each files set only once
|
|
||||||
scope="class",
|
|
||||||
)
|
|
||||||
def object_size(self, request):
|
|
||||||
return request.param
|
|
||||||
|
|
||||||
@allure.step("Create object and delete after test")
|
@allure.step("Create object and delete after test")
|
||||||
@pytest.fixture(scope="class")
|
@pytest.fixture(scope="class")
|
||||||
def storage_objects(
|
def storage_objects(
|
||||||
self, request: FixtureRequest, containers: list[StorageContainer], object_size: int
|
self,
|
||||||
|
request: FixtureRequest,
|
||||||
|
containers: list[StorageContainer],
|
||||||
|
simple_object_size: int,
|
||||||
|
complex_object_size: int,
|
||||||
) -> StorageObjectInfo:
|
) -> StorageObjectInfo:
|
||||||
|
count_object = request.param
|
||||||
|
object_size = [simple_object_size, complex_object_size]
|
||||||
object_list = []
|
object_list = []
|
||||||
for cont in containers:
|
for cont in containers:
|
||||||
for _ in range(request.param):
|
for _ in range(count_object):
|
||||||
object_list.append(cont.generate_object(size=object_size))
|
object_list.append(cont.generate_object(size=random.choice(object_size)))
|
||||||
|
|
||||||
yield object_list
|
yield object_list
|
||||||
|
|
||||||
|
@ -101,13 +92,12 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
|
|
||||||
@allure.step("Select random node to stop and start it after test")
|
@allure.step("Select random node to stop and start it after test")
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def node_to_stop(self) -> ClusterNode:
|
def node_to_stop(
|
||||||
node = random.choice(self.cluster.cluster_nodes)
|
self, node_under_test: ClusterNode, cluster_state_controller: ClusterStateController
|
||||||
yield node
|
) -> ClusterNode:
|
||||||
with allure.step(f"start {node.storage_node}"):
|
yield node_under_test
|
||||||
node.host.start_host()
|
with allure.step(f"start {node_under_test.storage_node}"):
|
||||||
with allure.step(f"Waiting status ready for node {node.storage_node}"):
|
cluster_state_controller.start_stopped_hosts()
|
||||||
wait_for_node_to_be_ready(node.storage_node)
|
|
||||||
|
|
||||||
@allure.step("Upload object with nodes and compare")
|
@allure.step("Upload object with nodes and compare")
|
||||||
def get_corrupted_objects_list(
|
def get_corrupted_objects_list(
|
||||||
|
@ -145,13 +135,14 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
)
|
)
|
||||||
|
|
||||||
@allure.title("Full shutdown node")
|
@allure.title("Full shutdown node")
|
||||||
@pytest.mark.parametrize("containers, storage_objects", [(5, 20)], indirect=True)
|
@pytest.mark.parametrize("containers, storage_objects", [(5, 10)], indirect=True)
|
||||||
def test_complete_node_shutdown(
|
def test_complete_node_shutdown(
|
||||||
self,
|
self,
|
||||||
containers: list[StorageContainer],
|
containers: list[StorageContainer],
|
||||||
storage_objects: list[StorageObjectInfo],
|
storage_objects: list[StorageObjectInfo],
|
||||||
default_wallet: str,
|
default_wallet: str,
|
||||||
node_to_stop: ClusterNode,
|
node_to_stop: ClusterNode,
|
||||||
|
cluster_state_controller: ClusterStateController,
|
||||||
):
|
):
|
||||||
with allure.step("Checking that the objects are loader according to the policy"):
|
with allure.step("Checking that the objects are loader according to the policy"):
|
||||||
self.check_objects_replication(storage_objects, self.cluster.storage_nodes)
|
self.check_objects_replication(storage_objects, self.cluster.storage_nodes)
|
||||||
|
@ -167,8 +158,7 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
with allure.step("Wait 2 block time"):
|
with allure.step("Wait 2 block time"):
|
||||||
time.sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 2)
|
time.sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 2)
|
||||||
|
|
||||||
with allure.step(f"Stop {node_to_stop} node"):
|
cluster_state_controller.stop_node_host(node=node_to_stop, mode="hard")
|
||||||
node_to_stop.host.stop_host(mode="hard")
|
|
||||||
|
|
||||||
with allure.step(f"Check if the node {node_to_stop.storage_node} has stopped"):
|
with allure.step(f"Check if the node {node_to_stop.storage_node} has stopped"):
|
||||||
wait_for_host_offline(self.shell, node_to_stop.storage_node)
|
wait_for_host_offline(self.shell, node_to_stop.storage_node)
|
||||||
|
@ -186,7 +176,7 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
node_to_stop.storage_node, self.shell, alive_node=storage_nodes[0]
|
node_to_stop.storage_node, self.shell, alive_node=storage_nodes[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
count_tick_epoch = alive_nodes[0].ir_node.get_netmap_cleaner_threshold() + 2
|
count_tick_epoch = int(alive_nodes[0].ir_node.get_netmap_cleaner_threshold()) + 2
|
||||||
|
|
||||||
with allure.step(f"Tick {count_tick_epoch} epoch, in {storage_nodes[0]} node"):
|
with allure.step(f"Tick {count_tick_epoch} epoch, in {storage_nodes[0]} node"):
|
||||||
for tick in range(count_tick_epoch):
|
for tick in range(count_tick_epoch):
|
||||||
|
@ -208,13 +198,14 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
assert not corrupted_objects_list
|
assert not corrupted_objects_list
|
||||||
|
|
||||||
@allure.title("Temporarily disable a node")
|
@allure.title("Temporarily disable a node")
|
||||||
@pytest.mark.parametrize("containers, storage_objects", [(5, 20)], indirect=True)
|
@pytest.mark.parametrize("containers, storage_objects", [(5, 10)], indirect=True)
|
||||||
def test_temporarily_disable_a_node(
|
def test_temporarily_disable_a_node(
|
||||||
self,
|
self,
|
||||||
containers: list[StorageContainer],
|
containers: list[StorageContainer],
|
||||||
storage_objects: list[StorageObjectInfo],
|
storage_objects: list[StorageObjectInfo],
|
||||||
default_wallet: str,
|
default_wallet: str,
|
||||||
node_to_stop,
|
node_to_stop: ClusterNode,
|
||||||
|
cluster_state_controller: ClusterStateController,
|
||||||
):
|
):
|
||||||
with allure.step("Checking that the objects are loader according to the policy"):
|
with allure.step("Checking that the objects are loader according to the policy"):
|
||||||
self.check_objects_replication(storage_objects, self.cluster.storage_nodes)
|
self.check_objects_replication(storage_objects, self.cluster.storage_nodes)
|
||||||
|
@ -228,8 +219,7 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
with allure.step("Wait 2 block time"):
|
with allure.step("Wait 2 block time"):
|
||||||
time.sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 2)
|
time.sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 2)
|
||||||
|
|
||||||
with allure.step(f"Stop {node_to_stop.storage_node} node"):
|
cluster_state_controller.stop_node_host(node=node_to_stop, mode="hard")
|
||||||
node_to_stop.host.stop_host(mode="hard")
|
|
||||||
|
|
||||||
with allure.step(f"Check if the node {node_to_stop} has stopped"):
|
with allure.step(f"Check if the node {node_to_stop} has stopped"):
|
||||||
wait_for_host_offline(self.shell, node_to_stop.storage_node)
|
wait_for_host_offline(self.shell, node_to_stop.storage_node)
|
||||||
|
@ -246,8 +236,7 @@ class TestFailoverServer(ClusterTestBase):
|
||||||
node_to_stop.storage_node, self.shell, alive_node=storage_nodes[0]
|
node_to_stop.storage_node, self.shell, alive_node=storage_nodes[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
with allure.step(f"Start {node_to_stop}"):
|
cluster_state_controller.start_node_host(node_to_stop)
|
||||||
node_to_stop.host.start_host()
|
|
||||||
|
|
||||||
with allure.step("Verify that there are no corrupted objects"):
|
with allure.step("Verify that there are no corrupted objects"):
|
||||||
corrupted_objects_list = self.get_corrupted_objects_list(storage_nodes, storage_objects)
|
corrupted_objects_list = self.get_corrupted_objects_list(storage_nodes, storage_objects)
|
||||||
|
|
Loading…
Reference in a new issue