From e2983c8539c485c545ab8345c6769bfa14fcca96 Mon Sep 17 00:00:00 2001 From: anatoly-bogatyrev <45566606+anatoly-bogatyrev@users.noreply.github.com> Date: Fri, 12 Feb 2021 00:34:44 +0300 Subject: [PATCH] Add storagegroup complex test case (#32) * storage group complex test case has been added * timeouts for several commands have been increased --- robot/resources/lib/neofs.py | 27 +++++- .../object/object_storagegroup_complex.robot | 92 +++++++++++++++++++ .../object/object_storagegroup_simple.robot | 2 +- 3 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 robot/testsuites/integration/object/object_storagegroup_complex.robot diff --git a/robot/resources/lib/neofs.py b/robot/resources/lib/neofs.py index 9ae43f9b..3984cb6e 100644 --- a/robot/resources/lib/neofs.py +++ b/robot/resources/lib/neofs.py @@ -403,6 +403,25 @@ def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: s except subprocess.CalledProcessError as e: raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) +@keyword('Get Split objects') +def get_component_objects(private_key: str, cid: str, oid: str): + + logger.info("Collect Split objects list from Linked object.") + nodes = _get_storage_nodes() + for node in nodes: + header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True) + parsed_header_virtual = parse_object_virtual_raw_header(header_virtual) + + if 'Linking object' in parsed_header_virtual.keys(): + + header_link = head_object(private_key, cid, parsed_header_virtual['Linking object'], '', '', '--raw') + header_link_parsed = parse_object_system_header(header_link) + + return header_link_parsed['Split ChildID'] + + raise Exception("Linking object has not been found.") + + @keyword('Verify Split Chain') def verify_split_chain(private_key: str, cid: str, oid: str): @@ -925,7 +944,7 @@ def get_object(private_key: str, cid: str, oid: str, bearer_token: str, logger.info("Cmd: %s" % ObjectCmd) try: complProc = subprocess.run(ObjectCmd, check=True, universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60, shell=True) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=120, shell=True) logger.info("Output: %s" % complProc.stdout) except subprocess.CalledProcessError as e: raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) @@ -944,7 +963,7 @@ def put_storagegroup(private_key: str, cid: str, *oid_list): logger.info(f"Cmd: {ObjectCmd}") try: complProc = subprocess.run(ObjectCmd, check=True, universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60, shell=True) logger.info(f"Output: {complProc.stdout}" ) oid = _parse_oid(complProc.stdout) @@ -985,7 +1004,7 @@ def get_storagegroup(private_key: str, cid: str, oid: str, expected_size, *expec logger.info(f"Cmd: {ObjectCmd}") try: complProc = subprocess.run(ObjectCmd, check=True, universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60, shell=True) logger.info(f"Output: {complProc.stdout}") if expected_size: @@ -1017,7 +1036,7 @@ def delete_storagegroup(private_key: str, cid: str, oid: str): logger.info(f"Cmd: {ObjectCmd}") try: complProc = subprocess.run(ObjectCmd, check=True, universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60, shell=True) logger.info(f"Output: {complProc.stdout}") m = re.search(r'Tombstone: ([a-zA-Z0-9-]+)', complProc.stdout) diff --git a/robot/testsuites/integration/object/object_storagegroup_complex.robot b/robot/testsuites/integration/object/object_storagegroup_complex.robot new file mode 100644 index 00000000..e1b1876d --- /dev/null +++ b/robot/testsuites/integration/object/object_storagegroup_complex.robot @@ -0,0 +1,92 @@ +*** Settings *** +Variables ../../../variables/common.py +Library Collections +Library ../${RESOURCES}/neofs.py +Library ../${RESOURCES}/payment_neogo.py +Resource common_steps_object.robot + + +*** Test cases *** +NeoFS Complex Object Operations + [Documentation] Testcase to validate NeoFS operations with Storagegroup. + [Tags] Object NeoFS NeoCLI + [Timeout] 20 min + + ${WALLET} = Init wallet + Generate wallet ${WALLET} + ${ADDR} = Dump Address ${WALLET} + ${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR} + ${TX} = Transfer Mainnet Gas wallets/wallet.json NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx ${ADDR} 15 + Wait Until Keyword Succeeds 1 min 15 sec + ... Transaction accepted in block ${TX} + Get Transaction ${TX} + Expexted Mainnet Balance ${ADDR} 15 + + ${SCRIPT_HASH} = Get ScripHash ${PRIV_KEY} + + ${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} 10 + Wait Until Keyword Succeeds 1 min 15 sec + ... Transaction accepted in block ${TX_DEPOSIT} + Get Transaction ${TX_DEPOSIT} + + ${BALANCE} = Wait Until Keyword Succeeds 5 min 1 min + ... Expected Balance ${PRIV_KEY} 0 10 + + ${CID} = Create container ${PRIV_KEY} + Container Existing ${PRIV_KEY} ${CID} + + ${FILE_S} = Generate file of bytes 70e+6 + ${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} + + Log Storage group with 1 object + ${SG_OID_1} = Put Storagegroup ${PRIV_KEY} ${CID} ${S_OID_1} + List Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} + @{SPLIT_OBJ_1} = Get Split objects ${PRIV_KEY} ${CID} ${S_OID_1} + Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} 70000000 @{SPLIT_OBJ_1} + ${Tombstone} = Delete Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} + Verify Head tombstone ${PRIV_KEY} ${CID} ${Tombstone} ${SG_OID_1} ${ADDR} + Run Keyword And Expect Error * + ... Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} 70000000 @{SPLIT_OBJ_1} + List Storagegroup ${PRIV_KEY} ${CID} @{EMPTY} + + + Log Storage group with 2 objects + ${SG_OID_2} = Put Storagegroup ${PRIV_KEY} ${CID} @{S_OBJ_ALL} + List Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_2} + @{SPLIT_OBJ_2} = Get Split objects ${PRIV_KEY} ${CID} ${S_OID_2} + @{SPLIT_OBJ_ALL} = Combine Lists ${SPLIT_OBJ_1} ${SPLIT_OBJ_2} + Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_2} 140000000 @{SPLIT_OBJ_ALL} + ${Tombstone} = Delete Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_2} + Verify Head tombstone ${PRIV_KEY} ${CID} ${Tombstone} ${SG_OID_2} ${ADDR} + Run Keyword And Expect Error * + ... Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_2} 140000000 @{SPLIT_OBJ_ALL} + List Storagegroup ${PRIV_KEY} ${CID} @{EMPTY} + + Log Incorrect input + + Run Keyword And Expect Error * + ... Put Storagegroup ${PRIV_KEY} ${CID} ${UNEXIST_OID} + Run Keyword And Expect Error * + ... Delete Storagegroup ${PRIV_KEY} ${CID} ${UNEXIST_OID} + + [Teardown] Cleanup ${FILE_S} + +*** Keywords *** + +Cleanup + [Arguments] ${FILE} + + @{CLEANUP_FILES} = Create List ${FILE} + Cleanup Files @{CLEANUP_FILES} + Get Docker Logs object_storage_group_complex + + + + diff --git a/robot/testsuites/integration/object/object_storagegroup_simple.robot b/robot/testsuites/integration/object/object_storagegroup_simple.robot index d63f043d..f61b4d4e 100644 --- a/robot/testsuites/integration/object/object_storagegroup_simple.robot +++ b/robot/testsuites/integration/object/object_storagegroup_simple.robot @@ -82,7 +82,7 @@ Cleanup @{CLEANUP_FILES} = Create List ${FILE} Cleanup Files @{CLEANUP_FILES} - Get Docker Logs object_storage_group + Get Docker Logs object_storage_group_simple