From d841f3f9ef3f535bd3a772ad98b0d31a54986072 Mon Sep 17 00:00:00 2001 From: anastasia prasolova Date: Tue, 4 May 2021 12:27:43 +0300 Subject: [PATCH] "create container" -> "prepare container" misprint fixed Signed-off-by: anastasia prasolova --- robot/resources/lib/neofs.py | 74 +++++++++++-------- .../acl/acl_basic_public_container.robot | 2 +- .../acl/common_steps_acl_basic.robot | 4 - .../acl/common_steps_acl_bearer.robot | 8 +- .../integration/network/replication.robot | 5 +- .../object/common_steps_object.robot | 11 ++- .../object/object_storagegroup_complex.robot | 7 +- .../object/object_storagegroup_simple.robot | 2 +- .../integration/services/http_gate.robot | 5 +- robot/variables/common.py | 2 + 10 files changed, 66 insertions(+), 54 deletions(-) diff --git a/robot/resources/lib/neofs.py b/robot/resources/lib/neofs.py index aaacf07..b7525fd 100644 --- a/robot/resources/lib/neofs.py +++ b/robot/resources/lib/neofs.py @@ -23,7 +23,6 @@ from common import * ROBOT_AUTO_KEYWORDS = False -CLI_PREFIX = "" # path to neofs-cli executable NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli') @@ -318,10 +317,11 @@ def get_range(private_key: str, cid: str, oid: str, range_file: str, bearer: str raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) @keyword('Create container') -def create_container(private_key: str, basic_acl:str="", - rule:str="REP 2 IN X CBF 1 SELECT 2 FROM * AS X"): +def create_container(private_key: str, basic_acl:str, rule:str): + if rule == "": + logger.error("Cannot create container with empty placement rule") if basic_acl != "": - basic_acl = "--basic-acl " + basic_acl + basic_acl = f"--basic-acl {basic_acl}" createContainerCmd = ( f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --key {private_key} ' @@ -334,7 +334,6 @@ def create_container(private_key: str, basic_acl:str="", logger.info("Output: %s" % output) cid = _parse_cid(output) logger.info("Created container %s with rule '%s'" % (cid, rule)) - return cid @@ -407,7 +406,6 @@ def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: s @keyword('Get Split objects') def get_component_objects(private_key: str, cid: str, oid: str): - logger.info("Collect Split objects list from Linked object.") split_id = "" nodes = _get_storage_nodes() @@ -444,7 +442,6 @@ def _collect_split_objects_from_header(private_key, cid, parsed_header): return header_link_parsed['Split ChildID'] - @keyword('Verify Split Chain') def verify_split_chain(private_key: str, cid: str, oid: str): @@ -739,7 +736,6 @@ def parse_object_system_header(header: str): else: raise Exception("no Type was parsed from object header: \t%s" % header) - # Header - Optional attributes m = re.search(r'Split ID:\s+([\w-]+)', header) if m is not None: @@ -757,8 +753,6 @@ def parse_object_system_header(header: str): found_objects = re.findall(r'Split ChildID:\s+(\w+)', header) if found_objects: result_header['Split ChildID'] = found_objects - - logger.info("Result: %s" % result_header) return result_header @@ -801,6 +795,7 @@ def verify_file_hash(filename, expected_hash): else: raise Exception("File hash '{}' is not equal to {}".format(file_hash, expected_hash)) + @keyword('Put object') def put_object(private_key: str, path: str, cid: str, bearer: str, user_headers: str, endpoint: str="", options: str="" ): @@ -1075,30 +1070,49 @@ def _find_cid(output: str, cid: str): raise Exception("no CID %s was parsed from command output: \t%s" % (cid, output)) return cid -def _parse_oid(output: str): +def _parse_oid(input_str: str): """ - This function parses OID from given CLI output. - Parameters: - - output: a string with command run output - """ - m = re.search(r'ID: ([a-zA-Z0-9-]+)', output) - if m.start() != m.end(): # e.g., if match found something - oid = m.group(1) - else: - raise Exception("no OID was parsed from command output: \t%s" % output) - return oid + This function parses OID from given CLI output. The input string we + expect: + Object successfully stored + ID: 4MhrLA7RXTBXCsaNnbahYVAPuoQdiUPuyNEWnywvoSEs + CID: HeZu2DXBuPve6HXbuHZx64knS7KcGtfSj2L59Li72kkg + We want to take 'ID' value from the string. -def _parse_cid(output: str): - """ - This function parses CID from given CLI output. Parameters: - - output: a string with command run output + - input_str: a string with command run output """ - m = re.search(r'container ID: (\w+)', output) - if not m.start() != m.end(): # e.g., if match found something - raise Exception("no CID was parsed from command output: \t%s" % (output)) - cid = m.group(1) - return cid + try: + # taking second string from command output + snd_str = input_str.split('\n')[1] + except: + logger.error(f"Got empty input: {input_str}") + splitted = snd_str.split(": ") + if len(splitted) != 2: + raise Exception(f"no OID was parsed from command output: \t{snd_str}") + return splitted[1] + +def _parse_cid(input_str: str): + """ + This function parses CID from given CLI output. The input string we + expect: + container ID: 2tz86kVTDpJxWHrhw3h6PbKMwkLtBEwoqhHQCKTre1FN + awaiting... + container has been persisted on sidechain + We want to take 'container ID' value from the string. + + Parameters: + - input_str: a string with command run output + """ + try: + # taking first string from command output + fst_str = input_str.split('\n')[0] + except: + logger.error(f"Got empty output: {input_str}") + splitted = fst_str.split(": ") + if len(splitted) != 2: + raise Exception(f"no CID was parsed from command output: \t{fst_str}") + return splitted[1] def _get_storage_nodes(): # TODO: fix to get netmap from neofs-cli diff --git a/robot/testsuites/integration/acl/acl_basic_public_container.robot b/robot/testsuites/integration/acl/acl_basic_public_container.robot index 943dd5e..090464b 100644 --- a/robot/testsuites/integration/acl/acl_basic_public_container.robot +++ b/robot/testsuites/integration/acl/acl_basic_public_container.robot @@ -58,7 +58,7 @@ Check Public Container Get Range Hash ${SYSTEM_KEY_SN} ${PUBLIC_CID} ${S_OID_USER} ${EMPTY} 0:256 # Search - @{S_OBJ_PRIV} = Create List ${S_OID_USER} ${S_OID_OTHER} ${S_OID_SYS_SN} ${S_OID_SYS_IR} + @{S_OBJ_PRIV} = Create List ${S_OID_USER} ${S_OID_OTHER} ${S_OID_SYS_SN} ${S_OID_SYS_IR} Search object ${USER_KEY} ${PUBLIC_CID} --root ${EMPTY} ${EMPTY} ${S_OBJ_PRIV} Search object ${OTHER_KEY} ${PUBLIC_CID} --root ${EMPTY} ${EMPTY} ${S_OBJ_PRIV} Search object ${SYSTEM_KEY_IR} ${PUBLIC_CID} --root ${EMPTY} ${EMPTY} ${S_OBJ_PRIV} diff --git a/robot/testsuites/integration/acl/common_steps_acl_basic.robot b/robot/testsuites/integration/acl/common_steps_acl_basic.robot index aad61bf..cd7d3de 100644 --- a/robot/testsuites/integration/acl/common_steps_acl_basic.robot +++ b/robot/testsuites/integration/acl/common_steps_acl_basic.robot @@ -44,10 +44,7 @@ Payment Operations ... Transaction accepted in block ${TX_DEPOSIT} Get Transaction ${TX_DEPOSIT} - Create Containers - # Create containers: - Log Create Private Container ${PRIV_CID_GEN} = Create container ${USER_KEY} 0x18888888 ${RULE_FOR_ALL} Container Existing ${USER_KEY} ${PRIV_CID_GEN} @@ -64,7 +61,6 @@ Create Containers Set Global Variable ${PUBLIC_CID} ${PUBLIC_CID_GEN} Set Global Variable ${READONLY_CID} ${READONLY_CID_GEN} - Generate file [Arguments] ${SIZE} ${FILE_S_GEN} = Generate file of bytes ${SIZE} diff --git a/robot/testsuites/integration/acl/common_steps_acl_bearer.robot b/robot/testsuites/integration/acl/common_steps_acl_bearer.robot index 8b3482d..74c7b9c 100644 --- a/robot/testsuites/integration/acl/common_steps_acl_bearer.robot +++ b/robot/testsuites/integration/acl/common_steps_acl_bearer.robot @@ -14,8 +14,8 @@ ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X Generate Keys # Generate new wallets - ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} - ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} + ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} + ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} # Get pre-defined keys ${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de @@ -52,13 +52,13 @@ Payment Operations Create Container Public Log Create Public Container - ${PUBLIC_CID_GEN} = Create container ${USER_KEY} 0x0FFFFFFF + ${PUBLIC_CID_GEN} = Create container ${USER_KEY} 0x0FFFFFFF ${COMMON_PLACEMENT_RULE} [Return] ${PUBLIC_CID_GEN} Create Container Inaccessible Log Create Inaccessible Container - ${PUBLIC_CID_GEN} = Create container ${USER_KEY} 0x40000000 + ${PUBLIC_CID_GEN} = Create container ${USER_KEY} 0x40000000 ${COMMON_PLACEMENT_RULE} [Return] ${PUBLIC_CID_GEN} diff --git a/robot/testsuites/integration/network/replication.robot b/robot/testsuites/integration/network/replication.robot index a4d46a1..2e7f2ff 100644 --- a/robot/testsuites/integration/network/replication.robot +++ b/robot/testsuites/integration/network/replication.robot @@ -6,6 +6,9 @@ Library ../${RESOURCES}/payment_neogo.py Library ${KEYWORDS}/wallet.py Library ../${RESOURCES}/utility_keywords.py +*** Variables *** +${PLACEMENT_RULE} = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X" + *** Test cases *** NeoFS Object Replication [Documentation] Testcase to validate NeoFS object replication. @@ -28,7 +31,7 @@ NeoFS Object Replication ... Transaction accepted in block ${TX_DEPOSIT} Get Transaction ${TX_DEPOSIT} - ${CID} = Create container ${PRIV_KEY} ${EMPTY} REP 2 IN X CBF 1 SELECT 4 FROM * AS X + ${CID} = Create container ${PRIV_KEY} ${EMPTY} ${PLACEMENT_RULE} Container Existing ${PRIV_KEY} ${CID} diff --git a/robot/testsuites/integration/object/common_steps_object.robot b/robot/testsuites/integration/object/common_steps_object.robot index 145d4ae..639152c 100644 --- a/robot/testsuites/integration/object/common_steps_object.robot +++ b/robot/testsuites/integration/object/common_steps_object.robot @@ -6,9 +6,10 @@ Library ${KEYWORDS}/wallet.py *** Variables *** ${FILE_USR_HEADER} = key1=1,key2=abc ${FILE_USR_HEADER_OTH} = key1=2 -${UNEXIST_OID} = B2DKvkHnLnPvapbDgfpU1oVUPuXQo5LTfKVxmNDZXQff +${UNEXIST_OID} = B2DKvkHnLnPvapbDgfpU1oVUPuXQo5LTfKVxmNDZXQff ${TRANSFER_AMOUNT} = 15 -${DEPOSIT_AMOUNT} = 10 +${DEPOSIT_AMOUNT} = 10 +${EMPTY_ACL} = "" *** Keywords *** @@ -34,13 +35,11 @@ Payment operations Set Global Variable ${PRIV_KEY} ${PRIV_KEY} Set Global Variable ${ADDR} ${ADDR} - Prepare container - ${CID} = Create container ${PRIV_KEY} - Container Existing ${PRIV_KEY} ${CID} + ${CID} = Create container ${PRIV_KEY} ${EMPTY_ACL} ${COMMON_PLACEMENT_RULE} + Container Existing ${PRIV_KEY} ${CID} Wait Until Keyword Succeeds ${NEOFS_EPOCH_TIMEOUT} ${MORPH_BLOCK_TIME} ... Expected Balance ${PRIV_KEY} ${DEPOSIT_AMOUNT} ${NEOFS_CREATE_CONTAINER_GAS_FEE} Set Global Variable ${CID} ${CID} - diff --git a/robot/testsuites/integration/object/object_storagegroup_complex.robot b/robot/testsuites/integration/object/object_storagegroup_complex.robot index 22ab8f4..69b2f8e 100644 --- a/robot/testsuites/integration/object/object_storagegroup_complex.robot +++ b/robot/testsuites/integration/object/object_storagegroup_complex.robot @@ -6,7 +6,6 @@ Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/utility_keywords.py Resource common_steps_object.robot - *** Test cases *** NeoFS Complex Storagegroup [Documentation] Testcase to validate NeoFS operations with Storagegroup. @@ -16,17 +15,16 @@ NeoFS Complex Storagegroup [Setup] Create Temporary Directory Payment operations - Create container + Prepare container ${FILE_S} = Generate file of bytes ${COMPLEX_OBJ_SIZE} ${FILE_HASH_S} = Get file hash ${FILE_S} - # Put two Simple Object ${S_OID_1} = Put object ${PRIV_KEY} ${FILE_S} ${CID} ${EMPTY} ${EMPTY} ${S_OID_2} = Put object ${PRIV_KEY} ${FILE_S} ${CID} ${EMPTY} ${FILE_USR_HEADER} - @{S_OBJ_ALL} = Create List ${S_OID_1} ${S_OID_2} + @{S_OBJ_ALL} = Create List ${S_OID_1} ${S_OID_2} Log Storage group with 1 object ${SG_OID_1} = Put Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} ${S_OID_1} @@ -39,7 +37,6 @@ NeoFS Complex Storagegroup ... Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} ${EMPTY} ${COMPLEX_OBJ_SIZE} @{SPLIT_OBJ_1} List Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} @{EMPTY} - Log Storage group with 2 objects ${SG_OID_2} = Put Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} @{S_OBJ_ALL} List Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} ${SG_OID_2} diff --git a/robot/testsuites/integration/object/object_storagegroup_simple.robot b/robot/testsuites/integration/object/object_storagegroup_simple.robot index a51be64..f56880c 100644 --- a/robot/testsuites/integration/object/object_storagegroup_simple.robot +++ b/robot/testsuites/integration/object/object_storagegroup_simple.robot @@ -16,7 +16,7 @@ NeoFS Simple Storagegroup [Setup] Create Temporary Directory Payment operations - Create container + Prepare container ${FILE_S} = Generate file of bytes ${SIMPLE_OBJ_SIZE} ${FILE_HASH_S} = Get file hash ${FILE_S} diff --git a/robot/testsuites/integration/services/http_gate.robot b/robot/testsuites/integration/services/http_gate.robot index e4946f8..96b4132 100644 --- a/robot/testsuites/integration/services/http_gate.robot +++ b/robot/testsuites/integration/services/http_gate.robot @@ -1,6 +1,5 @@ *** Settings *** Variables ../../../variables/common.py -<<<<<<< HEAD Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/payment_neogo.py @@ -8,6 +7,8 @@ Library ../${RESOURCES}/gates.py Library ${KEYWORDS}/wallet.py Library ../${RESOURCES}/utility_keywords.py +*** Variables *** +${PLACEMENT_RULE} = "REP 1 IN X CBF 1 SELECT 1 FROM * AS X" *** Test cases *** @@ -31,7 +32,7 @@ NeoFS HTTP Gateway ... Transaction accepted in block ${TX_DEPOSIT} Get Transaction ${TX_DEPOSIT} - ${CID} = Create container ${PRIV_KEY} public REP 1 IN X CBF 1 SELECT 1 FROM * AS X + ${CID} = Create container ${PRIV_KEY} public ${PLACEMENT_RULE} Wait Until Keyword Succeeds 2 min 30 sec ... Container Existing ${PRIV_KEY} ${CID} diff --git a/robot/variables/common.py b/robot/variables/common.py index f2c58ed..248746f 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -53,4 +53,6 @@ GAS_HASH = os.getenv("GAS_HASH", '0xd2a4cff31913016155e38e474a2c06d08be276cf') NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT") else os.getenv("NEOFS_IR_CONTRACTS_NEOFS", 'cfe89912c457754b7eb1f89781dc74bb3e0070bf')) +COMMON_PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 2 FROM * AS X" + TEMP_DIR = os.getenv("TEMP_DIR", "TemporaryDir/")