"create container" -> "prepare container" misprint fixed

Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
anastasia prasolova 2021-05-04 12:27:43 +03:00 committed by Anastasia Prasolova
parent 9c1d4b9b07
commit d841f3f9ef
10 changed files with 66 additions and 54 deletions

View file

@ -23,7 +23,6 @@ from common import *
ROBOT_AUTO_KEYWORDS = False ROBOT_AUTO_KEYWORDS = False
CLI_PREFIX = ""
# path to neofs-cli executable # path to neofs-cli executable
NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli') 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)) raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
@keyword('Create container') @keyword('Create container')
def create_container(private_key: str, basic_acl:str="", def create_container(private_key: str, basic_acl:str, rule:str):
rule:str="REP 2 IN X CBF 1 SELECT 2 FROM * AS X"): if rule == "":
logger.error("Cannot create container with empty placement rule")
if basic_acl != "": if basic_acl != "":
basic_acl = "--basic-acl " + basic_acl basic_acl = f"--basic-acl {basic_acl}"
createContainerCmd = ( createContainerCmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --key {private_key} ' 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) logger.info("Output: %s" % output)
cid = _parse_cid(output) cid = _parse_cid(output)
logger.info("Created container %s with rule '%s'" % (cid, rule)) logger.info("Created container %s with rule '%s'" % (cid, rule))
return cid return cid
@ -407,7 +406,6 @@ def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: s
@keyword('Get Split objects') @keyword('Get Split objects')
def get_component_objects(private_key: str, cid: str, oid: str): def get_component_objects(private_key: str, cid: str, oid: str):
logger.info("Collect Split objects list from Linked object.") logger.info("Collect Split objects list from Linked object.")
split_id = "" split_id = ""
nodes = _get_storage_nodes() 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'] return header_link_parsed['Split ChildID']
@keyword('Verify Split Chain') @keyword('Verify Split Chain')
def verify_split_chain(private_key: str, cid: str, oid: str): def verify_split_chain(private_key: str, cid: str, oid: str):
@ -739,7 +736,6 @@ def parse_object_system_header(header: str):
else: else:
raise Exception("no Type was parsed from object header: \t%s" % header) raise Exception("no Type was parsed from object header: \t%s" % header)
# Header - Optional attributes # Header - Optional attributes
m = re.search(r'Split ID:\s+([\w-]+)', header) m = re.search(r'Split ID:\s+([\w-]+)', header)
if m is not None: 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) found_objects = re.findall(r'Split ChildID:\s+(\w+)', header)
if found_objects: if found_objects:
result_header['Split ChildID'] = found_objects result_header['Split ChildID'] = found_objects
logger.info("Result: %s" % result_header) logger.info("Result: %s" % result_header)
return result_header return result_header
@ -801,6 +795,7 @@ def verify_file_hash(filename, expected_hash):
else: else:
raise Exception("File hash '{}' is not equal to {}".format(file_hash, expected_hash)) raise Exception("File hash '{}' is not equal to {}".format(file_hash, expected_hash))
@keyword('Put object') @keyword('Put object')
def put_object(private_key: str, path: str, cid: str, bearer: str, user_headers: str, def put_object(private_key: str, path: str, cid: str, bearer: str, user_headers: str,
endpoint: str="", options: 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)) raise Exception("no CID %s was parsed from command output: \t%s" % (cid, output))
return cid return cid
def _parse_oid(output: str): def _parse_oid(input_str: str):
""" """
This function parses OID from given CLI output. This function parses OID from given CLI output. The input string we
Parameters: expect:
- output: a string with command run output Object successfully stored
""" ID: 4MhrLA7RXTBXCsaNnbahYVAPuoQdiUPuyNEWnywvoSEs
m = re.search(r'ID: ([a-zA-Z0-9-]+)', output) CID: HeZu2DXBuPve6HXbuHZx64knS7KcGtfSj2L59Li72kkg
if m.start() != m.end(): # e.g., if match found something We want to take 'ID' value from the string.
oid = m.group(1)
else:
raise Exception("no OID was parsed from command output: \t%s" % output)
return oid
def _parse_cid(output: str):
"""
This function parses CID from given CLI output.
Parameters: Parameters:
- output: a string with command run output - input_str: a string with command run output
""" """
m = re.search(r'container ID: (\w+)', output) try:
if not m.start() != m.end(): # e.g., if match found something # taking second string from command output
raise Exception("no CID was parsed from command output: \t%s" % (output)) snd_str = input_str.split('\n')[1]
cid = m.group(1) except:
return cid 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(): def _get_storage_nodes():
# TODO: fix to get netmap from neofs-cli # TODO: fix to get netmap from neofs-cli

View file

@ -44,10 +44,7 @@ Payment Operations
... Transaction accepted in block ${TX_DEPOSIT} ... Transaction accepted in block ${TX_DEPOSIT}
Get Transaction ${TX_DEPOSIT} Get Transaction ${TX_DEPOSIT}
Create Containers Create Containers
# Create containers:
Log Create Private Container Log Create Private Container
${PRIV_CID_GEN} = Create container ${USER_KEY} 0x18888888 ${RULE_FOR_ALL} ${PRIV_CID_GEN} = Create container ${USER_KEY} 0x18888888 ${RULE_FOR_ALL}
Container Existing ${USER_KEY} ${PRIV_CID_GEN} Container Existing ${USER_KEY} ${PRIV_CID_GEN}
@ -64,7 +61,6 @@ Create Containers
Set Global Variable ${PUBLIC_CID} ${PUBLIC_CID_GEN} Set Global Variable ${PUBLIC_CID} ${PUBLIC_CID_GEN}
Set Global Variable ${READONLY_CID} ${READONLY_CID_GEN} Set Global Variable ${READONLY_CID} ${READONLY_CID_GEN}
Generate file Generate file
[Arguments] ${SIZE} [Arguments] ${SIZE}
${FILE_S_GEN} = Generate file of bytes ${SIZE} ${FILE_S_GEN} = Generate file of bytes ${SIZE}

View file

@ -52,13 +52,13 @@ Payment Operations
Create Container Public Create Container Public
Log Create Public Container 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} [Return] ${PUBLIC_CID_GEN}
Create Container Inaccessible Create Container Inaccessible
Log Create Inaccessible Container 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} [Return] ${PUBLIC_CID_GEN}

View file

@ -6,6 +6,9 @@ Library ../${RESOURCES}/payment_neogo.py
Library ${KEYWORDS}/wallet.py Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
*** Variables ***
${PLACEMENT_RULE} = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X"
*** Test cases *** *** Test cases ***
NeoFS Object Replication NeoFS Object Replication
[Documentation] Testcase to validate NeoFS object replication. [Documentation] Testcase to validate NeoFS object replication.
@ -28,7 +31,7 @@ NeoFS Object Replication
... Transaction accepted in block ${TX_DEPOSIT} ... Transaction accepted in block ${TX_DEPOSIT}
Get Transaction ${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} Container Existing ${PRIV_KEY} ${CID}

View file

@ -9,6 +9,7 @@ ${FILE_USR_HEADER_OTH} = key1=2
${UNEXIST_OID} = B2DKvkHnLnPvapbDgfpU1oVUPuXQo5LTfKVxmNDZXQff ${UNEXIST_OID} = B2DKvkHnLnPvapbDgfpU1oVUPuXQo5LTfKVxmNDZXQff
${TRANSFER_AMOUNT} = 15 ${TRANSFER_AMOUNT} = 15
${DEPOSIT_AMOUNT} = 10 ${DEPOSIT_AMOUNT} = 10
${EMPTY_ACL} = ""
*** Keywords *** *** Keywords ***
@ -34,13 +35,11 @@ Payment operations
Set Global Variable ${PRIV_KEY} ${PRIV_KEY} Set Global Variable ${PRIV_KEY} ${PRIV_KEY}
Set Global Variable ${ADDR} ${ADDR} Set Global Variable ${ADDR} ${ADDR}
Prepare container Prepare container
${CID} = Create container ${PRIV_KEY} ${CID} = Create container ${PRIV_KEY} ${EMPTY_ACL} ${COMMON_PLACEMENT_RULE}
Container Existing ${PRIV_KEY} ${CID} Container Existing ${PRIV_KEY} ${CID}
Wait Until Keyword Succeeds ${NEOFS_EPOCH_TIMEOUT} ${MORPH_BLOCK_TIME} Wait Until Keyword Succeeds ${NEOFS_EPOCH_TIMEOUT} ${MORPH_BLOCK_TIME}
... Expected Balance ${PRIV_KEY} ${DEPOSIT_AMOUNT} ${NEOFS_CREATE_CONTAINER_GAS_FEE} ... Expected Balance ${PRIV_KEY} ${DEPOSIT_AMOUNT} ${NEOFS_CREATE_CONTAINER_GAS_FEE}
Set Global Variable ${CID} ${CID} Set Global Variable ${CID} ${CID}

View file

@ -6,7 +6,6 @@ Library ../${RESOURCES}/payment_neogo.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
Resource common_steps_object.robot Resource common_steps_object.robot
*** Test cases *** *** Test cases ***
NeoFS Complex Storagegroup NeoFS Complex Storagegroup
[Documentation] Testcase to validate NeoFS operations with Storagegroup. [Documentation] Testcase to validate NeoFS operations with Storagegroup.
@ -16,12 +15,11 @@ NeoFS Complex Storagegroup
[Setup] Create Temporary Directory [Setup] Create Temporary Directory
Payment operations Payment operations
Create container Prepare container
${FILE_S} = Generate file of bytes ${COMPLEX_OBJ_SIZE} ${FILE_S} = Generate file of bytes ${COMPLEX_OBJ_SIZE}
${FILE_HASH_S} = Get file hash ${FILE_S} ${FILE_HASH_S} = Get file hash ${FILE_S}
# Put two Simple Object # Put two Simple Object
${S_OID_1} = Put object ${PRIV_KEY} ${FILE_S} ${CID} ${EMPTY} ${EMPTY} ${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_OID_2} = Put object ${PRIV_KEY} ${FILE_S} ${CID} ${EMPTY} ${FILE_USR_HEADER}
@ -39,7 +37,6 @@ NeoFS Complex Storagegroup
... Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} ${EMPTY} ${COMPLEX_OBJ_SIZE} @{SPLIT_OBJ_1} ... Get Storagegroup ${PRIV_KEY} ${CID} ${SG_OID_1} ${EMPTY} ${COMPLEX_OBJ_SIZE} @{SPLIT_OBJ_1}
List Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} @{EMPTY} List Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} @{EMPTY}
Log Storage group with 2 objects Log Storage group with 2 objects
${SG_OID_2} = Put Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} @{S_OBJ_ALL} ${SG_OID_2} = Put Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} @{S_OBJ_ALL}
List Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} ${SG_OID_2} List Storagegroup ${PRIV_KEY} ${CID} ${EMPTY} ${SG_OID_2}

View file

@ -16,7 +16,7 @@ NeoFS Simple Storagegroup
[Setup] Create Temporary Directory [Setup] Create Temporary Directory
Payment operations Payment operations
Create container Prepare container
${FILE_S} = Generate file of bytes ${SIMPLE_OBJ_SIZE} ${FILE_S} = Generate file of bytes ${SIMPLE_OBJ_SIZE}
${FILE_HASH_S} = Get file hash ${FILE_S} ${FILE_HASH_S} = Get file hash ${FILE_S}

View file

@ -1,6 +1,5 @@
*** Settings *** *** Settings ***
Variables ../../../variables/common.py Variables ../../../variables/common.py
<<<<<<< HEAD
Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/neofs.py
Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/payment_neogo.py
@ -8,6 +7,8 @@ Library ../${RESOURCES}/gates.py
Library ${KEYWORDS}/wallet.py Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
*** Variables ***
${PLACEMENT_RULE} = "REP 1 IN X CBF 1 SELECT 1 FROM * AS X"
*** Test cases *** *** Test cases ***
@ -31,7 +32,7 @@ NeoFS HTTP Gateway
... Transaction accepted in block ${TX_DEPOSIT} ... Transaction accepted in block ${TX_DEPOSIT}
Get Transaction ${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 Wait Until Keyword Succeeds 2 min 30 sec
... Container Existing ${PRIV_KEY} ${CID} ... Container Existing ${PRIV_KEY} ${CID}

View file

@ -53,4 +53,6 @@ GAS_HASH = os.getenv("GAS_HASH", '0xd2a4cff31913016155e38e474a2c06d08be276cf')
NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT") NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT")
else os.getenv("NEOFS_IR_CONTRACTS_NEOFS", 'cfe89912c457754b7eb1f89781dc74bb3e0070bf')) 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/") TEMP_DIR = os.getenv("TEMP_DIR", "TemporaryDir/")