forked from TrueCloudLab/frostfs-testlib
[#114] Add yaml configuration controllers
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
f8562da7e0
commit
72bd467c53
9 changed files with 244 additions and 22 deletions
|
@ -1,8 +1,10 @@
|
|||
import datetime
|
||||
import time
|
||||
from typing import TypeVar
|
||||
|
||||
import frostfs_testlib.resources.optionals as optionals
|
||||
from frostfs_testlib.healthcheck.interfaces import Healthcheck
|
||||
from frostfs_testlib.plugins import load_all
|
||||
from frostfs_testlib.reporter import get_reporter
|
||||
from frostfs_testlib.shell import CommandOptions, Shell, SshConnectionProvider
|
||||
from frostfs_testlib.steps.network import IfUpDownHelper, IpTablesHelper
|
||||
|
@ -22,6 +24,14 @@ reporter = get_reporter()
|
|||
if_up_down_helper = IfUpDownHelper()
|
||||
|
||||
|
||||
class StateManager:
|
||||
def __init__(self, cluster_state_controller: "ClusterStateController") -> None:
|
||||
self.csc = cluster_state_controller
|
||||
|
||||
|
||||
StateManagerClass = TypeVar("StateManagerClass", bound=StateManager)
|
||||
|
||||
|
||||
class ClusterStateController:
|
||||
def __init__(self, shell: Shell, cluster: Cluster, healthcheck: Healthcheck) -> None:
|
||||
self.stopped_nodes: list[ClusterNode] = []
|
||||
|
@ -33,6 +43,18 @@ class ClusterStateController:
|
|||
self.shell = shell
|
||||
self.suspended_services: dict[str, list[ClusterNode]] = {}
|
||||
self.nodes_with_modified_interface: list[ClusterNode] = []
|
||||
self.managers: list[StateManagerClass] = []
|
||||
|
||||
# TODO: move all functionality to managers
|
||||
managers = set(load_all(group="frostfs.testlib.csc_managers"))
|
||||
for manager in managers:
|
||||
self.managers.append(manager(self))
|
||||
|
||||
def manager(self, manager_type: type[StateManagerClass]) -> StateManagerClass:
|
||||
for manager in self.managers:
|
||||
# Subclasses here for the future if we have overriding subclasses of base interface
|
||||
if issubclass(type(manager), manager_type):
|
||||
return manager
|
||||
|
||||
def _get_stopped_by_node(self, node: ClusterNode) -> set[NodeBase]:
|
||||
stopped_by_node = [svc for svc in self.stopped_services if svc.host == node.host]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue