Add new fixture

Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
Dmitriy Zayakin 2023-09-18 16:56:53 +03:00 committed by Dmitriy Zayakin
parent 3021805f7e
commit ed15485b72
2 changed files with 36 additions and 4 deletions

View file

@ -28,6 +28,7 @@ from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
from frostfs_testlib.storage.dataclasses.wallet import WalletFactory, WalletInfo from frostfs_testlib.storage.dataclasses.wallet import WalletFactory, WalletInfo
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
from frostfs_testlib.utils import env_utils, version_utils from frostfs_testlib.utils import env_utils, version_utils
from frostfs_testlib.utils.failover_utils import search_for_consensus_nodes
from pytest_tests.resources.common import HOSTING_CONFIG_FILE, TEST_CYCLES_COUNT from pytest_tests.resources.common import HOSTING_CONFIG_FILE, TEST_CYCLES_COUNT
@ -178,6 +179,7 @@ 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)
@ -188,6 +190,7 @@ def s3_client(
cluster, cluster,
s3gates=[cluster_node.s3_gate for cluster_node in cluster.cluster_nodes], s3gates=[cluster_node.s3_gate for cluster_node in cluster.cluster_nodes],
policy=s3_policy, policy=s3_policy,
container_placement_policy=auth_container_placement_policy,
) )
containers_list = list_containers( containers_list = list_containers(
wallet.path, shell=client_shell, endpoint=cluster.default_rpc_endpoint wallet.path, shell=client_shell, endpoint=cluster.default_rpc_endpoint
@ -285,3 +288,17 @@ def default_wallet(wallet_factory: WalletFactory) -> str:
wallet = wallet_factory.create_wallet(password=DEFAULT_WALLET_PASS) wallet = wallet_factory.create_wallet(password=DEFAULT_WALLET_PASS)
allure.attach.file(wallet.path, os.path.basename(wallet.path), allure.attachment_type.JSON) allure.attach.file(wallet.path, os.path.basename(wallet.path), allure.attachment_type.JSON)
return wallet.path return wallet.path
@allure.step("[Class]: Container placement policy for keys")
@pytest.fixture(scope="class")
def auth_container_placement_policy(cluster: Cluster, request: pytest.FixtureRequest):
auth_container_placement_policy = None
placeholders = {
"ALPHABET_NODE_COUNT": 4 if len(cluster.cluster_nodes) < 8 else 8,
"$NODE_COUNT$": len(cluster.cluster_nodes),
}
if "param" in request.__dict__:
for key, value in placeholders.items():
auth_container_placement_policy.replace(key, value)
return auth_container_placement_policy

View file

@ -18,12 +18,13 @@ from frostfs_testlib.steps.cli.container import (
) )
from frostfs_testlib.steps.cli.object import get_object, get_object_nodes, put_object_to_random_node from frostfs_testlib.steps.cli.object import get_object, get_object_nodes, put_object_to_random_node
from frostfs_testlib.steps.s3.s3_helper import set_bucket_versioning from frostfs_testlib.steps.s3.s3_helper import set_bucket_versioning
from frostfs_testlib.storage.cluster import ClusterNode from frostfs_testlib.storage.cluster import Cluster, ClusterNode
from frostfs_testlib.storage.controllers import ClusterStateController from frostfs_testlib.storage.controllers import ClusterStateController
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
from frostfs_testlib.utils import datetime_utils from frostfs_testlib.utils import datetime_utils
from frostfs_testlib.utils.failover_utils import ( from frostfs_testlib.utils.failover_utils import (
search_for_consensus_nodes,
wait_all_storage_nodes_returned, wait_all_storage_nodes_returned,
wait_object_replication, wait_object_replication,
) )
@ -38,7 +39,17 @@ blocked_nodes: list[ClusterNode] = []
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
if "s3_client" in metafunc.fixturenames: if "s3_client" in metafunc.fixturenames:
metafunc.parametrize("s3_client", [AwsCliClient], ids=["aws"], indirect=True) metafunc.parametrize(
"s3_client, auth_container_placement_policy",
[
(
AwsCliClient,
"REP $ALPHABET_NODE_COUNT$ SELECT 4 FROM ALPHA FILTER 'role' EQ 'alphabet' AS ALPHA",
)
],
ids=["aws"],
indirect=True,
)
@pytest.mark.failover @pytest.mark.failover
@ -177,7 +188,9 @@ class TestFailoverSplitBrain(ClusterTestBase):
splitted.append(nodes_list[i::count] + free_nodes[i::count]) splitted.append(nodes_list[i::count] + free_nodes[i::count])
return tuple(s for s in splitted) return tuple(s for s in splitted)
@allure.title("Replication tree after split brain, versioning bucket") @allure.title(
"Replication tree after split brain, versioning bucket (placement_policy={keys_placement_policy}, s3_client={s3_client})",
)
def test_versioning_bucket_after_split_brain( def test_versioning_bucket_after_split_brain(
self, self,
cluster_state_controller: ClusterStateController, cluster_state_controller: ClusterStateController,
@ -311,7 +324,9 @@ class TestFailoverSplitBrain(ClusterTestBase):
f"{object_version[-1]} " f"!= {bucket_versions[-1]['VersionId']}" f"{object_version[-1]} " f"!= {bucket_versions[-1]['VersionId']}"
) )
@allure.title("Replication tree after split brain, no version bucket") @allure.title(
"Replication tree after split brain, no version bucket (placement_policy={keys_placement_policy}, s3_client={s3_client})"
)
def test_no_version_bucket_after_split_brain( def test_no_version_bucket_after_split_brain(
self, self,
cluster_state_controller: ClusterStateController, cluster_state_controller: ClusterStateController,