[#244] Fix test policies
DCO check / Commits Check (pull_request) Has been cancelled Details

Dmitriy Zayakin 2024-06-04 13:32:08 +03:00
parent 9cf083fac9
commit 9ebd359d75
2 changed files with 23 additions and 4 deletions

View File

@ -23,7 +23,7 @@ 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 DEFAULT_PLACEMENT_RULE, DEFAULT_EC_PLACEMENT_RULE
from frostfs_testlib.steps.cli.container import DEFAULT_EC_PLACEMENT_RULE, DEFAULT_PLACEMENT_RULE
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
@ -44,6 +44,7 @@ logger = logging.getLogger("NeoLogger")
SERVICE_ACTIVE_TIME = 20
# Add logs check test even if it's not fit to mark selectors
def pytest_configure(config: pytest.Config):
markers = config.option.markexpr
@ -54,6 +55,8 @@ def pytest_configure(config: pytest.Config):
number_key = pytest.StashKey[str]()
start_time = pytest.StashKey[int]()
test_outcome = pytest.StashKey[str]()
# pytest hook. Do not rename
def pytest_collection_modifyitems(items: list[pytest.Item]):
# Make network tests last based on @pytest.mark.node_mgmt and logs_test to be latest
@ -210,6 +213,7 @@ def object_size(
return complex_object_size
@pytest.fixture(scope="session")
def rep_placement_policy() -> PlacementPolicy:
return PlacementPolicy("rep", DEFAULT_PLACEMENT_RULE)
@ -234,6 +238,14 @@ def placement_policy(
return ec_placement_policy
@pytest.fixture()
def copies_object_with_placement_policies(placement_policy: PlacementPolicy) -> int:
if placement_policy.name == "rep":
return 2
return 4
@pytest.fixture(scope="session")
def cluster(temp_directory: str, hosting: Hosting, client_shell: Shell) -> Cluster:
cluster = Cluster(hosting)

View File

@ -94,11 +94,17 @@ def generate_ranges(
scope="module"
)
def storage_objects(
default_wallet: WalletInfo, client_shell: Shell, cluster: Cluster, object_size: ObjectSize, placement_policy: PlacementPolicy
default_wallet: WalletInfo,
client_shell: Shell,
cluster: Cluster,
object_size: ObjectSize,
placement_policy: PlacementPolicy,
) -> list[StorageObjectInfo]:
wallet = default_wallet
# Separate containers for complex/simple objects to avoid side-effects
cid = create_container(wallet, shell=client_shell, rule=placement_policy.value, endpoint=cluster.default_rpc_endpoint)
cid = create_container(
wallet, shell=client_shell, rule=placement_policy.value, endpoint=cluster.default_rpc_endpoint
)
file_path = generate_file(object_size.value)
file_hash = get_file_hash(file_path)
@ -140,6 +146,7 @@ class TestObjectApi(ClusterTestBase):
self,
storage_objects: list[StorageObjectInfo],
simple_object_size: ObjectSize,
copies_object_with_placement_policies: int,
):
"""
Validate object storage policy
@ -163,7 +170,7 @@ class TestObjectApi(ClusterTestBase):
shell=self.shell,
nodes=self.cluster.storage_nodes,
)
assert copies == 2, "Expected 2 copies"
assert copies == copies_object_with_placement_policies, "Expected 2 copies"
@allure.title("Get object by native API (obj_size={object_size}, policy={placement_policy})")
def test_get_object_api(self, storage_objects: list[StorageObjectInfo]):