forked from TrueCloudLab/frostfs-testcases
72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
import json
|
|
|
|
import pytest
|
|
from frostfs_testlib import reporter
|
|
from frostfs_testlib.shell import Shell
|
|
from frostfs_testlib.steps.cli.container import search_nodes_with_container
|
|
from frostfs_testlib.steps.cli.object import put_object_to_random_node
|
|
from frostfs_testlib.storage.cluster import Cluster, ClusterNode
|
|
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
|
|
def objects(container: str, default_wallet: WalletInfo, client_shell: Shell, cluster: Cluster, file_path: str):
|
|
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=container,
|
|
shell=client_shell,
|
|
cluster=cluster,
|
|
)
|
|
objects_oids = [put_result.result() for put_result in put_results]
|
|
|
|
return objects_oids
|
|
|
|
|
|
@pytest.fixture
|
|
def container_nodes(default_wallet: WalletInfo, container: str, client_shell: Shell, cluster: Cluster) -> list[ClusterNode]:
|
|
cid = container
|
|
container_holder_nodes = search_nodes_with_container(default_wallet, cid, client_shell, cluster.default_rpc_endpoint, cluster)
|
|
|
|
report_data = {node.id: node.host_ip for node in container_holder_nodes}
|
|
reporter.attach(json.dumps(report_data, indent=2), "container_nodes.json")
|
|
|
|
return container_holder_nodes
|
|
|
|
|
|
@pytest.fixture
|
|
def container_node_wallet(container_nodes: list[ClusterNode]) -> WalletInfo:
|
|
return WalletInfo.from_node(container_nodes[0].storage_node)
|