2022-08-08 14:49:08 +00:00
|
|
|
import logging
|
2024-06-07 14:13:50 +00:00
|
|
|
from re import fullmatch
|
2022-08-08 14:49:08 +00:00
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2023-01-09 12:46:03 +00:00
|
|
|
from frostfs_testlib.hosting import Hosting
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.utils.version_utils import get_remote_binaries_versions
|
2022-08-08 14:49:08 +00:00
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
logger = logging.getLogger("NeoLogger")
|
2022-08-08 14:49:08 +00:00
|
|
|
|
2024-06-07 14:13:50 +00:00
|
|
|
VERSION_REGEX = r"^([a-zA-Z0-9]*/)?\d+\.\d+\.\d+(-.*)?(?<!dirty)"
|
|
|
|
VERSION_ERROR_MSG = "{name} [{host}]: Actual version doesn't conform to format '0.0.0-000-aaaaaaa': {version}"
|
|
|
|
|
|
|
|
|
|
|
|
def _check_version_format(version):
|
|
|
|
return fullmatch(VERSION_REGEX, version)
|
|
|
|
|
2023-11-02 09:19:23 +00:00
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
@allure.title("Check binaries versions")
|
2022-08-08 14:49:08 +00:00
|
|
|
@pytest.mark.check_binaries
|
2024-06-07 14:13:50 +00:00
|
|
|
def test_binaries_versions(hosting: Hosting):
|
2022-08-08 14:49:08 +00:00
|
|
|
"""
|
|
|
|
Compare binaries versions from external source (url) and deployed on servers.
|
|
|
|
"""
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Get binaries versions from servers"):
|
2024-06-07 14:13:50 +00:00
|
|
|
versions_by_host = get_remote_binaries_versions(hosting)
|
2022-08-08 14:49:08 +00:00
|
|
|
|
2024-01-29 16:00:47 +00:00
|
|
|
exсeptions = []
|
2022-08-08 14:49:08 +00:00
|
|
|
|
2024-06-07 14:13:50 +00:00
|
|
|
last_host, versions_on_last_host = versions_by_host.popitem()
|
|
|
|
for name, version in versions_on_last_host.items():
|
|
|
|
for host, versions_on_host in versions_by_host.items():
|
|
|
|
if versions_on_host[name] != version:
|
|
|
|
exсeptions.append(f"Binary of {name} has inconsistent version {versions_on_host[name]} on host {host}")
|
|
|
|
if not _check_version_format(versions_on_host[name]):
|
|
|
|
exсeptions.append(VERSION_ERROR_MSG.format(name=name, host=host, version=version))
|
2022-08-08 14:49:08 +00:00
|
|
|
|
2024-06-07 14:13:50 +00:00
|
|
|
if not _check_version_format(version):
|
|
|
|
exсeptions.append(VERSION_ERROR_MSG.format(name=name, host=last_host, version=version))
|
2022-08-08 14:49:08 +00:00
|
|
|
|
2024-06-07 14:13:50 +00:00
|
|
|
assert not exсeptions, "\n".join(exсeptions)
|