diff --git a/pytest_tests/testsuites/object/test_object_lock.py b/pytest_tests/testsuites/object/test_object_lock.py index ea78d9da..c2a9d97d 100755 --- a/pytest_tests/testsuites/object/test_object_lock.py +++ b/pytest_tests/testsuites/object/test_object_lock.py @@ -1,6 +1,5 @@ import logging import re -from datetime import datetime import allure import pytest @@ -30,7 +29,7 @@ from frostfs_testlib.storage.dataclasses.storage_object_info import LockObjectIn 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, wait_for_success -from frostfs_testlib.utils import datetime_utils +from frostfs_testlib.utils import datetime_utils, string_utils from pytest_tests.helpers.utility import wait_for_gc_pass_on_storage_nodes @@ -43,7 +42,7 @@ FIXTURE_OBJECT_LIFETIME = 10 @pytest.fixture(scope="module") def user_wallet(credentials_provider: CredentialsProvider, cluster: Cluster) -> WalletInfo: with reporter.step("Create user wallet with container"): - user = User(f"user_{hex(int(datetime.now().timestamp() * 1000000))}") + user = User(string_utils.unique_name("user_")) return credentials_provider.GRPC.provide(user, cluster.cluster_nodes[0]) @@ -67,9 +66,7 @@ def locked_storage_object( current_epoch = ensure_fresh_epoch(client_shell, cluster) expiration_epoch = current_epoch + FIXTURE_LOCK_LIFETIME - storage_object = user_container.generate_object( - object_size.value, expire_at=current_epoch + FIXTURE_OBJECT_LIFETIME - ) + storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + FIXTURE_OBJECT_LIFETIME) lock_object_id = lock_object( storage_object.wallet, storage_object.cid, @@ -78,9 +75,7 @@ def locked_storage_object( cluster.default_rpc_endpoint, lifetime=FIXTURE_LOCK_LIFETIME, ) - storage_object.locks = [ - LockObjectInfo(storage_object.cid, lock_object_id, FIXTURE_LOCK_LIFETIME, expiration_epoch) - ] + storage_object.locks = [LockObjectInfo(storage_object.cid, lock_object_id, FIXTURE_LOCK_LIFETIME, expiration_epoch)] yield storage_object @@ -142,9 +137,7 @@ class TestObjectLockWithGrpc(ClusterTestBase): with reporter.step("Creating locked object"): current_epoch = self.get_epoch() - storage_object = user_container.generate_object( - object_size.value, expire_at=current_epoch + FIXTURE_OBJECT_LIFETIME - ) + storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + FIXTURE_OBJECT_LIFETIME) lock_object( storage_object.wallet, storage_object.cid, @@ -220,9 +213,7 @@ class TestObjectLockWithGrpc(ClusterTestBase): 1, ) - @allure.title( - "Lock must contain valid lifetime or expire_at field: (lifetime={wrong_lifetime}, expire-at={wrong_expire_at})" - ) + @allure.title("Lock must contain valid lifetime or expire_at field: (lifetime={wrong_lifetime}, expire-at={wrong_expire_at})") # We operate with only lock object here so no complex object needed in this test @pytest.mark.parametrize("object_size", ["simple"], indirect=True) @pytest.mark.parametrize( @@ -675,9 +666,7 @@ class TestObjectLockWithGrpc(ClusterTestBase): with reporter.step("Generate two objects"): for epoch_i in range(2): - storage_objects.append( - user_container.generate_object(object_size.value, expire_at=current_epoch + epoch_i + 3) - ) + storage_objects.append(user_container.generate_object(object_size.value, expire_at=current_epoch + epoch_i + 3)) self.tick_epoch() diff --git a/pytest_tests/testsuites/session_token/conftest.py b/pytest_tests/testsuites/session_token/conftest.py index 713442dc..cea75aab 100644 --- a/pytest_tests/testsuites/session_token/conftest.py +++ b/pytest_tests/testsuites/session_token/conftest.py @@ -1,10 +1,9 @@ -from datetime import datetime - import pytest from frostfs_testlib import reporter from frostfs_testlib.credentials.interfaces import CredentialsProvider, User from frostfs_testlib.storage.cluster import Cluster from frostfs_testlib.storage.dataclasses.wallet import WalletInfo +from frostfs_testlib.utils import string_utils @pytest.fixture(scope="module") @@ -15,12 +14,12 @@ def owner_wallet(default_wallet: WalletInfo) -> WalletInfo: @pytest.fixture(scope="module") def user_wallet(credentials_provider: CredentialsProvider, cluster: Cluster) -> WalletInfo: with reporter.step("Create user wallet which will use objects from owner via static session"): - user = User(f"user_{hex(int(datetime.now().timestamp() * 1000000))}") + user = User(string_utils.unique_name("user_")) return credentials_provider.GRPC.provide(user, cluster.cluster_nodes[0]) @pytest.fixture(scope="module") def stranger_wallet(credentials_provider: CredentialsProvider, cluster: Cluster) -> WalletInfo: with reporter.step("Create stranger user wallet which should fail to obtain data"): - user = User(f"user_{hex(int(datetime.now().timestamp() * 1000000))}") + user = User(string_utils.unique_name("user_")) return credentials_provider.GRPC.provide(user, cluster.cluster_nodes[0])