From f10d899173ff8a9f6f4b713059beab2be7ab423e Mon Sep 17 00:00:00 2001 From: "a.berezin" Date: Mon, 23 Dec 2024 17:17:54 +0300 Subject: [PATCH] [#349] Update session_token tests Signed-off-by: a.berezin --- pytest_tests/testsuites/conftest.py | 2 +- .../testsuites/session_token/conftest.py | 4 ++-- .../test_object_session_token.py | 24 ++++++++++--------- .../test_static_object_session_token.py | 18 ++++++++++---- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 6ecf70f..942d0ce 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -493,7 +493,7 @@ def wallet(user: User, credentials_provider: CredentialsProvider, cluster: Clust # TODO: Migrate tests to fixture wallet above @reporter.step("Get wallet for default user") @pytest.fixture(scope="session") -def default_wallet(wallet) -> WalletInfo: +def default_wallet(wallet: WalletInfo) -> WalletInfo: return wallet diff --git a/pytest_tests/testsuites/session_token/conftest.py b/pytest_tests/testsuites/session_token/conftest.py index eabd68b..de3f7af 100644 --- a/pytest_tests/testsuites/session_token/conftest.py +++ b/pytest_tests/testsuites/session_token/conftest.py @@ -7,8 +7,8 @@ from frostfs_testlib.utils import string_utils @pytest.fixture(scope="module") -def owner_wallet(default_wallet: WalletInfo) -> WalletInfo: - return default_wallet +def owner_wallet(wallet: WalletInfo) -> WalletInfo: + return wallet @pytest.fixture(scope="module") diff --git a/pytest_tests/testsuites/session_token/test_object_session_token.py b/pytest_tests/testsuites/session_token/test_object_session_token.py index 805013f..4ff81c2 100644 --- a/pytest_tests/testsuites/session_token/test_object_session_token.py +++ b/pytest_tests/testsuites/session_token/test_object_session_token.py @@ -3,14 +3,16 @@ import random import allure import pytest from frostfs_testlib import reporter +from frostfs_testlib.cli.frostfs_cli.cli import FrostfsCli 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 from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.storage.dataclasses.wallet import WalletInfo from frostfs_testlib.testing.cluster_test_base import ClusterTestBase from frostfs_testlib.utils.file_utils import generate_file +from workspace.frostfs_testcases.pytest_tests.helpers.container_creation import create_container_with_ape +from workspace.frostfs_testcases.pytest_tests.helpers.container_request import APE_OWNER_ALLOW_ALL, ContainerRequest @pytest.mark.nightly @@ -18,7 +20,8 @@ from frostfs_testlib.utils.file_utils import generate_file @pytest.mark.session_token class TestDynamicObjectSession(ClusterTestBase): @allure.title("Object Operations with Session Token (obj_size={object_size})") - def test_object_session_token(self, default_wallet: WalletInfo, object_size: ObjectSize): + @pytest.mark.parametrize("user_tag", ["TestDynamicObjectSession"], indirect=True) # provide dedicated user with no APE side-policies + def test_object_session_token(self, wallet: WalletInfo, frostfs_cli: FrostfsCli, object_size: ObjectSize): """ Test how operations over objects are executed with a session token @@ -32,17 +35,14 @@ class TestDynamicObjectSession(ClusterTestBase): with a session token """ - with reporter.step("Init wallet"): - wallet = default_wallet - with reporter.step("Nodes Settlements"): session_token_node, container_node, non_container_node = random.sample(self.cluster.storage_nodes, 3) with reporter.step("Create Session Token"): session_token = create_session_token( shell=self.shell, - owner=default_wallet.get_address(), - wallet=default_wallet, + owner=wallet.get_address(), + wallet=wallet, rpc_endpoint=session_token_node.get_rpc_endpoint(), ) @@ -54,11 +54,13 @@ class TestDynamicObjectSession(ClusterTestBase): f'AS LOC_{locode}_PLACE FILTER "UN-LOCODE" ' f'EQ "{un_locode}" AS LOC_{locode}' ) - cid = create_container( + cid = create_container_with_ape( + ContainerRequest(placement_policy, APE_OWNER_ALLOW_ALL), + frostfs_cli, wallet, - shell=self.shell, - endpoint=self.cluster.default_rpc_endpoint, - rule=placement_policy, + self.shell, + self.cluster, + self.cluster.default_rpc_endpoint, ) with reporter.step("Put Objects"): diff --git a/pytest_tests/testsuites/session_token/test_static_object_session_token.py b/pytest_tests/testsuites/session_token/test_static_object_session_token.py index e51f0c8..18ab606 100644 --- a/pytest_tests/testsuites/session_token/test_static_object_session_token.py +++ b/pytest_tests/testsuites/session_token/test_static_object_session_token.py @@ -3,9 +3,9 @@ import logging import allure import pytest from frostfs_testlib import reporter +from frostfs_testlib.cli.frostfs_cli.cli import FrostfsCli from frostfs_testlib.resources.error_patterns import EXPIRED_SESSION_TOKEN, MALFORMED_REQUEST, OBJECT_ACCESS_DENIED, OBJECT_NOT_FOUND from frostfs_testlib.shell import Shell -from frostfs_testlib.steps.cli.container import create_container from frostfs_testlib.steps.cli.object import ( delete_object, get_object, @@ -37,6 +37,8 @@ from frostfs_testlib.storage.dataclasses.wallet import WalletInfo from frostfs_testlib.testing.cluster_test_base import ClusterTestBase from frostfs_testlib.testing.test_control import expect_not_raises from frostfs_testlib.utils.file_utils import generate_file +from workspace.frostfs_testcases.pytest_tests.helpers.container_creation import create_containers_with_ape +from workspace.frostfs_testcases.pytest_tests.helpers.container_request import OWNER_ALLOW_ALL, MultipleContainersRequest logger = logging.getLogger("NeoLogger") @@ -44,10 +46,15 @@ RANGE_OFFSET_FOR_COMPLEX_OBJECT = 200 @pytest.fixture(scope="module") -def storage_containers(owner_wallet: WalletInfo, client_shell: Shell, cluster: Cluster) -> list[str]: - cid = create_container(owner_wallet, shell=client_shell, endpoint=cluster.default_rpc_endpoint) - other_cid = create_container(owner_wallet, shell=client_shell, endpoint=cluster.default_rpc_endpoint) - yield [cid, other_cid] +def storage_containers(owner_wallet: WalletInfo, frostfs_cli: FrostfsCli, client_shell: Shell, cluster: Cluster) -> list[str]: + return create_containers_with_ape( + frostfs_cli, + owner_wallet, + client_shell, + cluster, + cluster.default_rpc_endpoint, + MultipleContainersRequest([OWNER_ALLOW_ALL, OWNER_ALLOW_ALL]), + ) @pytest.fixture( @@ -135,6 +142,7 @@ def static_sessions( @pytest.mark.nightly @pytest.mark.static_session +@pytest.mark.parametrize("user_tag", ["TestObjectStaticSession"], indirect=True) # provide dedicated user with no APE side-policies class TestObjectStaticSession(ClusterTestBase): @allure.title("Read operations with static session (method={method_under_test.__name__}, obj_size={object_size})") @pytest.mark.parametrize(