forked from TrueCloudLab/frostfs-testcases
Fix test shutdown node
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
737c544fc0
commit
0c81ba6f22
1 changed files with 26 additions and 37 deletions
|
@ -13,12 +13,9 @@ from frostfs_testlib.steps.cli.container import (
|
|||
create_container,
|
||||
)
|
||||
from frostfs_testlib.steps.cli.object import get_object
|
||||
from frostfs_testlib.steps.node_management import (
|
||||
check_node_in_map,
|
||||
check_node_not_in_map,
|
||||
wait_for_node_to_be_ready,
|
||||
)
|
||||
from frostfs_testlib.steps.node_management import check_node_in_map, check_node_not_in_map
|
||||
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.wallet import WalletInfo
|
||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||
|
@ -72,27 +69,21 @@ class TestFailoverServer(ClusterTestBase):
|
|||
|
||||
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")
|
||||
@pytest.fixture(scope="class")
|
||||
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:
|
||||
count_object = request.param
|
||||
object_size = [simple_object_size, complex_object_size]
|
||||
object_list = []
|
||||
for cont in containers:
|
||||
for _ in range(request.param):
|
||||
object_list.append(cont.generate_object(size=object_size))
|
||||
for _ in range(count_object):
|
||||
object_list.append(cont.generate_object(size=random.choice(object_size)))
|
||||
|
||||
yield object_list
|
||||
|
||||
|
@ -101,13 +92,12 @@ class TestFailoverServer(ClusterTestBase):
|
|||
|
||||
@allure.step("Select random node to stop and start it after test")
|
||||
@pytest.fixture
|
||||
def node_to_stop(self) -> ClusterNode:
|
||||
node = random.choice(self.cluster.cluster_nodes)
|
||||
yield node
|
||||
with allure.step(f"start {node.storage_node}"):
|
||||
node.host.start_host()
|
||||
with allure.step(f"Waiting status ready for node {node.storage_node}"):
|
||||
wait_for_node_to_be_ready(node.storage_node)
|
||||
def node_to_stop(
|
||||
self, node_under_test: ClusterNode, cluster_state_controller: ClusterStateController
|
||||
) -> ClusterNode:
|
||||
yield node_under_test
|
||||
with allure.step(f"start {node_under_test.storage_node}"):
|
||||
cluster_state_controller.start_stopped_hosts()
|
||||
|
||||
@allure.step("Upload object with nodes and compare")
|
||||
def get_corrupted_objects_list(
|
||||
|
@ -145,13 +135,14 @@ class TestFailoverServer(ClusterTestBase):
|
|||
)
|
||||
|
||||
@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(
|
||||
self,
|
||||
containers: list[StorageContainer],
|
||||
storage_objects: list[StorageObjectInfo],
|
||||
default_wallet: str,
|
||||
node_to_stop: ClusterNode,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
):
|
||||
with allure.step("Checking that the objects are loader according to the policy"):
|
||||
self.check_objects_replication(storage_objects, self.cluster.storage_nodes)
|
||||
|
@ -167,8 +158,7 @@ class TestFailoverServer(ClusterTestBase):
|
|||
with allure.step("Wait 2 block time"):
|
||||
time.sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 2)
|
||||
|
||||
with allure.step(f"Stop {node_to_stop} node"):
|
||||
node_to_stop.host.stop_host(mode="hard")
|
||||
cluster_state_controller.stop_node_host(node=node_to_stop, mode="hard")
|
||||
|
||||
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)
|
||||
|
@ -186,7 +176,7 @@ class TestFailoverServer(ClusterTestBase):
|
|||
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"):
|
||||
for tick in range(count_tick_epoch):
|
||||
|
@ -208,13 +198,14 @@ class TestFailoverServer(ClusterTestBase):
|
|||
assert not corrupted_objects_list
|
||||
|
||||
@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(
|
||||
self,
|
||||
containers: list[StorageContainer],
|
||||
storage_objects: list[StorageObjectInfo],
|
||||
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"):
|
||||
self.check_objects_replication(storage_objects, self.cluster.storage_nodes)
|
||||
|
@ -228,8 +219,7 @@ class TestFailoverServer(ClusterTestBase):
|
|||
with allure.step("Wait 2 block time"):
|
||||
time.sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 2)
|
||||
|
||||
with allure.step(f"Stop {node_to_stop.storage_node} node"):
|
||||
node_to_stop.host.stop_host(mode="hard")
|
||||
cluster_state_controller.stop_node_host(node=node_to_stop, mode="hard")
|
||||
|
||||
with allure.step(f"Check if the node {node_to_stop} has stopped"):
|
||||
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]
|
||||
)
|
||||
|
||||
with allure.step(f"Start {node_to_stop}"):
|
||||
node_to_stop.host.start_host()
|
||||
cluster_state_controller.start_node_host(node_to_stop)
|
||||
|
||||
with allure.step("Verify that there are no corrupted objects"):
|
||||
corrupted_objects_list = self.get_corrupted_objects_list(storage_nodes, storage_objects)
|
||||
|
|
Loading…
Reference in a new issue