From ab85389d59ab98cae6f9577a3fd6dfb0e5892d53 Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Wed, 13 Jul 2022 18:30:57 +0400 Subject: [PATCH] Use neofs-adm to tick epoch This is a more convenient way to tick epoch when we have multiple moprh blockchain nodes. Approach that we use in devenv would require multi-signed transaction which is cumbersome. Signed-off-by: Vladimir Domnich --- .../network/test_node_management.py | 2 -- .../testsuites/object/test_object_api.py | 12 +++++----- robot/resources/lib/python_keywords/epoch.py | 15 +++++++++++-- robot/variables/common.py | 22 +++++++++++++------ 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/pytest_tests/testsuites/network/test_node_management.py b/pytest_tests/testsuites/network/test_node_management.py index 92fc97fc..2feab8a6 100644 --- a/pytest_tests/testsuites/network/test_node_management.py +++ b/pytest_tests/testsuites/network/test_node_management.py @@ -54,7 +54,6 @@ def crate_container_and_pick_node(prepare_wallet_and_deposit): @pytest.fixture -@pytest.mark.skip(reason="docker API works only for devenv") def start_node_if_needed(): yield try: @@ -168,7 +167,6 @@ def test_placement_policy_negative(prepare_wallet_and_deposit, placement_rule, e @pytest.mark.node_mgmt -@pytest.mark.skip(reason="docker API works only for devenv") @allure.title('NeoFS object replication on node failover') def test_replication(prepare_wallet_and_deposit, start_node_if_needed): """ diff --git a/pytest_tests/testsuites/object/test_object_api.py b/pytest_tests/testsuites/object/test_object_api.py index a386e9fb..2a7dd2ee 100644 --- a/pytest_tests/testsuites/object/test_object_api.py +++ b/pytest_tests/testsuites/object/test_object_api.py @@ -60,14 +60,16 @@ def test_object_api(prepare_wallet_and_deposit, request, object_size): with allure.step('Get range/range hash'): range_hash = get_range_hash(**wallet_cid, oid=oids[0], bearer_token='', range_cut=range_cut) - assert get_file_hash(file_path, range_len) == range_hash, 'Expected range hash is correct' + assert get_file_hash(file_path, range_len) == range_hash, \ + f'Expected range hash to match {range_cut} slice of file payload' range_hash = get_range_hash(**wallet_cid, oid=oids[1], bearer_token='', range_cut=range_cut) - assert get_file_hash(file_path, range_len) == range_hash, 'Expected range hash is correct' + assert get_file_hash(file_path, range_len) == range_hash, \ + f'Expected range hash to match {range_cut} slice of file payload' - _, got_content = get_range(**wallet_cid, oid=oids[1], bearer='', range_cut=range_cut) - assert get_file_content(file_path, content_len=range_len, mode='rb') == got_content, \ - 'Expected range content is correct' + _, range_content = get_range(**wallet_cid, oid=oids[1], bearer='', range_cut=range_cut) + assert get_file_content(file_path, content_len=range_len, mode='rb') == range_content, \ + f'Expected range content to match {range_cut} slice of file payload' with allure.step('Search objects'): search_object(**wallet_cid, expected_objects_list=oids) diff --git a/robot/resources/lib/python_keywords/epoch.py b/robot/resources/lib/python_keywords/epoch.py index 6ee1584e..c8a2e610 100644 --- a/robot/resources/lib/python_keywords/epoch.py +++ b/robot/resources/lib/python_keywords/epoch.py @@ -1,10 +1,12 @@ #!/usr/bin/python3.9 -import contract from robot.api import logger from robot.api.deco import keyword -from common import IR_WALLET_PATH, IR_WALLET_PASS, MORPH_ENDPOINT +import contract +import wrappers +from common import (IR_WALLET_PATH, IR_WALLET_PASS, MORPH_ENDPOINT, NEOFS_ADM_EXEC, + NEOFS_ADM_CONFIG_PATH) ROBOT_AUTO_KEYWORDS = False @@ -22,6 +24,15 @@ def get_epoch(): @keyword('Tick Epoch') def tick_epoch(): + if NEOFS_ADM_EXEC and NEOFS_ADM_CONFIG_PATH: + # If neofs-adm is available, then we tick epoch with it (to be consistent with UAT tests) + cmd = f"{NEOFS_ADM_EXEC} morph force-new-epoch -c {NEOFS_ADM_CONFIG_PATH}" + logger.info(f"Executing shell command: {cmd}") + out = wrappers.run_sh(cmd) + logger.info(f"Command completed with output: {out}") + return + + # Otherwise we tick epoch using transaction cur_epoch = get_epoch() return contract.invoke_contract_multisig( contract.get_netmap_contract_hash(MORPH_ENDPOINT), diff --git a/robot/variables/common.py b/robot/variables/common.py index fcf11ad5..a942932b 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -80,21 +80,29 @@ NEOFS_NETMAP = [i['rpc'] for i in NEOFS_NETMAP_DICT.values()] NEOGO_EXECUTABLE = os.getenv('NEOGO_EXECUTABLE', 'neo-go') NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli') +# Config of user's wallet that we use to run the tests WALLET_CONFIG = f"{CLI_CONFIGS_PATH}/empty_passwd.yml" + MAINNET_WALLET_PATH = os.getenv("MAINNET_WALLET_PATH", f"{DEVENV_PATH}/services/chain/node-wallet.json") -MAINNET_WALLET_CONFIG = f"{CLI_CONFIGS_PATH}/one_wallet_password.yml" -MAINNET_SINGLE_ADDR = 'NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP' +MAINNET_WALLET_CONFIG = os.getenv("MAINNET_WALLET_CONFIG", f"{CLI_CONFIGS_PATH}/one_wallet_password.yml") +MAINNET_SINGLE_ADDR = "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP" MAINNET_WALLET_PASS = os.getenv("MAINNET_WALLET_PASS", "one") + IR_WALLET_PATH = os.getenv("IR_WALLET_PATH", f"{DEVENV_PATH}/services/ir/wallet01.json") IR_WALLET_CONFIG = os.getenv("IR_WALLET_CONFIG", f"{CLI_CONFIGS_PATH}/one_wallet_password.yml") IR_WALLET_PASS = os.getenv("IR_WALLET_PASS", "one") + S3_GATE_WALLET_PATH = os.getenv("S3_GATE_WALLET_PATH", f"{DEVENV_PATH}/services/s3_gate/wallet.json") S3_GATE_WALLET_PASS = os.getenv("S3_GATE_WALLET_PASS", "s3") -STORAGE_NODE_USER = os.getenv('STORAGE_NODE_USER', 'root') -STORAGE_NODE_PWD = os.getenv('STORAGE_NODE_PWD') -STORAGE_NODE_BIN_PATH = os.getenv('STORAGE_NODE_BIN_PATH', '/opt/dev-env/vendor/neofs-cli') -STORAGE_NODE_CONFIG_PATH = os.getenv('STORAGE_NODE_CONFIG_PATH', '/opt/dev-env/services/storage/cli-cfg.yml') -STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT = os.getenv('STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT', 'localhost:8091') +STORAGE_NODE_USER = os.getenv("STORAGE_NODE_USER", "root") +STORAGE_NODE_PWD = os.getenv("STORAGE_NODE_PWD") +STORAGE_NODE_BIN_PATH = os.getenv("STORAGE_NODE_BIN_PATH", f"{DEVENV_PATH}/vendor/neofs-cli") +STORAGE_NODE_CONFIG_PATH = os.getenv("STORAGE_NODE_CONFIG_PATH", f"{DEVENV_PATH}/services/storage/cli-cfg.yml") +STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT = os.getenv("STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT", "localhost:8091") + +# Path and config for neofs-adm utility. Optional if tests are running against devenv +NEOFS_ADM_EXEC = os.getenv("NEOFS_ADM_EXEC") +NEOFS_ADM_CONFIG_PATH = os.getenv("NEOFS_ADM_CONFIG_PATH") FREE_STORAGE = os.getenv('FREE_STORAGE', "false").lower() == "true"