diff --git a/robot/resources/lib/neofs.py b/robot/resources/lib/neofs.py index 3132b8b1..417f45da 100644 --- a/robot/resources/lib/neofs.py +++ b/robot/resources/lib/neofs.py @@ -841,6 +841,25 @@ def delete_object(private_key: str, cid: str, oid: str, bearer: str, options: st except subprocess.CalledProcessError as e: raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) +@keyword('Delete Container') +# TODO: make the error message about a non-found container more user-friendly https://github.com/nspcc-dev/neofs-contract/issues/121 +def delete_container(cid: str, private_key: str): + + deleteContainerCmd = ( + f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wif {private_key} ' + f'container delete --cid {cid} --await' + ) + logger.info("Cmd: %s" % deleteContainerCmd) + + try: + subprocess.run(deleteContainerCmd, check=True, universal_newlines=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=300, shell=True) + + logger.info("Container %s has been deleted" % cid) + + except subprocess.CalledProcessError as e: + raise Exception("Error: \nreturn code: %s. \nOutput: %s" % (e.returncode, e.stderr)) + @keyword('Get file name') def get_file_name(filepath): filename = os.path.basename(filepath) @@ -1190,6 +1209,7 @@ def _search_object(node:str, private_key: str, cid:str, oid: str): f'{NEOFS_CLI_EXEC} --rpc-endpoint {node} --wif {private_key} --ttl 1 ' f'object search --root --cid {cid} {oid_cmd}' ) + try: logger.info(Cmd) complProc = subprocess.run(Cmd, check=True, universal_newlines=True, diff --git a/robot/testsuites/integration/object/container_attributes.robot b/robot/testsuites/integration/container/container_attributes.robot similarity index 100% rename from robot/testsuites/integration/object/container_attributes.robot rename to robot/testsuites/integration/container/container_attributes.robot diff --git a/robot/testsuites/integration/container/container_delete.robot b/robot/testsuites/integration/container/container_delete.robot new file mode 100644 index 00000000..e2058ffa --- /dev/null +++ b/robot/testsuites/integration/container/container_delete.robot @@ -0,0 +1,37 @@ +*** Settings *** +Variables ../../../variables/common.py + +Library ../${RESOURCES}/neofs.py +Library ../${RESOURCES}/payment_neogo.py +Library ${KEYWORDS}/wallet_keywords.py + +Resource ../${RESOURCES}/setup_teardown.robot +Resource ../${RESOURCES}/payment_operations.robot + +*** Test Cases *** +Delete Containers + [Documentation] Testcase to check if containers can be deleted. + [Tags] Container NeoFS NeoCLI + [Timeout] 10 min + + [Setup] Setup + + ${WALLET} ${ADDR} ${USER_KEY} = Init Wallet with Address ${ASSETS_DIR} + Payment Operations ${ADDR} ${USER_KEY} + ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY} = Init Wallet with Address ${ASSETS_DIR} + Payment Operations ${ADDR_OTH} ${OTHER_KEY} + + ${CID} = Create container ${USER_KEY} 0x1FFFFFFF ${COMMON_PLACEMENT_RULE} + Container Existing ${USER_KEY} ${CID} + + Run Keyword And Expect Error * + ... Delete Container ${CID} ${OTHER_KEY} + + Delete Container ${CID} ${USER_KEY} + + ${EXPECTED_ERROR} = Run Keyword And Expect Error * + ... Delete Container ${CID} ${USER_KEY} + Log Container cannot be deleted: ${EXPECTED_ERROR} + + [Teardown] Teardown container_delete + \ No newline at end of file