From 439a5595f82dab5ec1d3fd5c23ddd1c1ae394126 Mon Sep 17 00:00:00 2001 From: "a.berezin" Date: Fri, 7 Jun 2024 17:13:50 +0300 Subject: [PATCH] [#252] Refactor version checks Signed-off-by: a.berezin --- pytest_tests/testsuites/conftest.py | 13 +++- .../testsuites/services/test_binaries.py | 75 +++++-------------- 2 files changed, 29 insertions(+), 59 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 7d05e962..0e16fbe9 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -354,15 +354,20 @@ def two_buckets(s3_client: S3ClientWrapper, request: pytest.FixtureRequest): s3_helper.delete_bucket_with_objects(s3_client, bucket_name) -@allure.title("[Autouse/Session] Check binary versions") +@allure.title("[Autouse/Session] Collect binary versions") @pytest.fixture(scope="session", autouse=True) -def check_binary_versions(hosting: Hosting, client_shell: Shell, request: pytest.FixtureRequest): +def collect_binary_versions(hosting: Hosting, client_shell: Shell, request: pytest.FixtureRequest): local_versions = version_utils.get_local_binaries_versions(client_shell) - remote_versions, exсeptions_remote_binaries_versions = version_utils.get_remote_binaries_versions(hosting) + remote_versions = version_utils.get_remote_binaries_versions(hosting) + remote_versions_keys = list(remote_versions.keys()) all_versions = { **local_versions, - **{binary_name: binary["version"] for binary_name, binary in remote_versions.items()}, + **{ + f"{name}_{remote_versions_keys.index(host) + 1:02d}": version + for host, versions in remote_versions.items() + for name, version in versions.items() + }, } environment_dir = request.config.getoption("--alluredir") diff --git a/pytest_tests/testsuites/services/test_binaries.py b/pytest_tests/testsuites/services/test_binaries.py index 0307ad3e..db1ac947 100644 --- a/pytest_tests/testsuites/services/test_binaries.py +++ b/pytest_tests/testsuites/services/test_binaries.py @@ -1,77 +1,42 @@ import logging -import os -from http import HTTPStatus -from re import fullmatch, match +from re import fullmatch import allure import pytest -import requests from frostfs_testlib import reporter from frostfs_testlib.hosting import Hosting -from frostfs_testlib.resources.common import ASSETS_DIR -from frostfs_testlib.utils.env_utils import read_env_properties, save_env_properties from frostfs_testlib.utils.version_utils import get_remote_binaries_versions -from pytest import FixtureRequest logger = logging.getLogger("NeoLogger") +VERSION_REGEX = r"^([a-zA-Z0-9]*/)?\d+\.\d+\.\d+(-.*)?(? dict: - binaries_to_version = {} - - response = requests.get(url) - - assert response.status_code == HTTPStatus.OK, f"Got {response.status_code} code. Content {response.json()}" - - content = response.text - assert content, f"Expected file with content, got {response}" - - for line in content.split("\n"): - m = match("(.*)=(.*)", line) - if not m: - logger.warning(f"Could not get binary/version from {line}") - continue - bin_name, bin_version = m.group(1), m.group(2) - binaries_to_version[bin_name] = bin_version - - return binaries_to_version + assert not exсeptions, "\n".join(exсeptions)