diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad9846a1..0603040f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: black language_version: python3.9 - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort name: isort (python) diff --git a/requirements.txt b/requirements.txt index adca8f97..af0ee32b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ requests==2.28.1 # Dev dependencies black==22.8.0 bumpver==2022.1118 -isort==5.10.1 +isort==5.12.0 pre-commit==2.20.0 # Packaging dependencies diff --git a/src/neofs_testlib/hosting/docker_host.py b/src/neofs_testlib/hosting/docker_host.py index 257847b8..3b36e315 100644 --- a/src/neofs_testlib/hosting/docker_host.py +++ b/src/neofs_testlib/hosting/docker_host.py @@ -54,8 +54,8 @@ class ServiceAttributes(ParsedAttributes): container_name: str volume_name: Optional[str] = None - start_timeout: int = 60 - stop_timeout: int = 60 + start_timeout: int = 90 + stop_timeout: int = 90 class DockerHost(Host): @@ -117,6 +117,18 @@ class DockerHost(Host): timeout=service_attributes.stop_timeout, ) + def restart_service(self, service_name: str) -> None: + service_attributes = self._get_service_attributes(service_name) + + client = self._get_docker_client() + client.restart(service_attributes.container_name) + + self._wait_for_container_to_be_in_state( + container_name=service_attributes.container_name, + expected_state="running", + timeout=service_attributes.start_timeout, + ) + def delete_storage_node_data(self, service_name: str, cache_only: bool = False) -> None: service_attributes = self._get_service_attributes(service_name) diff --git a/src/neofs_testlib/hosting/interfaces.py b/src/neofs_testlib/hosting/interfaces.py index ddb07b74..2d360455 100644 --- a/src/neofs_testlib/hosting/interfaces.py +++ b/src/neofs_testlib/hosting/interfaces.py @@ -104,6 +104,14 @@ class Host(ABC): service_name: Name of the service to stop. """ + @abstractmethod + def restart_service(self, service_name: str) -> None: + """Restarts the service with specified name and waits until it starts. + The service must be hosted on this host. + Args: + service_name: Name of the service to restart. + """ + @abstractmethod def delete_storage_node_data(self, service_name: str, cache_only: bool = False) -> None: """Erases all data of the storage node with specified name.