regex for versions ready

This commit is contained in:
Ekaterina Chernitsyna 2023-08-03 12:41:03 +03:00 committed by Andrey Berezin
parent 6449264dcf
commit d40e875091
2 changed files with 9 additions and 18 deletions

View file

@ -2,6 +2,5 @@ import os
TEST_CYCLES_COUNT = int(os.getenv("TEST_CYCLES_COUNT", "1")) TEST_CYCLES_COUNT = int(os.getenv("TEST_CYCLES_COUNT", "1"))
BIN_VERSIONS_FILE = os.getenv("BIN_VERSIONS_FILE")
DEVENV_PATH = os.getenv("DEVENV_PATH", os.path.join("..", "frostfs-dev-env")) DEVENV_PATH = os.getenv("DEVENV_PATH", os.path.join("..", "frostfs-dev-env"))
HOSTING_CONFIG_FILE = os.getenv("HOSTING_CONFIG_FILE", ".devenv.hosting.yaml") HOSTING_CONFIG_FILE = os.getenv("HOSTING_CONFIG_FILE", ".devenv.hosting.yaml")

View file

@ -1,7 +1,7 @@
import logging import logging
import os import os
from http import HTTPStatus from http import HTTPStatus
from re import match from re import match, fullmatch
import allure import allure
import pytest import pytest
@ -12,23 +12,15 @@ from frostfs_testlib.utils.env_utils import read_env_properties, save_env_proper
from frostfs_testlib.utils.version_utils import get_remote_binaries_versions from frostfs_testlib.utils.version_utils import get_remote_binaries_versions
from pytest import FixtureRequest from pytest import FixtureRequest
from pytest_tests.resources.common import BIN_VERSIONS_FILE
logger = logging.getLogger("NeoLogger") logger = logging.getLogger("NeoLogger")
@allure.title("Check binaries versions") @allure.title("Check binaries versions")
@pytest.mark.sanity @pytest.mark.sanity
@pytest.mark.check_binaries @pytest.mark.check_binaries
@pytest.mark.skip("Skipped due to https://j.yadro.com/browse/OBJECT-628")
def test_binaries_versions(request: FixtureRequest, hosting: Hosting): def test_binaries_versions(request: FixtureRequest, hosting: Hosting):
""" """
Compare binaries versions from external source (url) and deployed on servers. Compare binaries versions from external source (url) and deployed on servers.
""" """
if not BIN_VERSIONS_FILE:
pytest.skip("File with binaries and versions was not provided")
binaries_to_check = download_versions_info(BIN_VERSIONS_FILE)
with allure.step("Get binaries versions from servers"): with allure.step("Get binaries versions from servers"):
got_versions = get_remote_binaries_versions(hosting) got_versions = get_remote_binaries_versions(hosting)
@ -37,24 +29,24 @@ def test_binaries_versions(request: FixtureRequest, hosting: Hosting):
env_properties = read_env_properties(env_file) env_properties = read_env_properties(env_file)
# compare versions from servers and file # compare versions from servers and file
failed_versions = {} exeptions = []
additional_env_properties = {} additional_env_properties = {}
for binary, version in binaries_to_check.items():
actual_version = got_versions.get(binary) for binary, version in got_versions.items():
if actual_version != version: if not fullmatch(r"^\d+\.\d+\.\d+(-.*)?(?<!dirty)", version):
failed_versions[binary] = f"Expected version {version}, found version {actual_version}" exeptions.append(f"{binary}: Actual version doesn't conform to format '0.0.0-000-aaaaaaa': {version}")
# If some binary was not listed in the env properties file, let's add it # If some binary was not listed in the env properties file, let's add it
# so that we have full information about versions in allure report # so that we have full information about versions in allure report
if env_properties and binary not in env_properties: if env_properties and binary not in env_properties:
additional_env_properties[binary] = actual_version additional_env_properties[binary] = version
if env_properties and additional_env_properties: if env_properties and additional_env_properties:
save_env_properties(env_file, additional_env_properties) save_env_properties(env_file, additional_env_properties)
# create clear beautiful error with aggregation info # create clear beautiful error with aggregation info
if failed_versions: if exeptions:
msg = "\n".join({f"{binary}: {error}" for binary, error in failed_versions.items()}) msg = "\n".join(exeptions)
raise AssertionError(f"Found binaries with unexpected versions:\n{msg}") raise AssertionError(f"Found binaries with unexpected versions:\n{msg}")