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 <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-07-13 18:30:57 +04:00
parent cbaecc60dc
commit ab85389d59
4 changed files with 35 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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