From eff4b032a593755526fe412305643ebc9ede002a Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Tue, 2 Aug 2022 09:37:28 +0300 Subject: [PATCH] Refactor fixture that checks cloud environment Now it relies on presence of sbercloud configuration rather than on free storage setting. Signed-off-by: Vladimir Domnich --- pytest_tests/testsuites/conftest.py | 6 ++++-- pytest_tests/testsuites/failovers/test_failover_network.py | 2 +- pytest_tests/testsuites/failovers/test_failover_storage.py | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index ca3cb5b..6dfbb89 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -12,6 +12,7 @@ from cli_helpers import _cmd_run from common import ASSETS_DIR, FREE_STORAGE, MAINNET_WALLET_PATH, NEOFS_NETMAP_DICT from payment_neogo import neofs_deposit, transfer_mainnet_gas from python_keywords.node_management import node_healthcheck +from sbercloud_helper import SberCloudConfig def robot_keyword_adapter(name=None, tags=(), types=()): @@ -24,8 +25,9 @@ logger = logging.getLogger('NeoLogger') @pytest.fixture(scope='session') -def free_storage_check(): - if os.getenv('FREE_STORAGE', default='False').lower() not in ('true', '1'): +def cloud_infrastructure_check(): + cloud_config = SberCloudConfig.from_env() + if not cloud_config.project_id: pytest.skip('Test only works on SberCloud infrastructure') yield diff --git a/pytest_tests/testsuites/failovers/test_failover_network.py b/pytest_tests/testsuites/failovers/test_failover_network.py index 6790135..efcbf86 100644 --- a/pytest_tests/testsuites/failovers/test_failover_network.py +++ b/pytest_tests/testsuites/failovers/test_failover_network.py @@ -62,7 +62,7 @@ def restore_network(): @allure.title('Block Storage node traffic') @pytest.mark.failover @pytest.mark.failover_net -def test_block_storage_node_traffic(prepare_wallet_and_deposit, free_storage_check): +def test_block_storage_node_traffic(prepare_wallet_and_deposit, cloud_infrastructure_check): """ Block storage nodes traffic using iptables and wait for replication for objects. """ diff --git a/pytest_tests/testsuites/failovers/test_failover_storage.py b/pytest_tests/testsuites/failovers/test_failover_storage.py index 18e11bd..4089af0 100644 --- a/pytest_tests/testsuites/failovers/test_failover_storage.py +++ b/pytest_tests/testsuites/failovers/test_failover_storage.py @@ -56,7 +56,7 @@ def return_all_storage_nodes(sbercloud_client: SberCloud) -> None: @pytest.mark.parametrize('hard_reboot', [True, False]) @pytest.mark.failover def test_lost_storage_node(prepare_wallet_and_deposit, sbercloud_client: SberCloud, - free_storage_check, hard_reboot: bool): + cloud_infrastructure_check, hard_reboot: bool): wallet = prepare_wallet_and_deposit placement_rule = 'REP 2 IN X CBF 2 SELECT 2 FROM * AS X' source_file_path = generate_file() @@ -88,7 +88,8 @@ def test_lost_storage_node(prepare_wallet_and_deposit, sbercloud_client: SberClo @pytest.mark.parametrize('sequence', [True, False]) @pytest.mark.failover_panic @pytest.mark.failover -def test_panic_storage_node(prepare_wallet_and_deposit, free_storage_check, sequence: bool): +def test_panic_storage_node(prepare_wallet_and_deposit, cloud_infrastructure_check, + sequence: bool): wallet = prepare_wallet_and_deposit placement_rule = 'REP 2 IN X CBF 2 SELECT 2 FROM * AS X' source_file_path = generate_file()