Adding timeout for more cli actions #13
6 changed files with 57 additions and 19 deletions
|
@ -43,23 +43,10 @@ $ git fetch upstream
|
||||||
|
|
||||||
### Set up development environment
|
### Set up development environment
|
||||||
To setup development environment for `frostfs-testlib`, please, take the following steps:
|
To setup development environment for `frostfs-testlib`, please, take the following steps:
|
||||||
1. Prepare virtualenv
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ virtualenv --python=python3.10 venv
|
$ make venv
|
||||||
$ source venv/bin/activate
|
$ source venv.frostfs-testlib/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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go:
|
Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go:
|
||||||
|
|
27
Makefile
Normal file
27
Makefile
Normal file
|
@ -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
|
|
@ -13,6 +13,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
generate_key: bool = False,
|
generate_key: bool = False,
|
||||||
ttl: Optional[int] = None,
|
ttl: Optional[int] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Get current epoch number.
|
Get current epoch number.
|
||||||
|
@ -24,6 +25,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
ttl: TTL value in request meta header (default 2).
|
ttl: TTL value in request meta header (default 2).
|
||||||
wallet: Path to the wallet or binary key.
|
wallet: Path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -41,6 +43,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
generate_key: bool = False,
|
generate_key: bool = False,
|
||||||
ttl: Optional[int] = None,
|
ttl: Optional[int] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Get information about FrostFS network.
|
Get information about FrostFS network.
|
||||||
|
@ -52,6 +55,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
ttl: TTL value in request meta header (default 2)
|
ttl: TTL value in request meta header (default 2)
|
||||||
wallet: Path to the wallet or binary key
|
wallet: Path to the wallet or binary key
|
||||||
xhdr: Request X-Headers in form of Key=Value
|
xhdr: Request X-Headers in form of Key=Value
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -70,6 +74,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
json: bool = False,
|
json: bool = False,
|
||||||
ttl: Optional[int] = None,
|
ttl: Optional[int] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Get target node info.
|
Get target node info.
|
||||||
|
@ -82,6 +87,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
ttl: TTL value in request meta header (default 2).
|
ttl: TTL value in request meta header (default 2).
|
||||||
wallet: Path to the wallet or binary key.
|
wallet: Path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -99,6 +105,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
generate_key: bool = False,
|
generate_key: bool = False,
|
||||||
ttl: Optional[int] = None,
|
ttl: Optional[int] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Request current local snapshot of the network map.
|
Request current local snapshot of the network map.
|
||||||
|
@ -110,6 +117,7 @@ class FrostfsCliNetmap(CliCommand):
|
||||||
ttl: TTL value in request meta header (default 2).
|
ttl: TTL value in request meta header (default 2).
|
||||||
wallet: Path to the wallet or binary key.
|
wallet: Path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
|
|
@ -13,6 +13,7 @@ class FrostfsCliShards(CliCommand):
|
||||||
id: Optional[list[str]],
|
id: Optional[list[str]],
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
all: bool = False,
|
all: bool = False,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Flush objects from the write-cache to the main storage.
|
Flush objects from the write-cache to the main storage.
|
||||||
|
@ -24,6 +25,7 @@ class FrostfsCliShards(CliCommand):
|
||||||
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
wallet_password: Wallet password.
|
wallet_password: Wallet password.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -44,6 +46,7 @@ class FrostfsCliShards(CliCommand):
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
all: bool = False,
|
all: bool = False,
|
||||||
clear_errors: bool = False,
|
clear_errors: bool = False,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Set work mode of the shard.
|
Set work mode of the shard.
|
||||||
|
@ -57,12 +60,13 @@ class FrostfsCliShards(CliCommand):
|
||||||
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
wallet_password: Wallet password.
|
wallet_password: Wallet password.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
"""
|
"""
|
||||||
return self._execute_with_password(
|
return self._execute_with_password(
|
||||||
f"control shards set-mode",
|
"control shards set-mode",
|
||||||
wallet_password,
|
wallet_password,
|
||||||
**{
|
**{
|
||||||
param: value
|
param: value
|
||||||
|
@ -80,6 +84,7 @@ class FrostfsCliShards(CliCommand):
|
||||||
path: str,
|
path: str,
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
no_errors: bool = False,
|
no_errors: bool = False,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Dump objects from shard to a file.
|
Dump objects from shard to a file.
|
||||||
|
@ -92,12 +97,13 @@ class FrostfsCliShards(CliCommand):
|
||||||
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
wallet_password: Wallet password.
|
wallet_password: Wallet password.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
"""
|
"""
|
||||||
return self._execute_with_password(
|
return self._execute_with_password(
|
||||||
f"control shards dump",
|
"control shards dump",
|
||||||
wallet_password,
|
wallet_password,
|
||||||
**{
|
**{
|
||||||
param: value
|
param: value
|
||||||
|
@ -113,6 +119,7 @@ class FrostfsCliShards(CliCommand):
|
||||||
wallet_password: str,
|
wallet_password: str,
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
json_mode: bool = False,
|
json_mode: bool = False,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
List shards of the storage node.
|
List shards of the storage node.
|
||||||
|
@ -123,12 +130,13 @@ class FrostfsCliShards(CliCommand):
|
||||||
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
wallet_password: Wallet password.
|
wallet_password: Wallet password.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
"""
|
"""
|
||||||
return self._execute_with_password(
|
return self._execute_with_password(
|
||||||
f"control shards list",
|
"control shards list",
|
||||||
wallet_password,
|
wallet_password,
|
||||||
**{
|
**{
|
||||||
param: value
|
param: value
|
||||||
|
|
|
@ -16,6 +16,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
lifetime: Optional[int] = None,
|
lifetime: Optional[int] = None,
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Put storage group to FrostFS.
|
Put storage group to FrostFS.
|
||||||
|
@ -30,6 +31,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
ttl: TTL value in request meta header.
|
ttl: TTL value in request meta header.
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -52,6 +54,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
lifetime: Optional[int] = None,
|
lifetime: Optional[int] = None,
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Get storage group from FrostFS.
|
Get storage group from FrostFS.
|
||||||
|
@ -67,6 +70,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
ttl: TTL value in request meta header.
|
ttl: TTL value in request meta header.
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -87,6 +91,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
lifetime: Optional[int] = None,
|
lifetime: Optional[int] = None,
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
List storage groups in FrostFS container.
|
List storage groups in FrostFS container.
|
||||||
|
@ -101,6 +106,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
ttl: TTL value in request meta header.
|
ttl: TTL value in request meta header.
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
@ -122,6 +128,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
lifetime: Optional[int] = None,
|
lifetime: Optional[int] = None,
|
||||||
address: Optional[str] = None,
|
address: Optional[str] = None,
|
||||||
xhdr: Optional[dict] = None,
|
xhdr: Optional[dict] = None,
|
||||||
|
timeout: Optional[str] = None,
|
||||||
) -> CommandResult:
|
) -> CommandResult:
|
||||||
"""
|
"""
|
||||||
Delete storage group from FrostFS.
|
Delete storage group from FrostFS.
|
||||||
|
@ -137,6 +144,7 @@ class FrostfsCliStorageGroup(CliCommand):
|
||||||
ttl: TTL value in request meta header.
|
ttl: TTL value in request meta header.
|
||||||
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
||||||
xhdr: Dict with request X-Headers.
|
xhdr: Dict with request X-Headers.
|
||||||
|
timeout: Timeout for an operation (default 15s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Command's result.
|
Command's result.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from datetime import datetime
|
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.hosting.config import CLIConfig, HostConfig, ServiceConfig
|
||||||
from frostfs_testlib.shell.interfaces import Shell
|
from frostfs_testlib.shell.interfaces import Shell
|
||||||
|
|
Loading…
Reference in a new issue