[#355] Change CSC time methods
All checks were successful
DCO action / DCO (pull_request) Successful in 24s
All checks were successful
DCO action / DCO (pull_request) Successful in 24s
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
b44705eb2f
commit
2ffb80bbf4
1 changed files with 8 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from datetime import datetime, timezone
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
import frostfs_testlib.resources.optionals as optionals
|
import frostfs_testlib.resources.optionals as optionals
|
||||||
|
@ -390,31 +390,23 @@ class ClusterStateController:
|
||||||
@reporter.step("Get node time")
|
@reporter.step("Get node time")
|
||||||
def get_node_date(self, node: ClusterNode) -> datetime:
|
def get_node_date(self, node: ClusterNode) -> datetime:
|
||||||
shell = node.host.get_shell()
|
shell = node.host.get_shell()
|
||||||
return datetime.datetime.strptime(shell.exec("hwclock -r").stdout.strip(), "%Y-%m-%d %H:%M:%S.%f%z")
|
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 node time to {in_date}")
|
||||||
def change_node_date(self, node: ClusterNode, in_date: datetime) -> None:
|
def change_node_date(self, node: ClusterNode, in_date: datetime) -> None:
|
||||||
shell = node.host.get_shell()
|
shell = node.host.get_shell()
|
||||||
shell.exec(f"date -s @{time.mktime(in_date.timetuple())}")
|
in_date_frmt = in_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
shell.exec("hwclock --systohc")
|
shell.exec(f"timedatectl set-time '{in_date_frmt}'")
|
||||||
node_time = self.get_node_date(node)
|
node_time = self.get_node_date(node)
|
||||||
with reporter.step(f"Verify difference between {node_time} and {in_date} is less than a minute"):
|
with reporter.step(f"Verify difference between {node_time} and {in_date} is less than a minute"):
|
||||||
assert (self.get_node_date(node) - in_date) < datetime.timedelta(minutes=1)
|
assert (node_time - in_date).total_seconds() < 60
|
||||||
|
|
||||||
@reporter.step(f"Restore time")
|
@reporter.step("Restore time")
|
||||||
def restore_node_date(self, node: ClusterNode) -> None:
|
def restore_node_date(self, node: ClusterNode) -> None:
|
||||||
shell = node.host.get_shell()
|
shell = node.host.get_shell()
|
||||||
now_time = datetime.datetime.now(datetime.timezone.utc)
|
now_time = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
with reporter.step(f"Set {now_time} time"):
|
with reporter.step(f"Set {now_time} time"):
|
||||||
shell.exec(f"date -s @{time.mktime(now_time.timetuple())}")
|
shell.exec(f"timedatectl set-time '{now_time}'")
|
||||||
shell.exec("hwclock --systohc")
|
|
||||||
|
|
||||||
@reporter.step("Change the synchronizer status to {status}")
|
|
||||||
def set_sync_date_all_nodes(self, status: str):
|
|
||||||
if status == "active":
|
|
||||||
parallel(self._enable_date_synchronizer, self.cluster.cluster_nodes)
|
|
||||||
return
|
|
||||||
parallel(self._disable_date_synchronizer, self.cluster.cluster_nodes)
|
|
||||||
|
|
||||||
@reporter.step("Set MaintenanceModeAllowed - {status}")
|
@reporter.step("Set MaintenanceModeAllowed - {status}")
|
||||||
def set_maintenance_mode_allowed(self, status: str, cluster_node: ClusterNode) -> None:
|
def set_maintenance_mode_allowed(self, status: str, cluster_node: ClusterNode) -> None:
|
||||||
|
@ -500,16 +492,6 @@ class ClusterStateController:
|
||||||
frostfs_cli_remote = FrostfsCli(shell=shell, frostfs_cli_exec_path=FROSTFS_CLI_EXEC, config_file=wallet_config_path)
|
frostfs_cli_remote = FrostfsCli(shell=shell, frostfs_cli_exec_path=FROSTFS_CLI_EXEC, config_file=wallet_config_path)
|
||||||
return frostfs_adm, frostfs_cli, frostfs_cli_remote
|
return frostfs_adm, frostfs_cli, frostfs_cli_remote
|
||||||
|
|
||||||
def _enable_date_synchronizer(self, cluster_node: ClusterNode):
|
|
||||||
shell = cluster_node.host.get_shell()
|
|
||||||
shell.exec("timedatectl set-ntp true")
|
|
||||||
cluster_node.host.wait_for_service_to_be_in_state("systemd-timesyncd", "active", 15)
|
|
||||||
|
|
||||||
def _disable_date_synchronizer(self, cluster_node: ClusterNode):
|
|
||||||
shell = cluster_node.host.get_shell()
|
|
||||||
shell.exec("timedatectl set-ntp false")
|
|
||||||
cluster_node.host.wait_for_service_to_be_in_state("systemd-timesyncd", "inactive", 15)
|
|
||||||
|
|
||||||
def _get_disk_controller(self, node: StorageNode, device: str, mountpoint: str) -> DiskController:
|
def _get_disk_controller(self, node: StorageNode, device: str, mountpoint: str) -> DiskController:
|
||||||
disk_controller_id = DiskController.get_id(node, device)
|
disk_controller_id = DiskController.get_id(node, device)
|
||||||
if disk_controller_id in self.detached_disks.keys():
|
if disk_controller_id in self.detached_disks.keys():
|
||||||
|
|
Loading…
Add table
Reference in a new issue