New fixture for s3 client init #91

Merged
d.zayakin merged 2 commits from d.zayakin/frostfs-testcases:change-split-brain into master 2023-09-19 08:35:29 +00:00
2 changed files with 35 additions and 4 deletions

View file

@ -166,6 +166,7 @@ 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)
@ -176,6 +177,7 @@ def s3_client(
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
@ -273,3 +275,18 @@ def default_wallet(wallet_factory: WalletFactory) -> str:
wallet = wallet_factory.create_wallet(password=DEFAULT_WALLET_PASS)
allure.attach.file(wallet.path, os.path.basename(wallet.path), allure.attachment_type.JSON)
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):
placeholders = {
"$ALPHABET_NODE_COUNT$": 4 if len(cluster.cluster_nodes) < 8 else 8,
"$NODE_COUNT$": len(cluster.cluster_nodes),
}
placement_policy = None
abereziny marked this conversation as resolved Outdated
placeholders = {
   "$REP_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():
         container_placement_policy = container_placement_policy.replace(key, value)
``` placeholders = { "$REP_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(): container_placement_policy = container_placement_policy.replace(key, value) ```

done

done
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

View file

@ -18,7 +18,7 @@ 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.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.dataclasses.object_size import ObjectSize
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
@ -38,7 +38,17 @@ blocked_nodes: list[ClusterNode] = []
def pytest_generate_tests(metafunc):
if "s3_client" in metafunc.fixturenames:
metafunc.parametrize("s3_client", [AwsCliClient], ids=["aws"], indirect=True)
metafunc.parametrize(
"s3_client, auth_container_placement_policy",
[
(
abereziny marked this conversation as resolved Outdated

What is the actual intention here?
If we don't use the container_placement_policy we can skip mentioning it.

Edit:
I've got it...

Change this

[(AwsCliClient, "")],

to

[(AwsCliClient, "REP $REP_NODE_COUNT$")],
What is the actual intention here? If we don't use the `container_placement_policy` we can skip mentioning it. Edit: I've got it... Change this ``` [(AwsCliClient, "")], ``` to ``` [(AwsCliClient, "REP $REP_NODE_COUNT$")], ```

done

done
AwsCliClient,
"REP $ALPHABET_NODE_COUNT$ SELECT 4 FROM ALPHA FILTER 'role' EQ 'alphabet' AS ALPHA",
)
],
ids=["aws"],
indirect=True,
)
@pytest.mark.failover
@ -177,7 +187,9 @@ class TestFailoverSplitBrain(ClusterTestBase):
splitted.append(nodes_list[i::count] + free_nodes[i::count])
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={auth_container_placement_policy}, s3_client={s3_client})",
)
def test_versioning_bucket_after_split_brain(
self,
cluster_state_controller: ClusterStateController,
@ -311,7 +323,9 @@ class TestFailoverSplitBrain(ClusterTestBase):
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={auth_container_placement_policy}, s3_client={s3_client})"
)
def test_no_version_bucket_after_split_brain(
self,
cluster_state_controller: ClusterStateController,