[#202] Use creds provider for s3 client
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
9068b96d69
commit
6af5ad9de5
1 changed files with 10 additions and 28 deletions
|
@ -11,6 +11,7 @@ import pytest
|
||||||
import yaml
|
import yaml
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
from frostfs_testlib import plugins, reporter
|
from frostfs_testlib import plugins, reporter
|
||||||
|
from frostfs_testlib.credentials.interfaces import CredentialsProvider
|
||||||
from frostfs_testlib.healthcheck.interfaces import Healthcheck
|
from frostfs_testlib.healthcheck.interfaces import Healthcheck
|
||||||
from frostfs_testlib.hosting import Hosting
|
from frostfs_testlib.hosting import Hosting
|
||||||
from frostfs_testlib.reporter import AllureHandler, StepsLogger
|
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.s3 import AwsCliClient, Boto3ClientWrapper, S3ClientWrapper, VersioningStatus
|
||||||
from frostfs_testlib.shell import LocalShell, Shell
|
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.cli.object import get_netmap_netinfo
|
||||||
from frostfs_testlib.steps.s3 import s3_helper
|
from frostfs_testlib.steps.s3 import s3_helper
|
||||||
from frostfs_testlib.storage import get_service_registry
|
from frostfs_testlib.storage import get_service_registry
|
||||||
|
@ -266,25 +266,22 @@ def s3_client(
|
||||||
client_shell: Shell,
|
client_shell: Shell,
|
||||||
s3_policy: Optional[str],
|
s3_policy: Optional[str],
|
||||||
cluster: Cluster,
|
cluster: Cluster,
|
||||||
auth_container_placement_policy: str,
|
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
) -> S3ClientWrapper:
|
) -> S3ClientWrapper:
|
||||||
wallet = WalletInfo(path=default_wallet, password=DEFAULT_WALLET_PASS)
|
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(
|
credentials_provider = CredentialsProvider(node.host.config.s3_creds_plugin_name)
|
||||||
wallet,
|
credentials_provider.stash["cluster"] = cluster
|
||||||
client_shell,
|
credentials_provider.stash["wallet"] = wallet
|
||||||
cluster,
|
credentials_provider.stash["shell"] = client_shell
|
||||||
s3gates=[cluster_node.s3_gate for cluster_node in cluster.cluster_nodes],
|
credentials_provider.stash["location_constraints"] = s3_policy
|
||||||
policy=s3_policy,
|
|
||||||
container_placement_policy=auth_container_placement_policy,
|
access_key_id, secret_access_key = credentials_provider.S3.provide(node)
|
||||||
)
|
|
||||||
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}"
|
|
||||||
|
|
||||||
s3_client_cls = request.param
|
s3_client_cls = request.param
|
||||||
client = s3_client_cls(access_key_id, secret_access_key, cluster.default_s3_gate_endpoint)
|
client = s3_client_cls(access_key_id, secret_access_key, cluster.default_s3_gate_endpoint)
|
||||||
yield client
|
return client
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -416,21 +413,6 @@ def default_wallet(wallet_factory: WalletFactory) -> str:
|
||||||
return wallet.path
|
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()
|
@pytest.fixture()
|
||||||
@allure.title("Select random node for testing")
|
@allure.title("Select random node for testing")
|
||||||
def node_under_test(cluster: Cluster) -> ClusterNode:
|
def node_under_test(cluster: Cluster) -> ClusterNode:
|
||||||
|
|
Loading…
Reference in a new issue