From 92c034c10b1a174c46245453ed01fa7f946d0a48 Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Thu, 13 Oct 2022 12:12:28 +0000 Subject: [PATCH] Update environment check for failover tests With testlib we have a new concept of host. Depending on number of hosts we can decide whether to run tests or not. This allows us to run failover tests on devenv if we deploy multiple devenv hosts, also this allows us to add hardware hosting without modifying code of the tests. Signed-off-by: Vladimir Domnich --- pytest_tests/testsuites/conftest.py | 12 ++++++------ .../testsuites/failovers/test_failover_network.py | 2 +- .../testsuites/failovers/test_failover_storage.py | 3 ++- robot/variables/common.py | 3 --- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index c0081dd2..477b4864 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -12,7 +12,6 @@ from common import ( ASSETS_DIR, FREE_STORAGE, HOSTING_CONFIG_FILE, - INFRASTRUCTURE_TYPE, MAINNET_WALLET_PATH, NEOFS_NETMAP_DICT, ) @@ -31,9 +30,10 @@ def client_shell() -> Shell: @pytest.fixture(scope="session") -def cloud_infrastructure_check(): - if INFRASTRUCTURE_TYPE != "CLOUD_VM": - pytest.skip("Test only works on SberCloud infrastructure") +def require_multiple_hosts(hosting: Hosting): + """Fixture that is applied to tests that require that environment has multiple hosts.""" + if len(hosting.hosts) <= 1: + pytest.skip("Test only works with multiple hosts") yield @@ -103,8 +103,8 @@ def run_health_check(collect_logs, hosting: Hosting): @pytest.fixture(scope="session") @allure.title("Prepare wallet and deposit") def prepare_wallet_and_deposit(prepare_tmp_dir): - wallet_path, addr, _ = wallet.init_wallet(ASSETS_DIR) - logger.info(f"Init wallet: {wallet_path},\naddr: {addr}") + wallet_path, address, _ = wallet.init_wallet(ASSETS_DIR) + logger.info(f"Init wallet: {wallet_path}, address: {address}") allure.attach.file(wallet_path, os.path.basename(wallet_path), allure.attachment_type.JSON) if not FREE_STORAGE: diff --git a/pytest_tests/testsuites/failovers/test_failover_network.py b/pytest_tests/testsuites/failovers/test_failover_network.py index 0b8f2053..9a33542f 100644 --- a/pytest_tests/testsuites/failovers/test_failover_network.py +++ b/pytest_tests/testsuites/failovers/test_failover_network.py @@ -49,7 +49,7 @@ def restore_network(hosting: Hosting): @allure.title("Block Storage node traffic") @pytest.mark.failover @pytest.mark.failover_net -def test_block_storage_node_traffic(prepare_wallet_and_deposit, client_shell, cloud_infrastructure_check): +def test_block_storage_node_traffic(prepare_wallet_and_deposit, client_shell, require_multiple_hosts): """ 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 d8cefab6..a478bf0b 100644 --- a/pytest_tests/testsuites/failovers/test_failover_storage.py +++ b/pytest_tests/testsuites/failovers/test_failover_storage.py @@ -58,6 +58,7 @@ def test_lost_storage_node( client_shell, hosting: Hosting, hard_reboot: bool, + require_multiple_hosts, ): wallet = prepare_wallet_and_deposit placement_rule = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X" @@ -92,7 +93,7 @@ def test_lost_storage_node( @pytest.mark.failover_panic @pytest.mark.failover def test_panic_storage_node( - prepare_wallet_and_deposit, client_shell, cloud_infrastructure_check, sequence: bool + prepare_wallet_and_deposit, client_shell, require_multiple_hosts, sequence: bool ): wallet = prepare_wallet_and_deposit placement_rule = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X" diff --git a/robot/variables/common.py b/robot/variables/common.py index 329a1238..79423a0a 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -121,9 +121,6 @@ NEOFS_ADM_CONFIG_PATH = os.getenv("NEOFS_ADM_CONFIG_PATH") FREE_STORAGE = os.getenv("FREE_STORAGE", "false").lower() == "true" BIN_VERSIONS_FILE = os.getenv("BIN_VERSIONS_FILE") -# TODO: instead of specifying infrastructure type we should use attributes of hosts -INFRASTRUCTURE_TYPE = os.getenv("INFRASTRUCTURE_TYPE", "LOCAL_DEVENV") - HOSTING_CONFIG_FILE = os.getenv("HOSTING_CONFIG_FILE", ".devenv.hosting.yaml") # Generate wallet configs