diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f290592a..b0f2b580 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,23 +43,10 @@ $ git fetch upstream ### Set up development environment To setup development environment for `frostfs-testlib`, please, take the following steps: -1. Prepare virtualenv ```shell -$ virtualenv --python=python3.10 venv -$ source venv/bin/activate -``` - -2. Install all dependencies: - -```shell -$ pip install -r requirements.txt -``` - -3. Setup pre-commit hooks to run code formatters on staged files before you run a `git commit` command: - -```shell -$ pre-commit install +$ make venv +$ source venv.frostfs-testlib/bin/activate ``` Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go: diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c7466084 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +SHELL := /bin/bash +PYTHON_VERSION := 3.10 +VENV_DIR := venv.frostfs-testlib + +current_dir := $(shell pwd) + +venv: create requirements paths precommit + @echo Ready + +precommit: + @echo Isntalling pre-commit hooks + . ${VENV_DIR}/bin/activate && pre-commit install + +paths: + @echo Append paths for project + @echo Virtual environment: ${VENV_DIR} + @sudo rm -rf ${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/_paths.pth + @sudo touch ${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/_paths.pth + @echo ${current_dir}/src/frostfs_testlib_frostfs_testlib | sudo tee ${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/_paths.pth + +create: + @echo Create virtual environment for + virtualenv --python=python${PYTHON_VERSION} --prompt=frostfs-testlib ${VENV_DIR} + +requirements: + @echo Isntalling pip requirements + . ${VENV_DIR}/bin/activate && pip install -Ur requirements.txt \ No newline at end of file diff --git a/src/frostfs_testlib/cli/frostfs_cli/netmap.py b/src/frostfs_testlib/cli/frostfs_cli/netmap.py index 7033912a..89208936 100644 --- a/src/frostfs_testlib/cli/frostfs_cli/netmap.py +++ b/src/frostfs_testlib/cli/frostfs_cli/netmap.py @@ -13,6 +13,7 @@ class FrostfsCliNetmap(CliCommand): generate_key: bool = False, ttl: Optional[int] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Get current epoch number. @@ -24,6 +25,7 @@ class FrostfsCliNetmap(CliCommand): ttl: TTL value in request meta header (default 2). wallet: Path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -41,6 +43,7 @@ class FrostfsCliNetmap(CliCommand): generate_key: bool = False, ttl: Optional[int] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Get information about FrostFS network. @@ -52,6 +55,7 @@ class FrostfsCliNetmap(CliCommand): ttl: TTL value in request meta header (default 2) wallet: Path to the wallet or binary key xhdr: Request X-Headers in form of Key=Value + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -70,6 +74,7 @@ class FrostfsCliNetmap(CliCommand): json: bool = False, ttl: Optional[int] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Get target node info. @@ -82,6 +87,7 @@ class FrostfsCliNetmap(CliCommand): ttl: TTL value in request meta header (default 2). wallet: Path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -99,6 +105,7 @@ class FrostfsCliNetmap(CliCommand): generate_key: bool = False, ttl: Optional[int] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Request current local snapshot of the network map. @@ -110,6 +117,7 @@ class FrostfsCliNetmap(CliCommand): ttl: TTL value in request meta header (default 2). wallet: Path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. diff --git a/src/frostfs_testlib/cli/frostfs_cli/shards.py b/src/frostfs_testlib/cli/frostfs_cli/shards.py index bfab6b69..6b47ac29 100644 --- a/src/frostfs_testlib/cli/frostfs_cli/shards.py +++ b/src/frostfs_testlib/cli/frostfs_cli/shards.py @@ -13,6 +13,7 @@ class FrostfsCliShards(CliCommand): id: Optional[list[str]], address: Optional[str] = None, all: bool = False, + timeout: Optional[str] = None, ) -> CommandResult: """ Flush objects from the write-cache to the main storage. @@ -24,6 +25,7 @@ class FrostfsCliShards(CliCommand): endpoint: Remote node address (as 'multiaddr' or ':'). wallet: WIF (NEP-2) string or path to the wallet or binary key. wallet_password: Wallet password. + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -44,6 +46,7 @@ class FrostfsCliShards(CliCommand): address: Optional[str] = None, all: bool = False, clear_errors: bool = False, + timeout: Optional[str] = None, ) -> CommandResult: """ Set work mode of the shard. @@ -57,12 +60,13 @@ class FrostfsCliShards(CliCommand): endpoint: Remote node address (as 'multiaddr' or ':'). wallet: WIF (NEP-2) string or path to the wallet or binary key. wallet_password: Wallet password. + timeout: Timeout for an operation (default 15s). Returns: Command's result. """ return self._execute_with_password( - f"control shards set-mode", + "control shards set-mode", wallet_password, **{ param: value @@ -80,6 +84,7 @@ class FrostfsCliShards(CliCommand): path: str, address: Optional[str] = None, no_errors: bool = False, + timeout: Optional[str] = None, ) -> CommandResult: """ Dump objects from shard to a file. @@ -92,12 +97,13 @@ class FrostfsCliShards(CliCommand): endpoint: Remote node address (as 'multiaddr' or ':'). wallet: WIF (NEP-2) string or path to the wallet or binary key. wallet_password: Wallet password. + timeout: Timeout for an operation (default 15s). Returns: Command's result. """ return self._execute_with_password( - f"control shards dump", + "control shards dump", wallet_password, **{ param: value @@ -113,6 +119,7 @@ class FrostfsCliShards(CliCommand): wallet_password: str, address: Optional[str] = None, json_mode: bool = False, + timeout: Optional[str] = None, ) -> CommandResult: """ List shards of the storage node. @@ -123,12 +130,13 @@ class FrostfsCliShards(CliCommand): endpoint: Remote node address (as 'multiaddr' or ':'). wallet: WIF (NEP-2) string or path to the wallet or binary key. wallet_password: Wallet password. + timeout: Timeout for an operation (default 15s). Returns: Command's result. """ return self._execute_with_password( - f"control shards list", + "control shards list", wallet_password, **{ param: value diff --git a/src/frostfs_testlib/cli/frostfs_cli/storagegroup.py b/src/frostfs_testlib/cli/frostfs_cli/storagegroup.py index 10f724be..8fb22cee 100644 --- a/src/frostfs_testlib/cli/frostfs_cli/storagegroup.py +++ b/src/frostfs_testlib/cli/frostfs_cli/storagegroup.py @@ -16,6 +16,7 @@ class FrostfsCliStorageGroup(CliCommand): lifetime: Optional[int] = None, address: Optional[str] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Put storage group to FrostFS. @@ -30,6 +31,7 @@ class FrostfsCliStorageGroup(CliCommand): ttl: TTL value in request meta header. wallet: WIF (NEP-2) string or path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -52,6 +54,7 @@ class FrostfsCliStorageGroup(CliCommand): lifetime: Optional[int] = None, address: Optional[str] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Get storage group from FrostFS. @@ -67,6 +70,7 @@ class FrostfsCliStorageGroup(CliCommand): ttl: TTL value in request meta header. wallet: WIF (NEP-2) string or path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -87,6 +91,7 @@ class FrostfsCliStorageGroup(CliCommand): lifetime: Optional[int] = None, address: Optional[str] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ List storage groups in FrostFS container. @@ -101,6 +106,7 @@ class FrostfsCliStorageGroup(CliCommand): ttl: TTL value in request meta header. wallet: WIF (NEP-2) string or path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. @@ -122,6 +128,7 @@ class FrostfsCliStorageGroup(CliCommand): lifetime: Optional[int] = None, address: Optional[str] = None, xhdr: Optional[dict] = None, + timeout: Optional[str] = None, ) -> CommandResult: """ Delete storage group from FrostFS. @@ -137,6 +144,7 @@ class FrostfsCliStorageGroup(CliCommand): ttl: TTL value in request meta header. wallet: WIF (NEP-2) string or path to the wallet or binary key. xhdr: Dict with request X-Headers. + timeout: Timeout for an operation (default 15s). Returns: Command's result. diff --git a/src/frostfs_testlib/hosting/interfaces.py b/src/frostfs_testlib/hosting/interfaces.py index 93e0304b..73f49541 100644 --- a/src/frostfs_testlib/hosting/interfaces.py +++ b/src/frostfs_testlib/hosting/interfaces.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod from datetime import datetime -from typing import Any, Optional +from typing import Optional from frostfs_testlib.hosting.config import CLIConfig, HostConfig, ServiceConfig from frostfs_testlib.shell.interfaces import Shell