From fbefa422e85e49abc202073f3dc26aef80b835f7 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Wed, 22 Nov 2023 19:58:49 +0300 Subject: [PATCH] [#153] Register services automatically Signed-off-by: Andrey Berezin --- pytest_tests/testsuites/conftest.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 926c80f3..12549c8d 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -2,15 +2,16 @@ import logging import os import shutil from datetime import datetime, timedelta, timezone +from importlib.metadata import entry_points from typing import Optional import allure import pytest import yaml from dateutil import parser +from frostfs_testlib import plugins from frostfs_testlib.healthcheck.interfaces import Healthcheck from frostfs_testlib.hosting import Hosting -from frostfs_testlib.plugins import load_plugin from frostfs_testlib.reporter import AllureHandler, get_reporter from frostfs_testlib.resources.common import ( ASSETS_DIR, @@ -24,6 +25,7 @@ from frostfs_testlib.shell import LocalShell, Shell from frostfs_testlib.steps.cli.container import list_containers from frostfs_testlib.steps.cli.object import get_netmap_netinfo from frostfs_testlib.steps.s3 import s3_helper +from frostfs_testlib.storage import get_service_registry from frostfs_testlib.storage.cluster import Cluster, ClusterNode from frostfs_testlib.storage.controllers.cluster_state_controller import ClusterStateController from frostfs_testlib.storage.dataclasses.frostfs_services import StorageNode @@ -76,6 +78,13 @@ def pytest_generate_tests(metafunc: pytest.Metafunc): def configure_testlib(): get_reporter().register_handler(AllureHandler()) logging.getLogger("paramiko").setLevel(logging.INFO) + + # Register Services for cluster + registry = get_service_registry() + services = entry_points(group="frostfs.testlib.services") + for svc in services: + registry.register_service(svc.name, svc.load()) + yield @@ -188,7 +197,7 @@ def s3_policy(request: pytest.FixtureRequest): @pytest.fixture(scope="session") @allure.title("[Session] Create healthcheck object") def healthcheck(cluster: Cluster) -> Healthcheck: - healthcheck_cls = load_plugin( + healthcheck_cls = plugins.load_plugin( "frostfs.testlib.healthcheck", cluster.cluster_nodes[0].host.config.healthcheck_plugin_name )