regex for versions ready
This commit is contained in:
parent
6449264dcf
commit
d40e875091
2 changed files with 9 additions and 18 deletions
|
@ -2,6 +2,5 @@ import os
|
|||
|
||||
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"))
|
||||
HOSTING_CONFIG_FILE = os.getenv("HOSTING_CONFIG_FILE", ".devenv.hosting.yaml")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import os
|
||||
from http import HTTPStatus
|
||||
from re import match
|
||||
from re import match, fullmatch
|
||||
|
||||
import allure
|
||||
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 pytest import FixtureRequest
|
||||
|
||||
from pytest_tests.resources.common import BIN_VERSIONS_FILE
|
||||
|
||||
logger = logging.getLogger("NeoLogger")
|
||||
|
||||
|
||||
@allure.title("Check binaries versions")
|
||||
@pytest.mark.sanity
|
||||
@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):
|
||||
"""
|
||||
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"):
|
||||
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)
|
||||
|
||||
# compare versions from servers and file
|
||||
failed_versions = {}
|
||||
exeptions = []
|
||||
additional_env_properties = {}
|
||||
for binary, version in binaries_to_check.items():
|
||||
actual_version = got_versions.get(binary)
|
||||
if actual_version != version:
|
||||
failed_versions[binary] = f"Expected version {version}, found version {actual_version}"
|
||||
|
||||
for binary, version in got_versions.items():
|
||||
if not fullmatch(r"^\d+\.\d+\.\d+(-.*)?(?<!dirty)", 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
|
||||
# so that we have full information about versions in allure report
|
||||
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:
|
||||
save_env_properties(env_file, additional_env_properties)
|
||||
|
||||
# create clear beautiful error with aggregation info
|
||||
if failed_versions:
|
||||
msg = "\n".join({f"{binary}: {error}" for binary, error in failed_versions.items()})
|
||||
if exeptions:
|
||||
msg = "\n".join(exeptions)
|
||||
raise AssertionError(f"Found binaries with unexpected versions:\n{msg}")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue