forked from TrueCloudLab/frostfs-testcases
Add time test
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
3944d9ff3b
commit
aab8b07726
1 changed files with 69 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
@ -14,6 +15,7 @@ from frostfs_testlib.steps.cli.object import (
|
||||||
get_object,
|
get_object,
|
||||||
get_object_from_random_node,
|
get_object_from_random_node,
|
||||||
head_object,
|
head_object,
|
||||||
|
neo_go_query_height,
|
||||||
put_object,
|
put_object,
|
||||||
put_object_to_random_node,
|
put_object_to_random_node,
|
||||||
)
|
)
|
||||||
|
@ -33,6 +35,7 @@ from frostfs_testlib.steps.node_management import (
|
||||||
)
|
)
|
||||||
from frostfs_testlib.steps.storage_policy import get_nodes_with_object, get_simple_object_copies
|
from frostfs_testlib.steps.storage_policy import get_nodes_with_object, get_simple_object_copies
|
||||||
from frostfs_testlib.storage.cluster import StorageNode
|
from frostfs_testlib.storage.cluster import StorageNode
|
||||||
|
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.testing.cluster_test_base import ClusterTestBase
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||||
from frostfs_testlib.utils import datetime_utils, string_utils
|
from frostfs_testlib.utils import datetime_utils, string_utils
|
||||||
|
@ -322,3 +325,69 @@ class TestNodeManagement(ClusterTestBase):
|
||||||
raise AssertionError(f'Expected "{OBJECT_NOT_FOUND}" error, got\n{err}')
|
raise AssertionError(f'Expected "{OBJECT_NOT_FOUND}" error, got\n{err}')
|
||||||
|
|
||||||
raise AssertionError(f"Object {oid} was not dropped from node")
|
raise AssertionError(f"Object {oid} was not dropped from node")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.time
|
||||||
|
class TestTime(ClusterTestBase):
|
||||||
|
@allure.step("Neo-go should continue to release blocks")
|
||||||
|
def check_nodes_block(self, cluster_state_controller: ClusterStateController):
|
||||||
|
count_blocks = {}
|
||||||
|
with allure.step("Get current block id"):
|
||||||
|
for cluster_node in self.cluster.cluster_nodes:
|
||||||
|
cluster_state_controller.get_node_date(cluster_node)
|
||||||
|
count_blocks[cluster_node] = neo_go_query_height(
|
||||||
|
shell=cluster_node.host.get_shell(), endpoint=cluster_node.morph_chain.get_http_endpoint()
|
||||||
|
)["Latest block"]
|
||||||
|
with allure.step("Wait for 3 blocks"):
|
||||||
|
sleep(datetime_utils.parse_time(MORPH_BLOCK_TIME) * 3)
|
||||||
|
with allure.step("Current block id should be higher than before"):
|
||||||
|
for cluster_node in self.cluster.cluster_nodes:
|
||||||
|
shell = cluster_node.host.get_shell()
|
||||||
|
now_block = neo_go_query_height(shell=shell, endpoint=cluster_node.morph_chain.get_http_endpoint())[
|
||||||
|
"Latest block"
|
||||||
|
]
|
||||||
|
assert count_blocks[cluster_node] < now_block
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def node_time_synchronizer(self, cluster_state_controller: ClusterStateController) -> None:
|
||||||
|
cluster_state_controller.set_sync_date_all_nodes(status="inactive")
|
||||||
|
yield
|
||||||
|
cluster_state_controller.set_sync_date_all_nodes(status="active")
|
||||||
|
|
||||||
|
def test_system_time(self, cluster_state_controller: ClusterStateController, node_time_synchronizer: None):
|
||||||
|
cluster_nodes = self.cluster.cluster_nodes
|
||||||
|
timezone_utc = datetime.timezone.utc
|
||||||
|
node_1, node_2, node_3 = cluster_nodes[0:3]
|
||||||
|
|
||||||
|
with allure.step("On node 1, move the system time forward by 2 years"):
|
||||||
|
cluster_state_controller.change_node_date(
|
||||||
|
node_1, (datetime.datetime.now(timezone_utc) + datetime.timedelta(days=(365 * 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
self.check_nodes_block(cluster_state_controller)
|
||||||
|
|
||||||
|
with allure.step("On node 2, move the system time back 2 years."):
|
||||||
|
cluster_state_controller.change_node_date(
|
||||||
|
node_2, (datetime.datetime.now(timezone_utc) - datetime.timedelta(days=(365 * 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
self.check_nodes_block(cluster_state_controller)
|
||||||
|
|
||||||
|
with allure.step("On node 3, move the system time forward by 3 years"):
|
||||||
|
cluster_state_controller.change_node_date(
|
||||||
|
node_3, (datetime.datetime.now(timezone_utc) + datetime.timedelta(days=(365 * 3)))
|
||||||
|
)
|
||||||
|
|
||||||
|
self.check_nodes_block(cluster_state_controller)
|
||||||
|
|
||||||
|
with allure.step("Return the time on all nodes to the current one"):
|
||||||
|
for cluster_node in self.cluster.cluster_nodes:
|
||||||
|
cluster_state_controller.restore_node_date(cluster_node)
|
||||||
|
|
||||||
|
self.check_nodes_block(cluster_state_controller)
|
||||||
|
|
||||||
|
with allure.step("Reboot all nodes"):
|
||||||
|
cluster_state_controller.shutdown_cluster(mode="soft")
|
||||||
|
cluster_state_controller.start_stopped_hosts()
|
||||||
|
|
||||||
|
self.check_nodes_block(cluster_state_controller)
|
||||||
|
|
Loading…
Reference in a new issue