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 <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-10-13 12:12:28 +00:00 committed by Vladimir
parent bfd02531ef
commit 92c034c10b
4 changed files with 9 additions and 11 deletions

View file

@ -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:

View file

@ -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.
"""

View file

@ -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"

View file

@ -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