From be36a10f1e9e56a55843b8b653a39b7479a8eb38 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Fri, 12 Jan 2024 18:23:04 +0300 Subject: [PATCH] [#157] fix for dev-env and unit-tests Signed-off-by: Andrey Berezin --- src/frostfs_testlib/hosting/docker_host.py | 14 ++++++++------ src/frostfs_testlib/steps/epoch.py | 2 +- tests/test_dataclasses.py | 16 +++++----------- tests/test_hosting.py | 14 +++++--------- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/frostfs_testlib/hosting/docker_host.py b/src/frostfs_testlib/hosting/docker_host.py index 05cd4b2..3c9883a 100644 --- a/src/frostfs_testlib/hosting/docker_host.py +++ b/src/frostfs_testlib/hosting/docker_host.py @@ -152,9 +152,7 @@ class DockerHost(Host): timeout=service_attributes.start_timeout, ) - def wait_for_service_to_be_in_state( - self, systemd_service_name: str, expected_state: str, timeout: int - ) -> None: + def wait_for_service_to_be_in_state(self, systemd_service_name: str, expected_state: str, timeout: int) -> None: raise NotImplementedError("Not implemented for docker") def get_data_directory(self, service_name: str) -> str: @@ -181,6 +179,12 @@ class DockerHost(Host): def delete_pilorama(self, service_name: str) -> None: raise NotImplementedError("Not implemented for docker") + def delete_file(self, file_path: str) -> None: + raise NotImplementedError("Not implemented for docker") + + def is_file_exist(self, file_path: str) -> None: + raise NotImplementedError("Not implemented for docker") + def delete_storage_node_data(self, service_name: str, cache_only: bool = False) -> None: volume_path = self.get_data_directory(service_name) @@ -305,9 +309,7 @@ class DockerHost(Host): return container return None - def _wait_for_container_to_be_in_state( - self, container_name: str, expected_state: str, timeout: int - ) -> None: + def _wait_for_container_to_be_in_state(self, container_name: str, expected_state: str, timeout: int) -> None: iterations = 10 iteration_wait_time = timeout / iterations diff --git a/src/frostfs_testlib/steps/epoch.py b/src/frostfs_testlib/steps/epoch.py index 5a43ba3..ef8f85a 100644 --- a/src/frostfs_testlib/steps/epoch.py +++ b/src/frostfs_testlib/steps/epoch.py @@ -87,7 +87,7 @@ def tick_epoch(shell: Shell, cluster: Cluster, alive_node: Optional[StorageNode] alive_node = alive_node if alive_node else cluster.services(StorageNode)[0] remote_shell = alive_node.host.get_shell() - if FROSTFS_ADM_EXEC and FROSTFS_ADM_CONFIG_PATH: + if "force_transactions" not in alive_node.host.config.attributes: # If frostfs-adm is available, then we tick epoch with it (to be consistent with UAT tests) frostfs_adm = FrostfsAdm( shell=remote_shell, diff --git a/tests/test_dataclasses.py b/tests/test_dataclasses.py index f1cc51e..19f3832 100644 --- a/tests/test_dataclasses.py +++ b/tests/test_dataclasses.py @@ -4,13 +4,7 @@ import pytest from frostfs_testlib.s3 import AwsCliClient, Boto3ClientWrapper from frostfs_testlib.storage.dataclasses.acl import EACLRole -from frostfs_testlib.storage.dataclasses.frostfs_services import ( - HTTPGate, - InnerRing, - MorphChain, - S3Gate, - StorageNode, -) +from frostfs_testlib.storage.dataclasses.frostfs_services import HTTPGate, InnerRing, MorphChain, S3Gate, StorageNode from frostfs_testlib.storage.dataclasses.object_size import ObjectSize @@ -22,10 +16,10 @@ class TestDataclassesStr: [ (Boto3ClientWrapper, "Boto3 client"), (AwsCliClient, "AWS CLI"), - (ObjectSize("simple", 1), "simple object size"), - (ObjectSize("simple", 10), "simple object size"), - (ObjectSize("complex", 5000), "complex object size"), - (ObjectSize("complex", 5555), "complex object size"), + (ObjectSize("simple", 1), "simple"), + (ObjectSize("simple", 10), "simple"), + (ObjectSize("complex", 5000), "complex"), + (ObjectSize("complex", 5555), "complex"), (StorageNode, "StorageNode"), (MorphChain, "MorphChain"), (S3Gate, "S3Gate"), diff --git a/tests/test_hosting.py b/tests/test_hosting.py index 14be8c5..39580cb 100644 --- a/tests/test_hosting.py +++ b/tests/test_hosting.py @@ -15,6 +15,7 @@ class TestHosting(TestCase): HOST1 = { "address": HOST1_ADDRESS, "plugin_name": HOST1_PLUGIN, + "healthcheck_plugin_name": "basic", "attributes": HOST1_ATTRIBUTES, "clis": HOST1_CLIS, "services": HOST1_SERVICES, @@ -32,6 +33,7 @@ class TestHosting(TestCase): HOST2 = { "address": HOST2_ADDRESS, "plugin_name": HOST2_PLUGIN, + "healthcheck_plugin_name": "basic", "attributes": HOST2_ATTRIBUTES, "clis": HOST2_CLIS, "services": HOST2_SERVICES, @@ -52,18 +54,14 @@ class TestHosting(TestCase): self.assertEqual(host1.config.plugin_name, self.HOST1_PLUGIN) self.assertDictEqual(host1.config.attributes, self.HOST1_ATTRIBUTES) self.assertListEqual(host1.config.clis, [CLIConfig(**cli) for cli in self.HOST1_CLIS]) - self.assertListEqual( - host1.config.services, [ServiceConfig(**service) for service in self.HOST1_SERVICES] - ) + self.assertListEqual(host1.config.services, [ServiceConfig(**service) for service in self.HOST1_SERVICES]) host2 = hosting.get_host_by_address(self.HOST2_ADDRESS) self.assertEqual(host2.config.address, self.HOST2_ADDRESS) self.assertEqual(host2.config.plugin_name, self.HOST2_PLUGIN) self.assertDictEqual(host2.config.attributes, self.HOST2_ATTRIBUTES) self.assertListEqual(host2.config.clis, [CLIConfig(**cli) for cli in self.HOST2_CLIS]) - self.assertListEqual( - host2.config.services, [ServiceConfig(**service) for service in self.HOST2_SERVICES] - ) + self.assertListEqual(host2.config.services, [ServiceConfig(**service) for service in self.HOST2_SERVICES]) def test_get_host_by_service(self): hosting = Hosting() @@ -104,9 +102,7 @@ class TestHosting(TestCase): services = hosting.find_service_configs(rf"^{self.SERVICE_NAME_PREFIX}") self.assertEqual(len(services), 2) for service in services: - self.assertEqual( - service.name[: len(self.SERVICE_NAME_PREFIX)], self.SERVICE_NAME_PREFIX - ) + self.assertEqual(service.name[: len(self.SERVICE_NAME_PREFIX)], self.SERVICE_NAME_PREFIX) service1 = hosting.find_service_configs(self.SERVICE1["name"]) self.assertEqual(len(service1), 1)