(#70) Add object_attributes.robot test
Signed-off-by: EliChin <elizaveta@nspcc.ru>
This commit is contained in:
parent
1c2fd5cead
commit
1e7ffba6e4
3 changed files with 172 additions and 4 deletions
|
@ -296,16 +296,18 @@ 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, rule:str):
|
def create_container(private_key: str, basic_acl:str, rule:str, user_headers: str):
|
||||||
if rule == "":
|
if rule == "":
|
||||||
logger.error("Cannot create container with empty placement rule")
|
logger.error("Cannot create container with empty placement rule")
|
||||||
|
|
||||||
if basic_acl:
|
if basic_acl:
|
||||||
basic_acl = f"--basic-acl {basic_acl}"
|
basic_acl = f"--basic-acl {basic_acl}"
|
||||||
|
if user_headers:
|
||||||
|
user_headers = f"--attributes {user_headers}"
|
||||||
|
|
||||||
createContainerCmd = (
|
createContainerCmd = (
|
||||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wif {private_key} '
|
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wif {private_key} '
|
||||||
f'container create --policy "{rule}" {basic_acl} --await'
|
f'container create --policy "{rule}" {basic_acl} {user_headers} --await'
|
||||||
)
|
)
|
||||||
logger.info("Cmd: %s" % createContainerCmd)
|
logger.info("Cmd: %s" % createContainerCmd)
|
||||||
complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True,
|
complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True,
|
||||||
|
@ -601,7 +603,7 @@ def _json_cli_decode(data: str):
|
||||||
|
|
||||||
@keyword('Head object')
|
@keyword('Head object')
|
||||||
def head_object(private_key: str, cid: str, oid: str, bearer_token: str="",
|
def head_object(private_key: str, cid: str, oid: str, bearer_token: str="",
|
||||||
user_headers:str="", options:str="", endpoint: str="", ignore_failure: bool = False):
|
user_headers:str="", options:str="", endpoint: str="", ignore_failure: bool = False, json_output: bool = False):
|
||||||
|
|
||||||
if bearer_token:
|
if bearer_token:
|
||||||
bearer_token = f"--bearer {ASSETS_DIR}/{bearer_token}"
|
bearer_token = f"--bearer {ASSETS_DIR}/{bearer_token}"
|
||||||
|
@ -610,7 +612,7 @@ def head_object(private_key: str, cid: str, oid: str, bearer_token: str="",
|
||||||
|
|
||||||
object_cmd = (
|
object_cmd = (
|
||||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wif {private_key} object '
|
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wif {private_key} object '
|
||||||
f'head --cid {cid} --oid {oid} {bearer_token} {options}'
|
f'head --cid {cid} --oid {oid} {bearer_token} {options} {"--json" if json_output else ""}'
|
||||||
)
|
)
|
||||||
logger.info("Cmd: %s" % object_cmd)
|
logger.info("Cmd: %s" % object_cmd)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
*** Settings ***
|
||||||
|
Variables ../../../variables/common.py
|
||||||
|
|
||||||
|
Library Collections
|
||||||
|
Library Process
|
||||||
|
Library String
|
||||||
|
Library ${KEYWORDS}/contract_keywords.py
|
||||||
|
|
||||||
|
Resource ../${RESOURCES}/setup_teardown.robot
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${SN_01_ADDR} = s01.neofs.devenv:8080
|
||||||
|
${SN_02_ADDR} = s02.neofs.devenv:8080
|
||||||
|
|
||||||
|
*** Test cases ***
|
||||||
|
NetworkInfo RPC Method
|
||||||
|
[Documentation] Testcase to check NetworkInfo RPC method.
|
||||||
|
[Tags] RPC NeoFS NeoCLI NetworkInfo
|
||||||
|
[Timeout] 10 min
|
||||||
|
|
||||||
|
[Setup] Setup
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Checking if the command returns equal results for two storage nodes
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
${RESULT1_S01} Run Process neofs-cli netmap netinfo -r ${SN_01_ADDR} -k ${MAINNET_WALLET_WIF} shell=True
|
||||||
|
Should Be Equal As Integers ${RESULT1_S01.rc} 0
|
||||||
|
${RESULT1_S02} Run Process neofs-cli netmap netinfo -r ${SN_02_ADDR} -k ${MAINNET_WALLET_WIF} shell=True
|
||||||
|
Should Be Equal As Integers ${RESULT1_S02.rc} 0
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Checking if morph magic number is relevant
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
${NETWORK_MAGIC_S01} = Parse Magic ${RESULT1_S01.stdout}
|
||||||
|
Should Be Equal ${NETWORK_MAGIC_S01} ${MORPH_MAGIC}
|
||||||
|
|
||||||
|
${NETWORK_MAGIC_S02} = Parse Magic ${RESULT1_S02.stdout}
|
||||||
|
Should Be Equal ${NETWORK_MAGIC_S02} ${MORPH_MAGIC}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Checking if epoch numbers requested from two storage nodes are equal
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
${EPOCH1_S01} = Parse Epoch ${RESULT1_S01.stdout}
|
||||||
|
${EPOCH1_S02} = Parse Epoch ${RESULT1_S02.stdout}
|
||||||
|
Should Be Equal As Integers ${EPOCH1_S01} ${EPOCH1_S02}
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Ticking epoch and getting new netinfo
|
||||||
|
########################################
|
||||||
|
|
||||||
|
Tick Epoch
|
||||||
|
|
||||||
|
${RESULT2_S01} Run Process neofs-cli netmap netinfo -r ${SN_01_ADDR} -k ${MAINNET_WALLET_WIF} shell=True
|
||||||
|
Should Be Equal As Integers ${RESULT2_S01.rc} 0
|
||||||
|
${RESULT2_S02} Run Process neofs-cli netmap netinfo -r ${SN_02_ADDR} -k ${MAINNET_WALLET_WIF} shell=True
|
||||||
|
Should Be Equal As Integers ${RESULT2_S02.rc} 0
|
||||||
|
|
||||||
|
Should Be Equal As Strings ${RESULT2_S01.stdout} ${RESULT2_S02.stdout}
|
||||||
|
|
||||||
|
${EPOCH2_S01} = Parse Epoch ${RESULT2_S01.stdout}
|
||||||
|
|
||||||
|
#################################################################
|
||||||
|
# Checking if the second epoch value is more than the first by 1
|
||||||
|
#################################################################
|
||||||
|
|
||||||
|
${NEW_EPOCH} = Evaluate ${EPOCH1_S01}+${1}
|
||||||
|
Should Be Equal ${EPOCH2_S01} ${NEW_EPOCH}
|
||||||
|
|
||||||
|
|
||||||
|
[Teardown] Teardown network_rpc_method
|
||||||
|
|
||||||
|
*** Keywords ***
|
||||||
|
|
||||||
|
Parse Magic
|
||||||
|
[Arguments] ${RESULT_STDOUT}
|
||||||
|
@{MAGIC} = Split String ${RESULT_STDOUT} ${\n}
|
||||||
|
${NETWORK_MAGIC} = Get From List ${MAGIC} ${1}
|
||||||
|
@{MAGIC_INFO} = Split String ${NETWORK_MAGIC} ${SPACE}
|
||||||
|
${MAGIC_VALUE} = Get From List ${MAGIC_INFO} ${4}
|
||||||
|
[Return] ${MAGIC_VALUE}
|
||||||
|
|
||||||
|
Parse Epoch
|
||||||
|
[Arguments] ${RESULT_STDOUT}
|
||||||
|
@{EPOCH} = Split String ${RESULT_STDOUT} ${\n}
|
||||||
|
${NETWORK_EPOCH} = Get From List ${EPOCH} ${0}
|
||||||
|
@{EPOCH_INFO} = Split String ${NETWORK_EPOCH} ${SPACE}
|
||||||
|
${EPOCH_VALUE} = Get From List ${EPOCH_INFO} ${1}
|
||||||
|
${EPOCH_VALUE_INT} = Convert To Integer ${EPOCH_VALUE}
|
||||||
|
[Return] ${EPOCH_VALUE_INT}
|
74
robot/testsuites/integration/object/object_attributes.robot
Normal file
74
robot/testsuites/integration/object/object_attributes.robot
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
*** Settings ***
|
||||||
|
Variables ../../../variables/common.py
|
||||||
|
|
||||||
|
Library Collections
|
||||||
|
Library ../${RESOURCES}/neofs.py
|
||||||
|
Library ../${RESOURCES}/payment_neogo.py
|
||||||
|
Library String
|
||||||
|
|
||||||
|
Resource ../${RESOURCES}/setup_teardown.robot
|
||||||
|
Resource ../${RESOURCES}/payment_operations.robot
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${POLICY} = REP 2 IN X CBF 1 SELECT 2 FROM * AS X
|
||||||
|
${ATTR_FILENAME} = FileName=new
|
||||||
|
${ATTR_DUPLICATE} = FileType=jpg, FileType=png
|
||||||
|
${ATTR_NONE} = NoAttribute=''
|
||||||
|
${ATTR_SINGLE} = AttrNum=one
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
|
||||||
|
Duplicated Object Attributes
|
||||||
|
[Documentation] Testcase to check duplicated attributes.
|
||||||
|
[Tags] Object NeoFS NeoCLI
|
||||||
|
[Timeout] 10 min
|
||||||
|
|
||||||
|
[Setup] Setup
|
||||||
|
|
||||||
|
${WALLET} ${ADDR} ${USER_KEY} = Init Wallet with Address ${ASSETS_DIR}
|
||||||
|
Payment Operations ${ADDR} ${USER_KEY}
|
||||||
|
|
||||||
|
${PUBLIC_CID} = Create container ${USER_KEY} 0x1FFFFFFF ${POLICY} ${EMPTY}
|
||||||
|
${FILE_S} = Generate file of bytes ${SIMPLE_OBJ_SIZE}
|
||||||
|
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Checking that object attributes cannot duplicate
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... Put object ${USER_KEY} ${FILE_S} ${PUBLIC_CID} ${EMPTY} ${ATTR_FILENAME}
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... Put object ${USER_KEY} ${FILE_S} ${PUBLIC_CID} ${EMPTY} ${ATTR_DUPLICATE}
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Checking that object cannot have empty attibute
|
||||||
|
##################################################
|
||||||
|
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... Put object ${USER_KEY} ${FILE_S} ${PUBLIC_CID} ${EMPTY} ${ATTR_NONE}
|
||||||
|
|
||||||
|
#####################################################
|
||||||
|
# Checking a successful step with a single attribute
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
${OID} = Put object ${USER_KEY} ${FILE_S} ${PUBLIC_CID} ${EMPTY} ${ATTR_SINGLE}
|
||||||
|
${HEAD} = Head object ${USER_KEY} ${PUBLIC_CID} ${OID} json_output=True
|
||||||
|
${ATTR} = Parse Header Attributes ${HEAD}
|
||||||
|
Should Be Equal ${ATTR} ${ATTR_SINGLE}
|
||||||
|
|
||||||
|
[Teardown] Teardown object_attributes
|
||||||
|
|
||||||
|
*** Keywords ***
|
||||||
|
|
||||||
|
Parse Header Attributes
|
||||||
|
|
||||||
|
[Arguments] ${HEADER}
|
||||||
|
&{HEADER_DIC} = Evaluate json.loads('''${HEADER}''') json
|
||||||
|
&{HEADER_ELEMENT} = Get From Dictionary ${HEADER_DIC} header
|
||||||
|
@{ATTR_DIC} = Get From Dictionary ${HEADER_ELEMENT} attributes
|
||||||
|
&{ATTR_NUM_DIC} = Get From List ${ATTR_DIC} 0
|
||||||
|
${ATTR_KEY} = Get From Dictionary ${ATTR_NUM_DIC} key
|
||||||
|
${ATTR_VALUE} = Get From Dictionary ${ATTR_NUM_DIC} value
|
||||||
|
${ATTRIBUTE} = Catenate SEPARATOR=\= ${ATTR_KEY} ${ATTR_VALUE}
|
||||||
|
[Return] ${ATTRIBUTE}
|
Loading…
Reference in a new issue