Update variables for node management tests

New variables allow us:
1. To configure path of CLI binaries and config file on storage node.
2. Update variable names for storage node endpoints.

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-07-05 15:55:16 +04:00
parent d9d74baa72
commit 68cbb7deea
3 changed files with 65 additions and 74 deletions

View file

@ -54,6 +54,7 @@ def crate_container_and_pick_node(create_remote_connection, prepare_wallet_and_d
@pytest.fixture @pytest.fixture
@pytest.mark.skip(reason="docker API works only for devenv")
def start_node_if_needed(create_remote_connection): def start_node_if_needed(create_remote_connection):
yield yield
try: try:
@ -167,6 +168,7 @@ def test_placement_policy_negative(prepare_wallet_and_deposit, placement_rule, e
@pytest.mark.node_mgmt @pytest.mark.node_mgmt
@pytest.mark.skip(reason="docker API works only for devenv")
@allure.title('NeoFS object replication on node failover') @allure.title('NeoFS object replication on node failover')
def test_replication(prepare_wallet_and_deposit, create_remote_connection, start_node_if_needed): def test_replication(prepare_wallet_and_deposit, create_remote_connection, start_node_if_needed):
""" """

View file

@ -8,10 +8,10 @@
import random import random
import re import re
from dataclasses import dataclass from dataclasses import dataclass
from typing import List, Tuple from typing import List
import docker import docker
from common import DEPLOY_PATH, NEOFS_NETMAP_DICT from common import NEOFS_NETMAP_DICT, STORAGE_NODE_BIN_PATH, STORAGE_NODE_CONFIG_PATH
from robot.api import logger from robot.api import logger
from robot.api.deco import keyword from robot.api.deco import keyword
from ssh_helper import HostClient from ssh_helper import HostClient
@ -152,10 +152,8 @@ def node_healthcheck(client: HostClient, node_name: str) -> HealthStatus:
node_config = NEOFS_NETMAP_DICT.get(node_name) node_config = NEOFS_NETMAP_DICT.get(node_name)
control_url = node_config.get('control') control_url = node_config.get('control')
host, port = control_url.split(':') cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control healthcheck --endpoint {control_url} ' \
cmd = f'{DEPLOY_PATH}/vendor/neofs-cli control healthcheck --endpoint {control_url} ' \ f'--config {STORAGE_NODE_CONFIG_PATH}'
f'--wallet {DEPLOY_PATH}/services/storage/wallet0{port[-1]}.json ' \
f'--config {DEPLOY_PATH}/services/storage/cli-cfg.yml'
output = client.exec_with_confirmation(cmd, ['']) output = client.exec_with_confirmation(cmd, [''])
return HealthStatus.from_stdout(output.stdout) return HealthStatus.from_stdout(output.stdout)
@ -176,10 +174,8 @@ def node_set_status(client: HostClient, node_name: str, status: str):
node_config = NEOFS_NETMAP_DICT.get(node_name) node_config = NEOFS_NETMAP_DICT.get(node_name)
control_url = node_config.get('control') control_url = node_config.get('control')
host, port = control_url.split(':') cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control set-status --endpoint {control_url} ' \
cmd = f'{DEPLOY_PATH}/vendor/neofs-cli control set-status --endpoint {control_url} ' \ f'--config {STORAGE_NODE_CONFIG_PATH} --status {status}'
f'--wallet {DEPLOY_PATH}/services/storage/wallet0{port[-1]}.json ' \
f'--config {DEPLOY_PATH}/services/storage/cli-cfg.yml --status {status}'
client.exec_with_confirmation(cmd, ['']) client.exec_with_confirmation(cmd, [''])
@ -200,10 +196,8 @@ def get_netmap_snapshot(client: HostClient, node_name: str = None) -> str:
node_config = NEOFS_NETMAP_DICT.get(node_name) node_config = NEOFS_NETMAP_DICT.get(node_name)
control_url = node_config.get('control') control_url = node_config.get('control')
host, port = control_url.split(':') cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control netmap-snapshot --endpoint {control_url} ' \
cmd = f'{DEPLOY_PATH}/vendor/neofs-cli control netmap-snapshot --endpoint {control_url} ' \ f'--config {STORAGE_NODE_CONFIG_PATH}'
f'--wallet {DEPLOY_PATH}/services/storage/wallet0{port[-1]}.json ' \
f'--config {DEPLOY_PATH}/services/storage/cli-cfg.yml'
output = client.exec_with_confirmation(cmd, ['']) output = client.exec_with_confirmation(cmd, [''])
return output.stdout return output.stdout
@ -218,10 +212,10 @@ def node_shard_list(client: HostClient, node_name: str) -> List[str]:
Returns: Returns:
list of shards. list of shards.
""" """
control_url, port = _url_port_for_node(node_name) node_config = NEOFS_NETMAP_DICT.get(node_name)
cmd = f'{DEPLOY_PATH}/vendor/neofs-cli control shards list --endpoint {control_url} ' \ control_url = node_config.get('control')
f'--wallet {DEPLOY_PATH}/services/storage/wallet0{port[-1]}.json ' \ cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control shards list --endpoint {control_url} ' \
f'--config {DEPLOY_PATH}/services/storage/cli-cfg.yml' f'--config {STORAGE_NODE_CONFIG_PATH}'
output = client.exec_with_confirmation(cmd, ['']) output = client.exec_with_confirmation(cmd, [''])
return re.findall(r'Shard (.*):', output.stdout) return re.findall(r'Shard (.*):', output.stdout)
@ -236,10 +230,10 @@ def node_shard_set_mode(client: HostClient, node_name: str, shard: str, mode: st
Returns: Returns:
health status as HealthStatus object. health status as HealthStatus object.
""" """
control_url, port = _url_port_for_node(node_name) node_config = NEOFS_NETMAP_DICT.get(node_name)
cmd = f'{DEPLOY_PATH}/vendor/neofs-cli control shards set-mode --endpoint {control_url} ' \ control_url = node_config.get('control')
f'--wallet {DEPLOY_PATH}/services/storage/wallet0{port[-1]}.json ' \ cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control shards set-mode --endpoint {control_url} ' \
f'--config {DEPLOY_PATH}/services/storage/cli-cfg.yml --id {shard} --mode {mode}' f'--config {STORAGE_NODE_CONFIG_PATH} --id {shard} --mode {mode}'
output = client.exec_with_confirmation(cmd, ['']) output = client.exec_with_confirmation(cmd, [''])
return output.stdout return output.stdout
@ -254,27 +248,9 @@ def drop_object(client: HostClient, node_name: str, cid: str, oid: str) -> str:
Returns: Returns:
health status as HealthStatus object. health status as HealthStatus object.
""" """
control_url, port = _url_port_for_node(node_name)
cmd = f'{DEPLOY_PATH}/vendor/neofs-cli control drop-objects --endpoint {control_url} ' \
f'--wallet {DEPLOY_PATH}/services/storage/wallet0{port[-1]}.json ' \
f'--config {DEPLOY_PATH}/services/storage/cli-cfg.yml -o {cid}/{oid}'
output = client.exec_with_confirmation(cmd, [''])
return output.stdout
def _url_port_for_node(node_name: str) -> Tuple[str, str]:
"""
Returns control url and port for particular storage node.
Args:
node_name: str node bane from NEOFS_NETMAP_DICT
Returns:
control url and port as a tuple.
"""
if node_name not in NEOFS_NETMAP_DICT:
raise AssertionError(f'Node {node_name} is not found!')
node_config = NEOFS_NETMAP_DICT.get(node_name) node_config = NEOFS_NETMAP_DICT.get(node_name)
control_url = node_config.get('control') control_url = node_config.get('control')
port = control_url.split(':')[-1] cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control drop-objects --endpoint {control_url} ' \
return control_url, port f'--config {STORAGE_NODE_CONFIG_PATH} -o {cid}/{oid}'
output = client.exec_with_confirmation(cmd, [''])
return output.stdout

View file

@ -32,34 +32,44 @@ ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/")
MORPH_MAGIC = os.getenv("MORPH_MAGIC") MORPH_MAGIC = os.getenv("MORPH_MAGIC")
STORAGE_NODE_1 = os.getenv('DATA_NODE_1', 's01.neofs.devenv:8080')
STORAGE_NODE_2 = os.getenv('DATA_NODE_2', 's02.neofs.devenv:8080')
STORAGE_NODE_3 = os.getenv('DATA_NODE_3', 's03.neofs.devenv:8080')
STORAGE_NODE_4 = os.getenv('DATA_NODE_4', 's04.neofs.devenv:8080')
CONTROL_NODE_1 = os.getenv('NEOFS_CONTROL_NODE_1', 's01.neofs.devenv:8081')
CONTROL_NODE_2 = os.getenv('NEOFS_CONTROL_NODE_2', 's02.neofs.devenv:8081')
CONTROL_NODE_3 = os.getenv('NEOFS_CONTROL_NODE_3', 's03.neofs.devenv:8081')
CONTROL_NODE_4 = os.getenv('NEOFS_CONTROL_NODE_4', 's04.neofs.devenv:8081')
DEVENV_SERVICES_PATH = f"{os.getenv('DEVENV_PATH')}/services" DEVENV_SERVICES_PATH = f"{os.getenv('DEVENV_PATH')}/services"
NEOFS_NETMAP_DICT = {'s01': {'rpc': STORAGE_NODE_1,
'control': CONTROL_NODE_1, STORAGE_RPC_ENDPOINT_1 = os.getenv('STORAGE_RPC_ENDPOINT_1', os.getenv('DATA_NODE_1', 's01.neofs.devenv:8080'))
STORAGE_RPC_ENDPOINT_2 = os.getenv('STORAGE_RPC_ENDPOINT_2', os.getenv('DATA_NODE_2', 's02.neofs.devenv:8080'))
STORAGE_RPC_ENDPOINT_3 = os.getenv('STORAGE_RPC_ENDPOINT_3', os.getenv('DATA_NODE_3', 's03.neofs.devenv:8080'))
STORAGE_RPC_ENDPOINT_4 = os.getenv('STORAGE_RPC_ENDPOINT_4', os.getenv('DATA_NODE_4', 's04.neofs.devenv:8080'))
STORAGE_CONTROL_ENDPOINT_1 = os.getenv('STORAGE_CONTROL_ENDPOINT_1', os.getenv('NEOFS_CONTROL_NODE_1', 's01.neofs.devenv:8081'))
STORAGE_CONTROL_ENDPOINT_2 = os.getenv('STORAGE_CONTROL_ENDPOINT_2', os.getenv('NEOFS_CONTROL_NODE_2', 's02.neofs.devenv:8081'))
STORAGE_CONTROL_ENDPOINT_3 = os.getenv('STORAGE_CONTROL_ENDPOINT_3', os.getenv('NEOFS_CONTROL_NODE_3', 's03.neofs.devenv:8081'))
STORAGE_CONTROL_ENDPOINT_4 = os.getenv('STORAGE_CONTROL_ENDPOINT_4', os.getenv('NEOFS_CONTROL_NODE_4', 's04.neofs.devenv:8081'))
NEOFS_NETMAP_DICT = {
's01': {
'rpc': STORAGE_RPC_ENDPOINT_1,
'control': STORAGE_CONTROL_ENDPOINT_1,
'wallet_path':f"{DEVENV_SERVICES_PATH}/storage/wallet01.json", 'wallet_path':f"{DEVENV_SERVICES_PATH}/storage/wallet01.json",
'UN-LOCODE': 'RU MOW'}, 'UN-LOCODE': 'RU MOW'
's02': {'rpc': STORAGE_NODE_2, },
'control': CONTROL_NODE_2, 's02': {
'rpc': STORAGE_RPC_ENDPOINT_2,
'control': STORAGE_CONTROL_ENDPOINT_2,
'wallet_path': f"{DEVENV_SERVICES_PATH}/storage/wallet02.json", 'wallet_path': f"{DEVENV_SERVICES_PATH}/storage/wallet02.json",
'UN-LOCODE': 'RU LED'}, 'UN-LOCODE': 'RU LED'
's03': {'rpc': STORAGE_NODE_3, },
'control': CONTROL_NODE_3, 's03': {
'rpc': STORAGE_RPC_ENDPOINT_3,
'control': STORAGE_CONTROL_ENDPOINT_3,
'wallet_path': f"{DEVENV_SERVICES_PATH}/storage/wallet03.json", 'wallet_path': f"{DEVENV_SERVICES_PATH}/storage/wallet03.json",
'UN-LOCODE': 'SE STO'}, 'UN-LOCODE': 'SE STO'
's04': {'rpc': STORAGE_NODE_4, },
'control': CONTROL_NODE_4, 's04': {
'rpc': STORAGE_RPC_ENDPOINT_4,
'control': STORAGE_CONTROL_ENDPOINT_4,
'wallet_path': f"{DEVENV_SERVICES_PATH}/storage/wallet04.json", 'wallet_path': f"{DEVENV_SERVICES_PATH}/storage/wallet04.json",
'UN-LOCODE': 'FI HEL'} 'UN-LOCODE': 'FI HEL'
} },
}
NEOFS_NETMAP = [i['rpc'] for i in NEOFS_NETMAP_DICT.values()] NEOFS_NETMAP = [i['rpc'] for i in NEOFS_NETMAP_DICT.values()]
NEOGO_EXECUTABLE = os.getenv('NEOGO_EXECUTABLE', 'neo-go') NEOGO_EXECUTABLE = os.getenv('NEOGO_EXECUTABLE', 'neo-go')
NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli') NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
@ -76,8 +86,11 @@ STORAGE_WALLET_PATH = f"{DEVENV_SERVICES_PATH}/storage/wallet01.json"
S3_GATE_WALLET_PATH = f"{DEVENV_SERVICES_PATH}/s3_gate/wallet.json" S3_GATE_WALLET_PATH = f"{DEVENV_SERVICES_PATH}/s3_gate/wallet.json"
S3_GATE_WALLET_PASS = 's3' S3_GATE_WALLET_PASS = 's3'
CONTROL_NODE_USER = os.getenv('CONTROL_NODE_USER', 'root') WALLET_PASS = f"{os.getcwd()}/wallet_pass.yml"
CONTROL_NODE_PWD = os.getenv('CONTROL_NODE_PWD')
DEPLOY_PATH = os.getenv('DEPLOY_PATH', '/opt/dev-env') STORAGE_NODE_USER = os.getenv('STORAGE_NODE_USER', 'root')
STORAGE_NODE_PWD = os.getenv('STORAGE_NODE_PWD')
STORAGE_NODE_BIN_PATH = os.getenv('STORAGE_NODE_BIN_PATH', '/opt/dev-env/vendor/neofs-cli')
STORAGE_NODE_CONFIG_PATH = os.getenv('STORAGE_NODE_CONFIG_PATH', '/opt/dev-env/services/storage/cli-cfg.yml')
FREE_STORAGE = os.getenv('FREE_STORAGE', "false").lower() == "true" FREE_STORAGE = os.getenv('FREE_STORAGE', "false").lower() == "true"