forked from TrueCloudLab/frostfs-testcases
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
|
import pytest
|
||
|
from frostfs_testlib import reporter
|
||
|
from frostfs_testlib.cli import FrostfsCli
|
||
|
from frostfs_testlib.resources.cli import FROSTFS_CLI_EXEC
|
||
|
from frostfs_testlib.shell.interfaces import Shell
|
||
|
from frostfs_testlib.steps.cli.object import put_object
|
||
|
from frostfs_testlib.storage.cluster import Cluster
|
||
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||
|
from frostfs_testlib.utils.file_utils import generate_file
|
||
|
|
||
|
|
||
|
@pytest.fixture(scope="session")
|
||
|
def frostfs_cli_on_first_node(cluster: Cluster) -> FrostfsCli:
|
||
|
node = cluster.cluster_nodes[0]
|
||
|
shell = node.host.get_shell()
|
||
|
|
||
|
return FrostfsCli(shell, FROSTFS_CLI_EXEC, node.storage_node.get_remote_wallet_config_path())
|
||
|
|
||
|
|
||
|
@pytest.fixture
|
||
|
def object_id(
|
||
|
default_wallet: WalletInfo,
|
||
|
frostfs_cli_on_first_node: FrostfsCli,
|
||
|
simple_object_size: ObjectSize,
|
||
|
cluster: Cluster,
|
||
|
client_shell: Shell,
|
||
|
container: str,
|
||
|
) -> str:
|
||
|
test_file = generate_file(simple_object_size.value)
|
||
|
|
||
|
with reporter.step("Allow PutObject on first node via local override"):
|
||
|
frostfs_cli_on_first_node.control.add_rule(
|
||
|
endpoint=cluster.storage_nodes[0].get_control_endpoint(),
|
||
|
target_type="container",
|
||
|
target_name=container,
|
||
|
chain_id="allowPutObject",
|
||
|
rule=f"allow Object.Put *",
|
||
|
)
|
||
|
|
||
|
with reporter.step("Put objects in container on the first node"):
|
||
|
object_id = put_object(default_wallet, test_file, container, client_shell, cluster.storage_nodes[0].get_rpc_endpoint())
|
||
|
|
||
|
with reporter.step("Remove PutObject local override from first node"):
|
||
|
frostfs_cli_on_first_node.control.remove_rule(
|
||
|
endpoint=cluster.storage_nodes[0].get_control_endpoint(),
|
||
|
target_type="container",
|
||
|
target_name=container,
|
||
|
chain_id="allowPutObject",
|
||
|
)
|
||
|
|
||
|
return object_id
|