From b3b0e206284f92e1658723b88854be34351dceb6 Mon Sep 17 00:00:00 2001 From: Elizaveta Chichindaeva Date: Tue, 28 Dec 2021 10:08:16 +0300 Subject: [PATCH] [#41] Emission Threshold test Signed-off-by: Elizaveta Chichindaeva --- robot/resources/lib/python/acl.py | 4 -- robot/resources/lib/python/neofs.py | 12 ---- .../resources/lib/python/utility_keywords.py | 25 +++++--- .../payment/emission_threshold.robot | 63 +++++++++++++++++++ venv/localtest/requirements.txt | 2 +- 5 files changed, 81 insertions(+), 25 deletions(-) create mode 100644 robot/testsuites/integration/payment/emission_threshold.robot diff --git a/robot/resources/lib/python/acl.py b/robot/resources/lib/python/acl.py index 827fba2..0c3ef86 100644 --- a/robot/resources/lib/python/acl.py +++ b/robot/resources/lib/python/acl.py @@ -41,7 +41,6 @@ def get_eacl(wif: str, cid: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wif} ' f'container get-eacl --cid {cid}' ) - logger.info(f"cmd: {cmd}") try: output = _cmd_run(cmd) if re.search(r'extended ACL table is not set for this container', output): @@ -59,7 +58,6 @@ def set_eacl(wif: str, cid: str, eacl_table_path: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wif} ' f'container set-eacl --cid {cid} --table {eacl_table_path} --await' ) - logger.info(f"cmd: {cmd}") _cmd_run(cmd) @@ -78,7 +76,6 @@ def create_eacl(cid: str, rules_list: list): f"{NEOFS_CLI_EXEC} acl extended create --cid {cid} " f"{rules}--out {table}" ) - logger.info(f"cmd: {cmd}") _cmd_run(cmd) return table @@ -167,5 +164,4 @@ def sign_bearer_token(wif: str, eacl_rules_file: str): f'{NEOFS_CLI_EXEC} util sign bearer-token --from {eacl_rules_file} ' f'--to {eacl_rules_file} --wallet {wif} --json' ) - logger.info(f"cmd: {cmd}") _cmd_run(cmd) diff --git a/robot/resources/lib/python/neofs.py b/robot/resources/lib/python/neofs.py index c13e7cb..5f42783 100644 --- a/robot/resources/lib/python/neofs.py +++ b/robot/resources/lib/python/neofs.py @@ -140,7 +140,6 @@ def create_container(private_key: str, basic_acl:str, rule:str, user_headers: st f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} ' f'container create --policy "{rule}" {basic_acl} {user_headers} {session} --await' ) - logger.info(f"Cmd: {createContainerCmd}") output = _cmd_run(createContainerCmd) cid = _parse_cid(output) logger.info(f"Created container {cid} with rule {rule}") @@ -153,7 +152,6 @@ def container_list(private_key: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} ' f'container list' ) - logger.info(f"Cmd: {Cmd}") output = _cmd_run(Cmd) container_list = re.findall(r'(\w{43,44})', output) @@ -167,7 +165,6 @@ def container_existing(private_key: str, cid: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} ' f'container list' ) - logger.info(f"Cmd: {Cmd}") output = _cmd_run(Cmd) _find_cid(output, cid) @@ -181,7 +178,6 @@ def verify_head_tombstone(private_key: str, cid: str, oid_ts: str, oid: str, add f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} ' f'object head --cid {cid} --oid {oid_ts} --json' ) - logger.info(f"Cmd: {object_cmd}") output = _cmd_run(object_cmd) full_headers = json.loads(output) logger.info(f"Output: {full_headers}") @@ -234,7 +230,6 @@ def get_container_attributes(private_key: str, cid: str, endpoint: str="", json_ f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wallet {private_key} ' f'--cid {cid} container get {"--json" if json_output else ""}' ) - logger.info(f"Cmd: {container_cmd}") output = _cmd_run(container_cmd) return output @@ -267,7 +262,6 @@ def delete_container(cid: str, private_key: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} ' f'container delete --cid {cid}' ) - logger.info(f"Cmd: {deleteContainerCmd}") _cmd_run(deleteContainerCmd) @@ -375,7 +369,6 @@ def put_storagegroup(private_key: str, cid: str, bearer_token: str="", *oid_list f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} storagegroup ' f'put --cid {cid} --members {cmd_oid_line} {bearer_token}' ) - logger.info(f"Cmd: {object_cmd}") output = _cmd_run(object_cmd) oid = _parse_oid(output) @@ -392,8 +385,6 @@ def list_storagegroup(private_key: str, cid: str, bearer_token: str="", *expecte f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} ' f'storagegroup list --cid {cid} {bearer_token}' ) - - logger.info(f"Cmd: {object_cmd}") output = _cmd_run(object_cmd) found_objects = re.findall(r'(\w{43,44})', output) @@ -413,7 +404,6 @@ def get_storagegroup(private_key: str, cid: str, oid: str, bearer_token: str, ex bearer_token = f"--bearer {bearer_token}" object_cmd = f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} storagegroup get --cid {cid} --id {oid} {bearer_token}' - logger.info(f"Cmd: {object_cmd}") output = _cmd_run(object_cmd) if expected_size: @@ -441,7 +431,6 @@ def delete_storagegroup(private_key: str, cid: str, oid: str, bearer_token: str= f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {private_key} storagegroup ' f'delete --cid {cid} --id {oid} {bearer_token}' ) - logger.info(f"Cmd: {object_cmd}") output = _cmd_run(object_cmd) m = re.search(r'Tombstone: ([a-zA-Z0-9-]+)', output) @@ -572,6 +561,5 @@ def _search_object(node:str, private_key: str, cid:str, oid: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {node} --wallet {private_key} --ttl 1 ' f'object search --root --cid {cid} --oid {oid}' ) - output = _cmd_run(Cmd) return output diff --git a/robot/resources/lib/python/utility_keywords.py b/robot/resources/lib/python/utility_keywords.py index 46388e8..2d847f9 100644 --- a/robot/resources/lib/python/utility_keywords.py +++ b/robot/resources/lib/python/utility_keywords.py @@ -7,10 +7,10 @@ import docker from neo3 import wallet from common import SIMPLE_OBJ_SIZE, ASSETS_DIR -from cli_helpers import _cmd_run from robot.api.deco import keyword from robot.api import logger from robot.libraries.BuiltIn import BuiltIn +from cli_helpers import _cmd_run ROBOT_AUTO_KEYWORDS = False @@ -54,30 +54,39 @@ def wif_to_binary(wif: str) -> str: return path @keyword('Make Up') -def make_up(services: list=[]): +def make_up(services: list=[], config_dict: dict={}): test_path = os.getcwd() dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env') os.chdir(dev_path) if len(services) > 0: for service in services: + if config_dict != {}: + with open(f"{dev_path}/.int_test.env", "a") as out: + for key, value in config_dict.items(): + out.write(f'{key}={value}') cmd = f'make up/{service}' - logger.info(f"Cmd: {cmd}") _cmd_run(cmd) else: cmd = f'make up/basic; make update.max_object_size val={SIMPLE_OBJ_SIZE}' - logger.info(f"Cmd: {cmd}") _cmd_run(cmd, timeout=120) os.chdir(test_path) @keyword('Make Down') -def make_down(): +def make_down(services: list=[]): test_path = os.getcwd() dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env') os.chdir(dev_path) - cmd = 'make down; make clean' - logger.info(f"Cmd: {cmd}") - _cmd_run(cmd, timeout=60) + if len(services) > 0: + for service in services: + cmd = f'make down/{service}' + _cmd_run(cmd) + with open(f"{dev_path}/.int_test.env", "w"): + pass + else: + cmd = 'make down; make clean' + _cmd_run(cmd, timeout=60) + os.chdir(test_path) diff --git a/robot/testsuites/integration/payment/emission_threshold.robot b/robot/testsuites/integration/payment/emission_threshold.robot new file mode 100644 index 0000000..411ab5e --- /dev/null +++ b/robot/testsuites/integration/payment/emission_threshold.robot @@ -0,0 +1,63 @@ +*** Settings *** +Variables common.py + +Library payment_neogo.py +Library wallet_keywords.py +Library rpc_call_keywords.py +Library Process + +Resource setup_teardown.robot + +*** Variables *** + +${DEPOSIT_AMOUNT} = ${25} +${DEPOSIT} = ${60} +@{INCLUDE_SVC} = ir +&{CONFIG_CHANGE} = NEOFS_IR_EMIT_GAS_BALANCE_THRESHOLD=${10**16} + +*** Test cases *** +IR GAS emission threshold value + [Documentation] Testcase to check sidechain balance when emission threshold is exceeded. + [Tags] GAS Sidechain + [Timeout] 5 min + + [Setup] Setup + + ${WALLET} ${ADDR} ${WIF} = Init Wallet with Address ${ASSETS_DIR} + + ${SC_BALANCE} = Get Sidechain Balance ${ADDR} + + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${DEPOSIT} + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} + ... Transaction accepted in block ${TX} + +########################################################################################## +# Threshold is set to default 0 and sidechain balance has changed after deposit operation +########################################################################################## + + ${TX_DEPOSIT} = NeoFS Deposit ${WIF} ${DEPOSIT_AMOUNT} + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} + ... Transaction accepted in block ${TX_DEPOSIT} + + Sleep ${MAINNET_BLOCK_TIME} + + ${BALANCE_CHANGED} = Get Sidechain Balance ${ADDR} + Should Not Be Equal ${SC_BALANCE} ${BALANCE_CHANGED} + + Make Down ${INCLUDE_SVC} + Make Up ${INCLUDE_SVC} ${CONFIG_CHANGE} + +###################################################################################### +# Threshold is exceeded and sidechain balance has not changed after deposit operation +###################################################################################### + + ${TX_DEPOSIT} = NeoFS Deposit ${WIF} ${DEPOSIT_AMOUNT} + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} + ... Transaction accepted in block ${TX_DEPOSIT} + + Sleep ${MAINNET_BLOCK_TIME} + + ${BALANCE_UNCHANGED} = Get Sidechain Balance ${ADDR} + Should Be Equal ${BALANCE_UNCHANGED} ${BALANCE_CHANGED} + + [Teardown] Teardown emission_threshold diff --git a/venv/localtest/requirements.txt b/venv/localtest/requirements.txt index aa6865a..d8a8901 100644 --- a/venv/localtest/requirements.txt +++ b/venv/localtest/requirements.txt @@ -5,4 +5,4 @@ boto3==1.16.33 docker==4.4.0 botocore==1.19.33 urllib3==1.26.3 -base58==1.0.3 +base58==2.1.0