2022-09-05 09:35:46 +00:00
|
|
|
import random
|
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
import allure
|
2022-09-05 09:35:46 +00:00
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.resources.error_patterns import SESSION_NOT_FOUND
|
|
|
|
from frostfs_testlib.steps.cli.container import create_container
|
|
|
|
from frostfs_testlib.steps.cli.object import delete_object, put_object, put_object_to_random_node
|
|
|
|
from frostfs_testlib.steps.session_token import create_session_token
|
2023-08-02 11:54:03 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
2024-03-11 16:34:54 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
2023-02-19 23:58:07 +00:00
|
|
|
from frostfs_testlib.utils import wallet_utils
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.utils.file_utils import generate_file
|
2022-09-05 09:35:46 +00:00
|
|
|
|
|
|
|
|
2022-11-10 05:27:52 +00:00
|
|
|
@pytest.mark.sanity
|
2022-09-05 09:35:46 +00:00
|
|
|
@pytest.mark.session_token
|
2022-12-05 22:31:45 +00:00
|
|
|
class TestDynamicObjectSession(ClusterTestBase):
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Object Operations with Session Token (obj_size={object_size})")
|
2024-03-11 16:34:54 +00:00
|
|
|
def test_object_session_token(self, default_wallet: WalletInfo, object_size: ObjectSize):
|
2022-12-05 22:31:45 +00:00
|
|
|
"""
|
|
|
|
Test how operations over objects are executed with a session token
|
2022-09-05 09:35:46 +00:00
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
Steps:
|
|
|
|
1. Create a private container
|
|
|
|
2. Obj operation requests to the node which IS NOT in the container but granted
|
|
|
|
with a session token
|
|
|
|
3. Obj operation requests to the node which IS in the container and NOT granted
|
|
|
|
with a session token
|
|
|
|
4. Obj operation requests to the node which IS NOT in the container and NOT granted
|
|
|
|
with a session token
|
|
|
|
"""
|
2022-09-05 09:35:46 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Init wallet"):
|
2022-12-05 22:31:45 +00:00
|
|
|
wallet = default_wallet
|
2022-09-05 09:35:46 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Nodes Settlements"):
|
|
|
|
session_token_node, container_node, non_container_node = random.sample(self.cluster.storage_nodes, 3)
|
2022-09-05 09:35:46 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create Session Token"):
|
2022-12-05 22:31:45 +00:00
|
|
|
session_token = create_session_token(
|
|
|
|
shell=self.shell,
|
2024-03-11 16:34:54 +00:00
|
|
|
owner=default_wallet.get_address(),
|
|
|
|
wallet=default_wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
rpc_endpoint=session_token_node.get_rpc_endpoint(),
|
|
|
|
)
|
2022-09-05 09:35:46 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create Private Container"):
|
2022-12-05 22:31:45 +00:00
|
|
|
un_locode = container_node.get_un_locode()
|
|
|
|
locode = "SPB" if un_locode == "RU LED" else un_locode.split()[1]
|
|
|
|
placement_policy = (
|
|
|
|
f"REP 1 IN LOC_{locode}_PLACE CBF 1 SELECT 1 FROM LOC_{locode} "
|
|
|
|
f'AS LOC_{locode}_PLACE FILTER "UN-LOCODE" '
|
|
|
|
f'EQ "{un_locode}" AS LOC_{locode}'
|
|
|
|
)
|
|
|
|
cid = create_container(
|
|
|
|
wallet,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
|
|
|
rule=placement_policy,
|
|
|
|
)
|
2022-09-05 09:35:46 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put Objects"):
|
2023-08-02 11:54:03 +00:00
|
|
|
file_path = generate_file(object_size.value)
|
2022-12-05 22:31:45 +00:00
|
|
|
oid = put_object_to_random_node(
|
2022-09-05 09:35:46 +00:00
|
|
|
wallet=wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
2022-12-05 22:31:45 +00:00
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
2022-09-05 09:35:46 +00:00
|
|
|
)
|
2022-12-05 22:31:45 +00:00
|
|
|
oid_delete = put_object_to_random_node(
|
2022-09-05 09:35:46 +00:00
|
|
|
wallet=wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
path=file_path,
|
2022-09-05 09:35:46 +00:00
|
|
|
cid=cid,
|
2022-12-05 22:31:45 +00:00
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
2022-09-05 09:35:46 +00:00
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Node not in container but granted a session token"):
|
2022-09-05 09:35:46 +00:00
|
|
|
put_object(
|
|
|
|
wallet=wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
2022-12-05 22:31:45 +00:00
|
|
|
shell=self.shell,
|
|
|
|
endpoint=session_token_node.get_rpc_endpoint(),
|
2022-09-05 09:35:46 +00:00
|
|
|
session=session_token,
|
|
|
|
)
|
|
|
|
delete_object(
|
|
|
|
wallet=wallet,
|
|
|
|
cid=cid,
|
2022-12-05 22:31:45 +00:00
|
|
|
oid=oid_delete,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=session_token_node.get_rpc_endpoint(),
|
2022-09-05 09:35:46 +00:00
|
|
|
session=session_token,
|
|
|
|
)
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Node in container and not granted a session token"):
|
2022-12-05 22:31:45 +00:00
|
|
|
with pytest.raises(Exception, match=SESSION_NOT_FOUND):
|
|
|
|
put_object(
|
|
|
|
wallet=wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=container_node.get_rpc_endpoint(),
|
|
|
|
session=session_token,
|
|
|
|
)
|
|
|
|
with pytest.raises(Exception, match=SESSION_NOT_FOUND):
|
|
|
|
delete_object(
|
|
|
|
wallet=wallet,
|
|
|
|
cid=cid,
|
|
|
|
oid=oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=container_node.get_rpc_endpoint(),
|
|
|
|
session=session_token,
|
|
|
|
)
|
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Node not in container and not granted a session token"):
|
2022-12-05 22:31:45 +00:00
|
|
|
with pytest.raises(Exception, match=SESSION_NOT_FOUND):
|
|
|
|
put_object(
|
|
|
|
wallet=wallet,
|
|
|
|
path=file_path,
|
|
|
|
cid=cid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=non_container_node.get_rpc_endpoint(),
|
|
|
|
session=session_token,
|
|
|
|
)
|
|
|
|
with pytest.raises(Exception, match=SESSION_NOT_FOUND):
|
|
|
|
delete_object(
|
|
|
|
wallet=wallet,
|
|
|
|
cid=cid,
|
|
|
|
oid=oid,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=non_container_node.get_rpc_endpoint(),
|
|
|
|
session=session_token,
|
|
|
|
)
|