Fix maintenance test and introduce custom ordering mark #257

Merged
abereziny merged 1 commit from abereziny/frostfs-testcases:feature-fix-maintenance-tests into master 2024-06-24 15:47:03 +00:00
5 changed files with 18 additions and 41 deletions

View file

@ -12,6 +12,7 @@ markers =
smoke: test runs in smoke testrun smoke: test runs in smoke testrun
# controlling markers # controlling markers
no_healthcheck: skip healthcheck for this test no_healthcheck: skip healthcheck for this test
order: manual control of test order
# functional markers # functional markers
maintenance: tests for change mode node maintenance: tests for change mode node
container: tests for container creation container: tests for container creation
@ -44,7 +45,6 @@ markers =
failover_network: tests for network failure failover_network: tests for network failure
failover_reboot: tests for system recovery after reboot of a node failover_reboot: tests for system recovery after reboot of a node
interfaces: tests down interface to system interfaces: tests down interface to system
add_nodes: add nodes to cluster
check_binaries: check frostfs installed binaries versions check_binaries: check frostfs installed binaries versions
payments: tests for payment associated operations payments: tests for payment associated operations
load: performance tests load: performance tests
@ -66,4 +66,3 @@ markers =
replication: replication tests replication: replication tests
static_session_container: tests for a static session in a container static_session_container: tests for a static session in a container
shard: shard management tests shard: shard management tests
logs_after_session: tests after a session with logs

View file

@ -57,14 +57,16 @@ start_time = pytest.StashKey[int]()
test_outcome = pytest.StashKey[str]() test_outcome = pytest.StashKey[str]()
# pytest hook. Do not rename # pytest hook. Do not rename
def pytest_collection_modifyitems(items: list[pytest.Item]): def pytest_collection_modifyitems(items: list[pytest.Item]):
# Make network tests last based on @pytest.mark.node_mgmt and logs_test to be latest # Change order of tests based on @pytest.mark.order(<int>) marker
def priority(item: pytest.Item) -> int: def order(item: pytest.Item) -> int:
is_node_mgmt_test = 1 if item.get_closest_marker("node_mgmt") else 0 order_marker = item.get_closest_marker("order")
is_logs_check_test = 100 if item.get_closest_marker("logs_after_session") else 0 if order_marker and (len(order_marker.args) != 1 or not isinstance(order_marker.args[0], int)):
is_system_time_test = 10 if item.get_closest_marker("time") else 0 raise RuntimeError("Incorrect usage of pytest.mark.order")
return is_node_mgmt_test + is_logs_check_test + is_system_time_test
items.sort(key=lambda item: priority(item)) order_value = order_marker.args[0] if order_marker else 0
return order_value
items.sort(key=lambda item: order(item))
# pytest hook. Do not rename # pytest hook. Do not rename

View file

@ -11,7 +11,7 @@ from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
from frostfs_testlib.utils import datetime_utils from frostfs_testlib.utils import datetime_utils
@pytest.mark.time @pytest.mark.order(20)
@pytest.mark.failover @pytest.mark.failover
class TestTime(ClusterTestBase): class TestTime(ClusterTestBase):
@reporter.step("Neo-go should continue to release blocks") @reporter.step("Neo-go should continue to release blocks")

View file

@ -1,5 +1,4 @@
import logging import logging
import os
import random import random
from time import sleep from time import sleep
from typing import Optional, Tuple from typing import Optional, Tuple
@ -36,7 +35,7 @@ from frostfs_testlib.steps.node_management import (
wait_for_node_to_be_ready, wait_for_node_to_be_ready,
) )
from frostfs_testlib.steps.storage_policy import get_nodes_with_object from frostfs_testlib.steps.storage_policy import get_nodes_with_object
from frostfs_testlib.storage.cluster import Cluster, ClusterNode, StorageNode from frostfs_testlib.storage.cluster import ClusterNode, StorageNode
from frostfs_testlib.storage.controllers import ClusterStateController from frostfs_testlib.storage.controllers import ClusterStateController
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
from frostfs_testlib.storage.dataclasses.storage_object_info import NodeStatus from frostfs_testlib.storage.dataclasses.storage_object_info import NodeStatus
@ -52,9 +51,8 @@ logger = logging.getLogger("NeoLogger")
check_nodes: list[StorageNode] = [] check_nodes: list[StorageNode] = []
@allure.title("Add one node to cluster")
@pytest.mark.add_nodes
@pytest.mark.node_mgmt @pytest.mark.node_mgmt
@pytest.mark.order(10)
class TestNodeManagement(ClusterTestBase): class TestNodeManagement(ClusterTestBase):
@pytest.fixture @pytest.fixture
@allure.title("Create container and pick the node with data") @allure.title("Create container and pick the node with data")
@ -131,7 +129,6 @@ class TestNodeManagement(ClusterTestBase):
check_node_in_map(node, shell=self.shell, alive_node=alive_node) check_node_in_map(node, shell=self.shell, alive_node=alive_node)
@allure.title("Add one node to cluster") @allure.title("Add one node to cluster")
@pytest.mark.add_nodes
def test_add_nodes( def test_add_nodes(
self, self,
default_wallet: WalletInfo, default_wallet: WalletInfo,
@ -210,7 +207,6 @@ class TestNodeManagement(ClusterTestBase):
) )
wait_object_replication(cid, oid, 4, shell=self.shell, nodes=storage_nodes) wait_object_replication(cid, oid, 4, shell=self.shell, nodes=storage_nodes)
@pytest.mark.node_mgmt
@allure.title("Drop object using control command") @allure.title("Drop object using control command")
def test_drop_object(self, default_wallet, complex_object_size: ObjectSize, simple_object_size: ObjectSize): def test_drop_object(self, default_wallet, complex_object_size: ObjectSize, simple_object_size: ObjectSize):
""" """
@ -242,7 +238,6 @@ class TestNodeManagement(ClusterTestBase):
self.wait_for_obj_dropped(wallet, cid, oid, endpoint, get_object) self.wait_for_obj_dropped(wallet, cid, oid, endpoint, get_object)
self.wait_for_obj_dropped(wallet, cid, oid, endpoint, head_object) self.wait_for_obj_dropped(wallet, cid, oid, endpoint, head_object)
@pytest.mark.node_mgmt
@pytest.mark.skip(reason="Need to clarify scenario") @pytest.mark.skip(reason="Need to clarify scenario")
@allure.title("Control Operations with storage nodes") @allure.title("Control Operations with storage nodes")
def test_shards( def test_shards(
@ -285,7 +280,6 @@ class TestNodeManagement(ClusterTestBase):
oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster) oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster)
delete_object(wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint) delete_object(wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint)
@pytest.mark.node_mgmt
@allure.title("Put object with stopped node") @allure.title("Put object with stopped node")
def test_stop_node(self, default_wallet, return_nodes_after_test_run, simple_object_size: ObjectSize): def test_stop_node(self, default_wallet, return_nodes_after_test_run, simple_object_size: ObjectSize):
wallet = default_wallet wallet = default_wallet
@ -332,6 +326,7 @@ class TestNodeManagement(ClusterTestBase):
@pytest.mark.maintenance @pytest.mark.maintenance
@pytest.mark.order(9)
class TestMaintenanceMode(ClusterTestBase): class TestMaintenanceMode(ClusterTestBase):
@pytest.fixture() @pytest.fixture()
@allure.title("Init Frostfs CLI remote") @allure.title("Init Frostfs CLI remote")
@ -454,8 +449,6 @@ class TestMaintenanceMode(ClusterTestBase):
with pytest.raises(RuntimeError, match=node_under_maintenance_error): with pytest.raises(RuntimeError, match=node_under_maintenance_error):
put_object(default_wallet, file_path, cid, self.shell, endpoint) put_object(default_wallet, file_path, cid, self.shell, endpoint)
os.remove(file_path)
@pytest.mark.sanity @pytest.mark.sanity
@allure.title("MAINTENANCE and OFFLINE mode transitions") @allure.title("MAINTENANCE and OFFLINE mode transitions")
def test_mode_transitions( def test_mode_transitions(
@ -564,7 +557,7 @@ class TestMaintenanceMode(ClusterTestBase):
cluster_state_controller: ClusterStateController, cluster_state_controller: ClusterStateController,
node_under_test: ClusterNode, node_under_test: ClusterNode,
frostfs_cli_remote: FrostfsCli, frostfs_cli_remote: FrostfsCli,
frostfs_cli: FrostfsCli, default_wallet: WalletInfo,
restore_node_status: list[ClusterNode], restore_node_status: list[ClusterNode],
): ):
restore_node_status.append(node_under_test) restore_node_status.append(node_under_test)
@ -581,24 +574,7 @@ class TestMaintenanceMode(ClusterTestBase):
cluster_state_controller.set_maintenance_mode_allowed("true", node_under_test) cluster_state_controller.set_maintenance_mode_allowed("true", node_under_test)
with reporter.step("Set node status to 'maintenance'"): with reporter.step("Set node status to 'maintenance'"):
output = frostfs_cli_remote.control.set_status(endpoint=control_endpoint, status="maintenance") cluster_state_controller.set_node_status(node_under_test, default_wallet, NodeStatus.MAINTENANCE)
assert "update request successfully sent" in output.stdout, f"Response = {output}"
with reporter.step("Tick epoch"):
self.tick_epoch(wait_block=2)
with reporter.step("Check node status is 'maintenance'"):
self.check_node_status(
NodeStatus.MAINTENANCE, node_under_test, frostfs_cli, node_under_test.storage_node.get_rpc_endpoint()
)
with reporter.step("Set node status to 'online'"): with reporter.step("Set node status to 'online'"):
frostfs_cli_remote.control.set_status(endpoint=control_endpoint, status="online") cluster_state_controller.set_node_status(node_under_test, default_wallet, NodeStatus.ONLINE)
with reporter.step("Tick epoch"):
self.tick_epoch()
with reporter.step("Check node status is 'online'"):
self.check_node_status(
NodeStatus.ONLINE, node_under_test, frostfs_cli, node_under_test.storage_node.get_rpc_endpoint()
)

View file

@ -22,7 +22,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):
class TestLogs: class TestLogs:
@allure.title("Check logs from frostfs-testcases with marks '{request.config.option.markexpr}'") @allure.title("Check logs from frostfs-testcases with marks '{request.config.option.markexpr}'")
@pytest.mark.logs_after_session @pytest.mark.order(1000)
@pytest.mark.no_healthcheck @pytest.mark.no_healthcheck
def test_logs_after_session( def test_logs_after_session(
self, temp_directory: str, cluster: Cluster, session_start_time: datetime, request: pytest.FixtureRequest self, temp_directory: str, cluster: Cluster, session_start_time: datetime, request: pytest.FixtureRequest