Move node deletion logic to service helper

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-08-05 00:03:06 +03:00 committed by Vladimir Domnich
parent 91197335ba
commit ce099c61a4
4 changed files with 201 additions and 130 deletions

View file

@ -12,7 +12,8 @@ from cli_helpers import _cmd_run
from common import (ASSETS_DIR, FREE_STORAGE, INFRASTRUCTURE_TYPE, MAINNET_WALLET_PATH,
NEOFS_NETMAP_DICT)
from payment_neogo import neofs_deposit, transfer_mainnet_gas
from python_keywords.node_management import node_healthcheck, create_ssh_client
from python_keywords.node_management import node_healthcheck
from service_helper import get_storage_service_helper
def robot_keyword_adapter(name=None, tags=(), types=()):
@ -26,42 +27,29 @@ logger = logging.getLogger('NeoLogger')
@pytest.fixture(scope='session')
def cloud_infrastructure_check():
if not is_cloud_infrastructure():
if INFRASTRUCTURE_TYPE != "CLOUD_VM":
pytest.skip('Test only works on SberCloud infrastructure')
yield
def is_cloud_infrastructure():
return INFRASTRUCTURE_TYPE == "CLOUD_VM"
@pytest.fixture(scope='session', autouse=True)
@allure.title('Check binary versions')
def check_binary_versions(request):
environment_dir = request.config.getoption('--alluredir')
is_cloud = is_cloud_infrastructure()
# Collect versions of neo binaries
# Collect versions of local binaries
binaries = ['neo-go', 'neofs-cli', 'neofs-authmate']
env_out = _get_binaries_version_local(binaries)
if is_cloud:
binaries = ['neo-go',
'neofs-adm',
'neofs-cli',
'neofs-http-gw',
'neofs-ir',
'neofs-lens',
'neofs-node',
'neofs-s3-authmate',
'neofs-s3-gw',
'neogo-morph-cn']
env_out = _get_binaries_version_remote(binaries)
# Collect versions of remote binaries
helper = get_storage_service_helper()
remote_binaries = helper.get_binaries_version()
env_out = {**env_out, **remote_binaries}
# Get version of aws binary
out = _cmd_run('aws --version')
out_lines = out.split("\n")
env_out["AWS"] = out_lines[0] if out_lines else 'Unknown'
environment_dir = request.config.getoption('--alluredir')
if environment_dir:
with open(f'{environment_dir}/environment.properties', 'w') as out_file:
for env, env_value in env_out.items():
@ -77,23 +65,6 @@ def _get_binaries_version_local(binaries: list) -> dict:
return env_out
def _get_binaries_version_remote(binaries: list) -> dict:
env_out = {}
for node_name in NEOFS_NETMAP_DICT:
with create_ssh_client(node_name) as ssh_client:
for binary in binaries:
out = ssh_client.exec(f'{binary} --version').stdout
version = re.search(r'version[:\s]*(.+)', out, re.IGNORECASE)
version = version.group(1) if version else 'Unknown'
if not env_out.get(binary.upper()):
env_out[binary.upper()] = version
else:
msg = f'Expected binary {binary} versions on node s1 and {node_name} are the same'
assert env_out[binary.upper()] == version, msg
return env_out
@pytest.fixture(scope='session', autouse=True)
@allure.title('Run health check for all storage nodes')
def run_health_check():