import pytest from frostfs_testlib import reporter from frostfs_testlib.resources.wellknown_acl import PUBLIC_ACL from frostfs_testlib.shell import Shell from frostfs_testlib.steps.cli.container import create_container from frostfs_testlib.steps.cli.object import put_object_to_random_node from frostfs_testlib.storage.cluster import Cluster from frostfs_testlib.storage.dataclasses import ape from frostfs_testlib.storage.dataclasses.wallet import WalletInfo from frostfs_testlib.testing.parallel import parallel OBJECT_COUNT = 5 @pytest.fixture(scope="session") def ir_wallet(cluster: Cluster) -> WalletInfo: return WalletInfo.from_node(cluster.ir_nodes[0]) @pytest.fixture(scope="session") def storage_wallet(cluster: Cluster) -> WalletInfo: return WalletInfo.from_node(cluster.storage_nodes[0]) @pytest.fixture(scope="session") def role(request: pytest.FixtureRequest): return request.param @pytest.fixture(scope="session") def test_wallet(default_wallet: WalletInfo, other_wallet: WalletInfo, role: ape.Role): role_to_wallet_map = { ape.Role.OWNER: default_wallet, ape.Role.OTHERS: other_wallet, } assert role in role_to_wallet_map, "Missing wallet with role {role}" return role_to_wallet_map[role] @pytest.fixture(scope="function") def container_with_objects(default_wallet: WalletInfo, client_shell: Shell, cluster: Cluster, file_path: str) -> tuple[str, list[str], str]: with reporter.step("Create public container"): cid = create_container( default_wallet, shell=client_shell, endpoint=cluster.default_rpc_endpoint, basic_acl=PUBLIC_ACL, ) with reporter.step("Add test objects to container"): put_results = parallel( [put_object_to_random_node] * OBJECT_COUNT, wallet=default_wallet, path=file_path, cid=cid, shell=client_shell, cluster=cluster, ) objects_oids = [put_result.result() for put_result in put_results] return cid, objects_oids, file_path