2022-07-05 07:18:37 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
from re import search
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
2022-07-01 17:30:07 +00:00
|
|
|
from robot.api import deco
|
|
|
|
|
2022-07-05 07:18:37 +00:00
|
|
|
import wallet
|
|
|
|
from cli_helpers import _cmd_run
|
2022-07-20 14:55:25 +00:00
|
|
|
from common import ASSETS_DIR, FREE_STORAGE, MAINNET_WALLET_PATH, NEOFS_NETMAP_DICT
|
2022-07-01 17:30:07 +00:00
|
|
|
from payment_neogo import neofs_deposit, transfer_mainnet_gas
|
2022-07-20 14:55:25 +00:00
|
|
|
from python_keywords.node_management import node_healthcheck
|
|
|
|
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-07-12 09:59:19 +00:00
|
|
|
def robot_keyword_adapter(name=None, tags=(), types=()):
|
|
|
|
return allure.step(name)
|
2022-07-20 14:55:25 +00:00
|
|
|
|
|
|
|
|
2022-07-12 09:59:19 +00:00
|
|
|
deco.keyword = robot_keyword_adapter
|
2022-07-05 07:18:37 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger('NeoLogger')
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session', autouse=True)
|
|
|
|
@allure.title('Check binary versions')
|
|
|
|
def check_binary_versions(request):
|
|
|
|
environment_dir = request.config.getoption('--alluredir')
|
|
|
|
binaries = ['neo-go', 'neofs-cli', 'neofs-authmate', 'aws']
|
|
|
|
env_out = {}
|
|
|
|
for binary in binaries:
|
|
|
|
out = _cmd_run(f'{binary} --version')
|
|
|
|
version = search(r'(v?\d.*)\s+', out)
|
|
|
|
version = version.group(1) if version else 'Unknown'
|
|
|
|
env_out[binary.upper()] = version
|
|
|
|
|
|
|
|
if environment_dir:
|
|
|
|
with open(f'{environment_dir}/environment.properties', 'w') as out_file:
|
|
|
|
for env, env_value in env_out.items():
|
|
|
|
out_file.write(f'{env}={env_value}\n')
|
|
|
|
|
|
|
|
|
2022-07-20 14:55:25 +00:00
|
|
|
@pytest.fixture(scope='session', autouse=True)
|
|
|
|
@allure.title('Run health check for all storage nodes')
|
|
|
|
def run_health_check():
|
|
|
|
failed_nodes = []
|
|
|
|
for node_name in NEOFS_NETMAP_DICT.keys():
|
|
|
|
health_check = node_healthcheck(node_name)
|
|
|
|
if health_check.health_status != 'READY' or health_check.network_status != 'ONLINE':
|
|
|
|
failed_nodes.append(node_name)
|
|
|
|
|
|
|
|
if failed_nodes:
|
|
|
|
raise AssertionError(f'Nodes {failed_nodes} are not healthy')
|
|
|
|
|
|
|
|
|
2022-07-05 07:18:37 +00:00
|
|
|
@pytest.fixture(scope='session')
|
2022-07-08 17:24:55 +00:00
|
|
|
@allure.title('Prepare tmp directory')
|
|
|
|
def prepare_tmp_dir():
|
|
|
|
full_path = f'{os.getcwd()}/{ASSETS_DIR}'
|
2022-07-11 14:11:26 +00:00
|
|
|
shutil.rmtree(full_path, ignore_errors=True)
|
2022-07-08 17:24:55 +00:00
|
|
|
os.mkdir(full_path)
|
2022-07-12 08:23:48 +00:00
|
|
|
yield full_path
|
2022-07-05 07:18:37 +00:00
|
|
|
shutil.rmtree(full_path)
|
|
|
|
|
|
|
|
|
2022-07-12 08:23:48 +00:00
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
@allure.title('Init wallet with address')
|
|
|
|
def init_wallet_with_address(prepare_tmp_dir):
|
|
|
|
yield wallet.init_wallet(ASSETS_DIR)
|
|
|
|
|
|
|
|
|
2022-07-05 07:18:37 +00:00
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
@allure.title('Prepare wallet and deposit')
|
|
|
|
def prepare_wallet_and_deposit(init_wallet_with_address):
|
2022-07-01 17:30:07 +00:00
|
|
|
wallet, addr, _ = init_wallet_with_address
|
|
|
|
logger.info(f'Init wallet: {wallet},\naddr: {addr}')
|
|
|
|
|
2022-07-05 10:17:36 +00:00
|
|
|
if not FREE_STORAGE:
|
|
|
|
deposit = 30
|
2022-07-12 09:59:19 +00:00
|
|
|
transfer_mainnet_gas(wallet, deposit + 1, wallet_path=MAINNET_WALLET_PATH)
|
2022-07-05 10:17:36 +00:00
|
|
|
neofs_deposit(wallet, deposit)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-07-01 17:30:07 +00:00
|
|
|
return wallet
|