Add container_attributes.robot test
Signed-off-by: EliChin <elizaveta@nspcc.ru>
This commit is contained in:
parent
692d6c4e20
commit
abc7845610
2 changed files with 100 additions and 1 deletions
|
@ -635,6 +635,36 @@ def head_object(private_key: str, cid: str, oid: str, bearer_token: str="",
|
||||||
else:
|
else:
|
||||||
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('Head container')
|
||||||
|
def head_container(private_key: str, cid: str, endpoint: str="", user_headers:str="", ignore_failure: bool = False, json_output: bool = False):
|
||||||
|
|
||||||
|
if endpoint == "":
|
||||||
|
endpoint = NEOFS_ENDPOINT
|
||||||
|
|
||||||
|
container_cmd = (
|
||||||
|
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wif {private_key} --cid {cid} container get {"--json" if json_output else ""}'
|
||||||
|
)
|
||||||
|
logger.info("Cmd: %s" % container_cmd)
|
||||||
|
try:
|
||||||
|
complProc = subprocess.run(container_cmd, check=True, universal_newlines=True,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True)
|
||||||
|
logger.info("Output: %s" % complProc.stdout)
|
||||||
|
|
||||||
|
if user_headers:
|
||||||
|
for key in user_headers.split(","):
|
||||||
|
if re.search(r'(%s)' % key, complProc.stdout):
|
||||||
|
logger.info("User header %s was parsed from command output" % key)
|
||||||
|
else:
|
||||||
|
raise Exception("User header %s was not found in the command output: \t%s" % (key, complProc.stdout))
|
||||||
|
return complProc.stdout
|
||||||
|
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
if ignore_failure:
|
||||||
|
logger.info("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
|
||||||
|
return e.output
|
||||||
|
else:
|
||||||
|
raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
|
||||||
|
|
||||||
@keyword('Parse Object Virtual Raw Header')
|
@keyword('Parse Object Virtual Raw Header')
|
||||||
def parse_object_virtual_raw_header(header: str):
|
def parse_object_virtual_raw_header(header: str):
|
||||||
result_header = dict()
|
result_header = dict()
|
||||||
|
@ -659,7 +689,7 @@ def parse_object_virtual_raw_header(header: str):
|
||||||
@keyword('Parse Object System Header')
|
@keyword('Parse Object System Header')
|
||||||
def parse_object_system_header(header: str):
|
def parse_object_system_header(header: str):
|
||||||
result_header = dict()
|
result_header = dict()
|
||||||
|
|
||||||
# Header - Constant attributes
|
# Header - Constant attributes
|
||||||
|
|
||||||
# ID
|
# ID
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
*** 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
|
||||||
|
Resource ../acl/common_steps_acl_bearer.robot
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${POLICY} = REP 2 IN X CBF 1 SELECT 2 FROM * AS X
|
||||||
|
${ATTR_TIME} = Timestamp=new
|
||||||
|
${ATTR_DUPLICATE} = Size=small, Size=big
|
||||||
|
${ATTR_NONE} = NoAttribute=''
|
||||||
|
${ATTR_SINGLE} = AttrNum=one
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
Duplicated Object Attributes
|
||||||
|
[Documentation] Testcase to check duplicated container attributes.
|
||||||
|
[Tags] Container NeoFS NeoCLI
|
||||||
|
[Timeout] 10 min
|
||||||
|
|
||||||
|
[Setup] Setup
|
||||||
|
|
||||||
|
${WALLET} ${ADDR} ${USER_KEY} = Init Wallet with Address ${ASSETS_DIR}
|
||||||
|
Payment Operations ${ADDR} ${USER_KEY}
|
||||||
|
|
||||||
|
######################################################
|
||||||
|
# Checking that container attributes cannot duplicate
|
||||||
|
######################################################
|
||||||
|
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... Create container ${USER_KEY} ${EMPTY} ${POLICY} ${ATTR_TIME}
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... Create container ${USER_KEY} ${EMPTY} ${POLICY} ${ATTR_DUPLICATE}
|
||||||
|
|
||||||
|
#####################################################
|
||||||
|
# Checking that container cannot have empty attibute
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... Create container ${USER_KEY} ${EMPTY} ${POLICY} ${ATTR_NONE}
|
||||||
|
|
||||||
|
#####################################################
|
||||||
|
# Checking a successful step with a single attribute
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
${CID} = Create container ${USER_KEY} ${EMPTY} ${POLICY} ${ATTR_SINGLE}
|
||||||
|
${HEAD} = Head container ${USER_KEY} ${CID} ${EMPTY} json_output=True
|
||||||
|
${ATTR} = Parse Header Attributes ${HEAD}
|
||||||
|
Should Be Equal ${ATTR} ${ATTR_SINGLE}
|
||||||
|
|
||||||
|
[Teardown] Teardown container_attributes
|
||||||
|
|
||||||
|
*** Keywords ***
|
||||||
|
|
||||||
|
Parse Header Attributes
|
||||||
|
|
||||||
|
[Arguments] ${HEADER}
|
||||||
|
&{HEADER_DIC} = Evaluate json.loads('''${HEADER}''') json
|
||||||
|
@{ATTR_DIC} = Get From Dictionary ${HEADER_DIC} 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