From ccdd6ab7842aab18113d7e4a92b675955ec5334a Mon Sep 17 00:00:00 2001 From: Dmitriy Zayakin Date: Mon, 2 Sep 2024 13:25:13 +0300 Subject: [PATCH] [#296] Add resolve bucket fixture into old resolve func. Signed-off-by: Dmitriy Zayakin --- pytest_tests/testsuites/conftest.py | 9 +++++++++ .../testsuites/failovers/test_failover_storage.py | 3 +++ .../testsuites/replication/test_ec_replication.py | 8 -------- .../services/s3_gate/test_s3_multipart.py | 15 +++++++++++---- .../testsuites/services/s3_gate/test_s3_policy.py | 12 ++++++++---- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 357368c..3dc3eaf 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -16,6 +16,7 @@ from frostfs_testlib.hosting import Hosting from frostfs_testlib.resources import optionals from frostfs_testlib.resources.common import ASSETS_DIR, COMPLEX_OBJECT_CHUNKS_COUNT, COMPLEX_OBJECT_TAIL_SIZE, SIMPLE_OBJECT_SIZE from frostfs_testlib.s3 import AwsCliClient, Boto3ClientWrapper, S3ClientWrapper, VersioningStatus +from frostfs_testlib.s3.interfaces import BucketContainerResolver from frostfs_testlib.shell import LocalShell, Shell from frostfs_testlib.steps.cli.container import DEFAULT_EC_PLACEMENT_RULE, DEFAULT_PLACEMENT_RULE, FROSTFS_CLI_EXEC from frostfs_testlib.steps.cli.object import get_netmap_netinfo @@ -470,3 +471,11 @@ def node_under_test(cluster: Cluster) -> ClusterNode: selected_node = random.choice(cluster.cluster_nodes) reporter.attach(f"{selected_node}", "Selected node") return selected_node + + +@allure.title("Init bucket container resolver") +@pytest.fixture() +def bucket_container_resolver(node_under_test: ClusterNode) -> BucketContainerResolver: + resolver_cls = plugins.load_plugin("frostfs.testlib.bucket_cid_resolver", node_under_test.host.config.product) + resolver: BucketContainerResolver = resolver_cls() + return resolver diff --git a/pytest_tests/testsuites/failovers/test_failover_storage.py b/pytest_tests/testsuites/failovers/test_failover_storage.py index 8358b11..5f9eba5 100644 --- a/pytest_tests/testsuites/failovers/test_failover_storage.py +++ b/pytest_tests/testsuites/failovers/test_failover_storage.py @@ -9,6 +9,7 @@ from frostfs_testlib import reporter from frostfs_testlib.resources.common import MORPH_BLOCK_TIME from frostfs_testlib.resources.wellknown_acl import PUBLIC_ACL from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus +from frostfs_testlib.s3.interfaces import BucketContainerResolver from frostfs_testlib.steps.cli.container import StorageContainer, StorageContainerInfo, create_container from frostfs_testlib.steps.cli.object import get_object, put_object_to_random_node from frostfs_testlib.steps.node_management import ( @@ -117,6 +118,7 @@ class TestFailoverStorage(ClusterTestBase): default_wallet: WalletInfo, simple_object_size: ObjectSize, cluster_state_controller: ClusterStateController, + bucket_container_resolver: BucketContainerResolver, ): default_node = self.cluster.cluster_nodes[0] @@ -149,6 +151,7 @@ class TestFailoverStorage(ClusterTestBase): wallet=default_wallet, shell=self.shell, endpoint=self.cluster.storage_nodes[0].get_rpc_endpoint(), + bucket_container_resolver=bucket_container_resolver )[0] with reporter.step("Turn off all storage nodes except bucket node"): diff --git a/pytest_tests/testsuites/replication/test_ec_replication.py b/pytest_tests/testsuites/replication/test_ec_replication.py index f13534d..6328a69 100644 --- a/pytest_tests/testsuites/replication/test_ec_replication.py +++ b/pytest_tests/testsuites/replication/test_ec_replication.py @@ -56,14 +56,6 @@ class Chunk: return self.object_id -@allure.title("Init bucket container resolver") -@pytest.fixture() -def bucket_container_resolver(node_under_test: ClusterNode) -> BucketContainerResolver: - resolver_cls = plugins.load_plugin("frostfs.testlib.bucket_cid_resolver", node_under_test.host.config.product) - resolver: BucketContainerResolver = resolver_cls() - return resolver - - @allure.title("Initialized remote FrostfsAdm") @pytest.fixture def frostfs_remote_adm(cluster: Cluster) -> FrostfsAdm: diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py b/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py index d8fad51..8a8d351 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py @@ -2,7 +2,8 @@ import allure import pytest from frostfs_testlib import reporter from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus -from frostfs_testlib.steps.cli.container import list_objects, search_container_by_name +from frostfs_testlib.s3.interfaces import BucketContainerResolver +from frostfs_testlib.steps.cli.container import list_objects from frostfs_testlib.steps.s3 import s3_helper from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.storage.dataclasses.wallet import WalletInfo @@ -21,7 +22,12 @@ class TestS3GateMultipart(ClusterTestBase): @allure.title("Object Multipart API (s3_client={s3_client}, bucket versioning = {versioning_status})") @pytest.mark.parametrize("versioning_status", [VersioningStatus.ENABLED, VersioningStatus.UNDEFINED], indirect=True) def test_s3_object_multipart( - self, s3_client: S3ClientWrapper, bucket: str, default_wallet: WalletInfo, versioning_status: str + self, + s3_client: S3ClientWrapper, + bucket: str, + default_wallet: WalletInfo, + versioning_status: str, + bucket_container_resolver: BucketContainerResolver, ): parts_count = 5 file_name_large = generate_file(PART_SIZE * parts_count) # 5Mb - min part @@ -31,7 +37,7 @@ class TestS3GateMultipart(ClusterTestBase): with reporter.step(f"Get related container_id for bucket"): for cluster_node in self.cluster.cluster_nodes: - container_id = search_container_by_name(bucket, cluster_node) + container_id = bucket_container_resolver.resolve(cluster_node, bucket) if container_id: break @@ -86,6 +92,7 @@ class TestS3GateMultipart(ClusterTestBase): bucket: str, simple_object_size: ObjectSize, complex_object_size: ObjectSize, + bucket_container_resolver: BucketContainerResolver, ): complex_file = generate_file(complex_object_size.value) simple_file = generate_file(simple_object_size.value) @@ -95,7 +102,7 @@ class TestS3GateMultipart(ClusterTestBase): with reporter.step("Get related container_id for bucket"): for cluster_node in self.cluster.cluster_nodes: - container_id = search_container_by_name(bucket, cluster_node) + container_id = bucket_container_resolver.resolve(cluster_node, bucket) if container_id: break diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py b/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py index 39ab40c..bedce60 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py @@ -6,7 +6,7 @@ import pytest from botocore.exceptions import ClientError from frostfs_testlib import reporter from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus -from frostfs_testlib.steps.cli.container import search_container_by_name +from frostfs_testlib.s3.interfaces import BucketContainerResolver from frostfs_testlib.steps.s3 import s3_helper from frostfs_testlib.steps.storage_policy import get_simple_object_copies from frostfs_testlib.storage.dataclasses.object_size import ObjectSize @@ -21,7 +21,11 @@ from frostfs_testlib.utils.file_utils import generate_file class TestS3GatePolicy(ClusterTestBase): @allure.title("Bucket creation with retention policy applied (s3_client={s3_client})") def test_s3_bucket_location( - self, default_wallet: WalletInfo, s3_client: S3ClientWrapper, simple_object_size: ObjectSize + self, + default_wallet: WalletInfo, + s3_client: S3ClientWrapper, + simple_object_size: ObjectSize, + bucket_container_resolver: BucketContainerResolver, ): file_path_1 = generate_file(simple_object_size.value) file_name_1 = s3_helper.object_key_from_file_path(file_path_1) @@ -57,7 +61,7 @@ class TestS3GatePolicy(ClusterTestBase): with reporter.step("Check object policy"): for cluster_node in self.cluster.cluster_nodes: - cid_1 = search_container_by_name(name=bucket_1, node=cluster_node) + cid_1 = bucket_container_resolver.resolve(cluster_node, bucket_1) if cid_1: break copies_1 = get_simple_object_copies( @@ -69,7 +73,7 @@ class TestS3GatePolicy(ClusterTestBase): ) assert copies_1 == 1 for cluster_node in self.cluster.cluster_nodes: - cid_2 = search_container_by_name(name=bucket_2, node=cluster_node) + cid_2 = bucket_container_resolver.resolve(cluster_node, bucket_2) if cid_2: break copies_2 = get_simple_object_copies(