Fix SSH connection to storage node in node management tests.

This commit is contained in:
Vladimir Domnich 2022-07-14 11:33:45 +04:00
parent b1746f3eeb
commit 72cd1f4893
5 changed files with 71 additions and 61 deletions

101
Makefile
View file

@ -53,29 +53,34 @@ setup-for-remote-devenv:
# Download services directory from remote devenv into $(SETUP_DIR)/services
scp -r root@$(DEV_ENV_HOST_NAME):$(DEV_ENV_DEPLOY_DIR)/services $(SETUP_DIR)
# Generate .env file
echo NEO_MAINNET_ENDPOINT=http://$(DEV_ENV_HOST_NAME):30333 > $(CURDIR)/.env
echo MORPH_ENDPOINT=http://$(DEV_ENV_HOST_NAME):30334 >> $(CURDIR)/.env
echo HTTP_GATE=http://$(DEV_ENV_HOST_NAME):81 >> $(CURDIR)/.env
echo S3_GATE=https://$(DEV_ENV_HOST_NAME):8080 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_1=$(DEV_ENV_HOST_NAME):8181 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_2=$(DEV_ENV_HOST_NAME):8182 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_3=$(DEV_ENV_HOST_NAME):8183 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_4=$(DEV_ENV_HOST_NAME):8184 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_1=$(DEV_ENV_HOST_NAME):8081 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_2=$(DEV_ENV_HOST_NAME):8082 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_3=$(DEV_ENV_HOST_NAME):8083 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_4=$(DEV_ENV_HOST_NAME):8084 >> $(CURDIR)/.env
echo NEOFS_ENDPOINT=$(DEV_ENV_HOST_NAME):8081 >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_1="/.setup/services/storage/wallet01.json"
echo STORAGE_WALLET_PATH_2="/.setup/services/storage/wallet02.json"
echo STORAGE_WALLET_PATH_3="/.setup/services/storage/wallet03.json"
echo STORAGE_WALLET_PATH_4="/.setup/services/storage/wallet04.json"
echo MAINNET_WALLET_PATH="/.setup/services/chain/node-wallet.json" >> $(CURDIR)/.env
echo IR_WALLET_PATH="/.setup/services/ir/wallet01.json" >> $(CURDIR)/.env
echo NEO_MAINNET_ENDPOINT=http://$(DEV_ENV_HOST_NAME):30333 > .env
echo MORPH_ENDPOINT=http://$(DEV_ENV_HOST_NAME):30334 >> .env
echo HTTP_GATE=http://$(DEV_ENV_HOST_NAME):81 >> .env
echo S3_GATE=https://$(DEV_ENV_HOST_NAME):8080 >> .env
echo NEOFS_ENDPOINT=$(DEV_ENV_HOST_NAME):8081 >> .env
# env: blockchain wallets
echo MAINNET_WALLET_PATH="/.setup/services/chain/node-wallet.json" >> .env
echo IR_WALLET_PATH="/.setup/services/ir/wallet01.json" >> .env
# env: storage nodes
echo STORAGE_CONTROL_ENDPOINT_1=$(DEV_ENV_HOST_NAME):8181 >> .env
echo STORAGE_CONTROL_ENDPOINT_2=$(DEV_ENV_HOST_NAME):8182 >> .env
echo STORAGE_CONTROL_ENDPOINT_3=$(DEV_ENV_HOST_NAME):8183 >> .env
echo STORAGE_CONTROL_ENDPOINT_4=$(DEV_ENV_HOST_NAME):8184 >> .env
echo STORAGE_RPC_ENDPOINT_1=$(DEV_ENV_HOST_NAME):8081 >> .env
echo STORAGE_RPC_ENDPOINT_2=$(DEV_ENV_HOST_NAME):8082 >> .env
echo STORAGE_RPC_ENDPOINT_3=$(DEV_ENV_HOST_NAME):8083 >> .env
echo STORAGE_RPC_ENDPOINT_4=$(DEV_ENV_HOST_NAME):8084 >> .env
echo STORAGE_WALLET_PATH_1="/.setup/services/storage/wallet01.json" >> .env
echo STORAGE_WALLET_PATH_2="/.setup/services/storage/wallet02.json" >> .env
echo STORAGE_WALLET_PATH_3="/.setup/services/storage/wallet03.json" >> .env
echo STORAGE_WALLET_PATH_4="/.setup/services/storage/wallet04.json" >> .env
# env: SSH connection to storage node
echo STORAGE_NODE_SSH_PRIVATE_KEY_PATH="/root/.ssh/id_rsa" >> .env
# env: files inside storage node to make calls via SSH on that node
echo STORAGE_NODE_BIN_PATH="$(DEV_ENV_DEPLOY_DIR)/vendor/neofs-cli" >> $(CURDIR)/.env
echo STORAGE_NODE_CONFIG_PATH="$(DEV_ENV_DEPLOY_DIR)/services/storage/cli-cfg.yml" >> $(CURDIR)/.env
ssh root@$(DEV_ENV_HOST_NAME) 'cd $(DEV_ENV_DEPLOY_DIR) && make env | grep NEOFS_IR_CONTRACTS_NEOFS' >> $(CURDIR)/.env
echo STORAGE_NODE_BIN_PATH="$(DEV_ENV_DEPLOY_DIR)/vendor" >> .env
echo STORAGE_NODE_CONFIG_PATH="$(DEV_ENV_DEPLOY_DIR)/services/storage/cli-cfg.yml" >> .env
# env: s3 gateway public key
ssh root@$(DEV_ENV_HOST_NAME) 'cd $(DEV_ENV_DEPLOY_DIR) && make env | grep NEOFS_IR_CONTRACTS_NEOFS' >> .env
.PHONY: setup-for-sbercloud
setup-for-sbercloud:
@ -84,41 +89,41 @@ setup-for-sbercloud:
cp -r $(CONFIG_DIR)/alphabet-wallets $(SETUP_DIR)
cp -r $(CONFIG_DIR)/wallets $(SETUP_DIR)
# Copy neofs-adm config to setup directory (and adjust path to wallets)
cat $(CONFIG_DIR)/config.yaml | sed "s|alphabet-wallets:.*|alphabet-wallets: $(SETUP_DIR)/alphabet-wallets|" > $(SETUP_DIR)/config.yaml
cat $(CONFIG_DIR)/config.yaml | sed "s|alphabet-wallets:.*|alphabet-wallets: /.setup/alphabet-wallets|" > $(SETUP_DIR)/config.yaml
# Generate .env file (NEO_MAINNET_ENDPOINT might be incorrect, but we don't use it)
echo NEO_MAINNET_ENDPOINT=http://$(NODE1):40333 > $(CURDIR)/.env
echo MORPH_ENDPOINT=http://$(NODE1):40332 >> $(CURDIR)/.env
echo HTTP_GATE=http://$(NODE1):8888 >> $(CURDIR)/.env
echo S3_GATE=http://$(NODE1):8084 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_1=$(NODE1):40332 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_2=$(NODE2):40332 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_3=$(NODE3):40332 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_4=$(NODE4):40332 >> $(CURDIR)/.env
echo NEOFS_ENDPOINT=$(NODE1):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_1=$(NODE1):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_2=$(NODE2):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_3=$(NODE3):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_4=$(NODE4):8080 >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_1="/.setup/wallets/node1-storage.json" >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_2="/.setup/wallets/node2-storage.json" >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_3="/.setup/wallets/node3-storage.json" >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_4="/.setup/wallets/node4-storage.json" >> $(CURDIR)/.env
echo MAINNET_WALLET_PATH="/.setup/alphabet-wallets/az.json" >> $(CURDIR)/.env
echo FREE_STORAGE=true >> $(CURDIR)/.env
echo NEOFS_ADM_EXEC="neofs-adm" >> $(CURDIR)/.env
echo NEOFS_ADM_CONFIG_PATH="/.setup/config.yaml" >> $(CURDIR)/.env
echo NEO_MAINNET_ENDPOINT=http://$(NODE1):40333 > .env
echo MORPH_ENDPOINT=http://$(NODE1):40332 >> .env
echo HTTP_GATE=http://$(NODE1):8888 >> .env
echo S3_GATE=http://$(NODE1):8084 >> .env
echo STORAGE_CONTROL_ENDPOINT_1=$(NODE1):40332 >> .env
echo STORAGE_CONTROL_ENDPOINT_2=$(NODE2):40332 >> .env
echo STORAGE_CONTROL_ENDPOINT_3=$(NODE3):40332 >> .env
echo STORAGE_CONTROL_ENDPOINT_4=$(NODE4):40332 >> .env
echo NEOFS_ENDPOINT=$(NODE1):8080 >> .env
echo STORAGE_RPC_ENDPOINT_1=$(NODE1):8080 >> .env
echo STORAGE_RPC_ENDPOINT_2=$(NODE2):8080 >> .env
echo STORAGE_RPC_ENDPOINT_3=$(NODE3):8080 >> .env
echo STORAGE_RPC_ENDPOINT_4=$(NODE4):8080 >> .env
echo STORAGE_WALLET_PATH_1="/.setup/wallets/node1-storage.json" >> .env
echo STORAGE_WALLET_PATH_2="/.setup/wallets/node2-storage.json" >> .env
echo STORAGE_WALLET_PATH_3="/.setup/wallets/node3-storage.json" >> .env
echo STORAGE_WALLET_PATH_4="/.setup/wallets/node4-storage.json" >> .env
echo MAINNET_WALLET_PATH="/.setup/alphabet-wallets/az.json" >> .env
echo FREE_STORAGE=true >> .env
echo NEOFS_ADM_EXEC="neofs-adm" >> .env
echo NEOFS_ADM_CONFIG_PATH="/.setup/config.yaml" >> .env
# env: files inside storage node to make calls via SSH on that node
echo STORAGE_NODE_BIN_PATH="/usr/local/bin/" >> $(CURDIR)/.env
echo STORAGE_NODE_CONFIG_PATH="/tmp/conf.yaml" >> $(CURDIR)/.env
echo STORAGE_NODE_BIN_PATH="/usr/local/bin/" >> .env
echo STORAGE_NODE_CONFIG_PATH="/tmp/conf.yaml" >> .env
# env: s3 gateway public key
echo S3_GATE_PUB_KEY=$(shell $(NEO_BIN_DIR)/neo-go wallet dump-keys -w $(CONFIG_DIR)/wallets/node1-s3.json | head -2 | tail -1) >> $(CURDIR)/.env
echo S3_GATE_PUB_KEY=$(shell $(NEO_BIN_DIR)/neo-go wallet dump-keys -w $(CONFIG_DIR)/wallets/node1-s3.json | head -2 | tail -1) >> .env
.PHONY: pytest-docker
pytest-docker:
-docker ps
-docker rm neofs_tests_py$(BUILD_NUMBER)
-docker pull $(DEV_IMAGE_PY)
docker run -t --rm \
docker run -t --rm \
-w /tests \
--name neofs_tests_py$(BUILD_NUMBER) \
-e PYTHONPATH="/tests/neofs-keywords/lib:/tests/neofs-keywords/robot:/tests/robot/resources/lib:/tests/robot/resources/lib/python_keywords:/tests/robot/variables:/tests/pytest_tests/helpers" \

View file

@ -41,7 +41,7 @@ def return_all_storage_nodes_fixture(sbercloud_client):
def panic_reboot_host(ip: str = None):
ssh = HostClient(ip=ip)
ssh = HostClient(ip=ip, private_key_path=f"{os.getcwd()}/configuration/id_rsa")
ssh.exec('echo 1 > /proc/sys/kernel/sysrq')
with pytest.raises(HostIsNotAvailable):
ssh.exec('echo b > /proc/sysrq-trigger', timeout=1)

View file

@ -3,15 +3,15 @@ from time import sleep
import allure
import pytest
from common import SIMPLE_OBJ_SIZE, COMPLEX_OBJ_SIZE
from container import create_container
from epoch import get_epoch, tick_epoch
from tombstone import verify_head_tombstone
from python_keywords.neofs_verbs import (delete_object, get_object, get_range,
get_range_hash, head_object,
put_object, search_object)
from python_keywords.storage_policy import get_simple_object_copies
from python_keywords.utility_keywords import generate_file, get_file_hash
from common import SIMPLE_OBJ_SIZE, COMPLEX_OBJ_SIZE
from tombstone import verify_head_tombstone
from utility import get_file_content
logger = logging.getLogger('NeoLogger')
@ -99,11 +99,12 @@ def test_object_api(prepare_wallet_and_deposit, request, object_size):
@pytest.mark.sanity
@pytest.mark.grpc_api
@pytest.mark.parametrize('object_size', [SIMPLE_OBJ_SIZE, COMPLEX_OBJ_SIZE], ids=['simple object', 'complex object'])
def test_object_life_time(prepare_container, request, object_size):
def test_object_api(prepare_wallet_and_deposit, request, object_size):
"""
Test object deleted after expiration epoch.
"""
cid, wallet = prepare_container
wallet = prepare_wallet_and_deposit
cid = create_container(wallet)
allure.dynamic.title(f'Test object life time for {request.node.callspec.id}')

View file

@ -13,7 +13,8 @@ from typing import List
import docker
from common import (NEOFS_NETMAP_DICT, STORAGE_NODE_BIN_PATH, STORAGE_NODE_CONFIG_PATH,
STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT, STORAGE_NODE_PWD, STORAGE_NODE_USER)
STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT, STORAGE_NODE_SSH_PASSWORD,
STORAGE_NODE_SSH_PRIVATE_KEY_PATH, STORAGE_NODE_SSH_USER)
from robot.api import logger
from robot.api.deco import keyword
from ssh_helper import HostClient, HostIsNotAvailable
@ -44,10 +45,12 @@ def create_ssh_client(node_name: str) -> HostClient:
node_config = NEOFS_NETMAP_DICT.get(node_name)
host = node_config.get('control').split(':')[0]
try:
ssh_client = HostClient(host, STORAGE_NODE_USER, STORAGE_NODE_PWD)
except HostIsNotAvailable:
ssh_client = HostClient(host)
ssh_client = HostClient(
host,
login=STORAGE_NODE_SSH_USER,
password=STORAGE_NODE_SSH_PASSWORD,
private_key_path=STORAGE_NODE_SSH_PRIVATE_KEY_PATH,
)
try:
yield ssh_client

View file

@ -92,9 +92,10 @@ IR_WALLET_PATH = os.getenv("IR_WALLET_PATH", f"{DEVENV_PATH}/services/ir/wallet0
IR_WALLET_CONFIG = os.getenv("IR_WALLET_CONFIG", f"{os.getcwd()}/neofs_cli_configs/one_wallet_password.yml")
IR_WALLET_PASS = os.getenv("IR_WALLET_PASS", "one")
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", f"{DEVENV_PATH}/vendor/neofs-cli")
STORAGE_NODE_SSH_USER = os.getenv("STORAGE_NODE_SSH_USER", "root")
STORAGE_NODE_SSH_PASSWORD = os.getenv("STORAGE_NODE_SSH_PASSWORD")
STORAGE_NODE_SSH_PRIVATE_KEY_PATH = os.getenv("STORAGE_NODE_SSH_PRIVATE_KEY_PATH")
STORAGE_NODE_BIN_PATH = os.getenv("STORAGE_NODE_BIN_PATH", f"{DEVENV_PATH}/vendor")
STORAGE_NODE_CONFIG_PATH = os.getenv("STORAGE_NODE_CONFIG_PATH", f"{DEVENV_PATH}/services/storage/cli-cfg.yml")
STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT = os.getenv("STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT", "localhost:8091")