[#362] Add functions to change date on nodes in ClusterStateController #362

Merged
abereziny merged 1 commit from Kiriruso/frostfs-testlib:certification-iaf-upd-rsb-part-two into master 2025-03-13 08:06:49 +00:00

View file

@ -247,23 +247,20 @@ class ClusterStateController:
if service_type == StorageNode:
self.wait_after_storage_startup()
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Stop all storage services on cluster")
def stop_all_storage_services(self, reversed_order: bool = False):
nodes = reversed(self.cluster.cluster_nodes) if reversed_order else self.cluster.cluster_nodes
@reporter.step("Restart {service_type} service on {node}")
def restart_service_of_type(self, node: ClusterNode, service_type: ServiceClass):
service = node.service(service_type)
service.restart_service()
for node in nodes:
self.stop_service_of_type(node, StorageNode)
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Stop all S3 gates on cluster")
def stop_all_s3_gates(self, reversed_order: bool = False):
nodes = reversed(self.cluster.cluster_nodes) if reversed_order else self.cluster.cluster_nodes
@reporter.step("Restart all {service_type} services")
def restart_services_of_type(self, service_type: type[ServiceClass]):
services = self.cluster.services(service_type)
parallel([service.restart_service for service in services])
for node in nodes:
self.stop_service_of_type(node, S3Gate)
if service_type == StorageNode:
self.wait_after_storage_startup()
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@ -277,30 +274,6 @@ class ClusterStateController:
def start_storage_service(self, node: ClusterNode):
self.start_service_of_type(node, StorageNode)
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Start stopped storage services")
def start_stopped_storage_services(self):
self.start_stopped_services_of_type(StorageNode)
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Stop s3 gate on {node}")
def stop_s3_gate(self, node: ClusterNode, mask: bool = True):
self.stop_service_of_type(node, S3Gate, mask)
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Start s3 gate on {node}")
def start_s3_gate(self, node: ClusterNode):
self.start_service_of_type(node, S3Gate)
# TODO: Deprecated
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Start stopped S3 gates")
def start_stopped_s3_gates(self):
self.start_stopped_services_of_type(S3Gate)
@run_optionally(optionals.OPTIONAL_FAILOVER_ENABLED)
@reporter.step("Suspend {process_name} service in {node}")
def suspend_service(self, process_name: str, node: ClusterNode):
@ -392,19 +365,29 @@ class ClusterStateController:
shell = node.host.get_shell()
return datetime.strptime(shell.exec('date +"%Y-%m-%d %H:%M:%S"').stdout.strip(), "%Y-%m-%d %H:%M:%S")
@reporter.step("Set node time to {in_date}")
@reporter.step("Set time on nodes in {in_date}")
def change_date_on_all_nodes(self, cluster: Cluster, in_date: datetime) -> None:
parallel(self.change_node_date, cluster.cluster_nodes, in_date=in_date)
@reporter.step("Set time on {node} to {in_date}")
def change_node_date(self, node: ClusterNode, in_date: datetime) -> None:
shell = node.host.get_shell()
in_date_frmt = in_date.strftime("%Y-%m-%d %H:%M:%S")
shell.exec(f"timedatectl set-time '{in_date_frmt}'")
node_time = self.get_node_date(node)
with reporter.step(f"Verify difference between {node_time} and {in_date} is less than a minute"):
assert (node_time - in_date).total_seconds() < 60
@reporter.step("Restore time")
@reporter.step("Restore time on nodes")
def restore_date_on_all_nodes(self, cluster: Cluster) -> None:
parallel(self.restore_node_date, cluster.cluster_nodes)
@reporter.step("Restore time on {node}")
def restore_node_date(self, node: ClusterNode) -> None:
shell = node.host.get_shell()
now_time = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
with reporter.step(f"Set {now_time} time"):
shell.exec(f"timedatectl set-time '{now_time}'")