From 6af5ad9de5840099bf20da4bda4c5ef282b56b85 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Fri, 1 Mar 2024 02:26:56 +0300 Subject: [PATCH] [#202] Use creds provider for s3 client Signed-off-by: Andrey Berezin --- pytest_tests/testsuites/conftest.py | 38 ++++++++--------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index ca7869e..ce85d62 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -11,6 +11,7 @@ import pytest import yaml from dateutil import parser from frostfs_testlib import plugins, reporter +from frostfs_testlib.credentials.interfaces import CredentialsProvider from frostfs_testlib.healthcheck.interfaces import Healthcheck from frostfs_testlib.hosting import Hosting from frostfs_testlib.reporter import AllureHandler, StepsLogger @@ -23,7 +24,6 @@ from frostfs_testlib.resources.common import ( ) from frostfs_testlib.s3 import AwsCliClient, Boto3ClientWrapper, S3ClientWrapper, VersioningStatus 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 @@ -266,25 +266,22 @@ def s3_client( client_shell: Shell, s3_policy: Optional[str], cluster: Cluster, - auth_container_placement_policy: str, request: pytest.FixtureRequest, ) -> S3ClientWrapper: wallet = WalletInfo(path=default_wallet, password=DEFAULT_WALLET_PASS) + node = cluster.cluster_nodes[0] - (cid, access_key_id, secret_access_key) = s3_helper.init_s3_credentials( - wallet, - client_shell, - cluster, - s3gates=[cluster_node.s3_gate for cluster_node in cluster.cluster_nodes], - policy=s3_policy, - container_placement_policy=auth_container_placement_policy, - ) - containers_list = list_containers(wallet.path, shell=client_shell, endpoint=cluster.default_rpc_endpoint) - assert cid in containers_list, f"Expected cid {cid} in {containers_list}" + credentials_provider = CredentialsProvider(node.host.config.s3_creds_plugin_name) + credentials_provider.stash["cluster"] = cluster + credentials_provider.stash["wallet"] = wallet + credentials_provider.stash["shell"] = client_shell + credentials_provider.stash["location_constraints"] = s3_policy + + access_key_id, secret_access_key = credentials_provider.S3.provide(node) s3_client_cls = request.param client = s3_client_cls(access_key_id, secret_access_key, cluster.default_s3_gate_endpoint) - yield client + return client @pytest.fixture @@ -416,21 +413,6 @@ def default_wallet(wallet_factory: WalletFactory) -> str: return wallet.path -@reporter.step("[Class]: Container placement policy for keys") -@pytest.fixture(scope="class") -def auth_container_placement_policy(cluster: Cluster, request: pytest.FixtureRequest): - placeholders = { - "$ALPHABET_NODE_COUNT$": 4 if len(cluster.cluster_nodes) < 8 else 8, - "$NODE_COUNT$": len(cluster.cluster_nodes), - } - placement_policy = None - if "param" in request.__dict__: - placement_policy = request.param - for key, value in placeholders.items(): - placement_policy = placement_policy.replace(key, str(value)) - return placement_policy - - @pytest.fixture() @allure.title("Select random node for testing") def node_under_test(cluster: Cluster) -> ClusterNode: