added keywords library container.py extracted from neofs.py

Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
anastasia prasolova 2022-04-25 12:53:20 +03:00 committed by Anastasia Prasolova
parent 14183dabfc
commit 3e749abcd0
18 changed files with 317 additions and 303 deletions

View file

@ -0,0 +1,158 @@
#!/usr/bin/python3
"""
This module contains keywords which utilize `neofs-cli container`
commands.
"""
import json
import time
from common import NEOFS_ENDPOINT, COMMON_PLACEMENT_RULE, NEOFS_CLI_EXEC, WALLET_PASS
from cli_helpers import _cmd_run
from data_formatters import dict_to_attrs
from robot.api.deco import keyword
from robot.api import logger
ROBOT_AUTO_KEYWORDS = False
@keyword('Create Container')
def create_container(wallet: str, rule: str=COMMON_PLACEMENT_RULE, basic_acl: str='',
attributes: dict={}, session_token: str='', session_wallet: str='',
options: str=''):
"""
A wrapper for `neofs-cli container create` call.
Args:
wallet (str): a wallet on whose behalf a container is created
rule (optional, str): placement rule for container
basic_acl (optional, str): an ACL for container, will be
appended to `--basic-acl` key
attributes (optional, dict): container attributes , will be
appended to `--attributes` key
session_token (optional, str): a path to session token file
session_wallet(optional, str): a path to the wallet which signed
the session token; this parameter makes sense
when paired with `session_token`
options (optional, str): any other options to pass to the call
Returns:
(str): CID of the created container
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} container create '
f'--wallet {session_wallet if session_wallet else wallet} '
f'--config {WALLET_PASS} --policy "{rule}" '
f'{"--basic-acl " + basic_acl if basic_acl else ""} '
f'{"--attributes " + dict_to_attrs(attributes) if attributes else ""} '
f'{"--session " + session_token if session_token else ""} '
f'{options} --await'
)
output = _cmd_run(cmd, timeout=60)
cid = _parse_cid(output)
logger.info("Container created; waiting until it is persisted in sidechain")
deadline_to_persist = 15 # seconds
for i in range(0, deadline_to_persist):
time.sleep(1)
containers = list_containers(wallet)
if cid in containers:
break
logger.info(f"There is no {cid} in {containers} yet; continue")
if i+1 == deadline_to_persist:
raise RuntimeError(
f"After {deadline_to_persist} seconds the container "
f"{cid} hasn't been persisted; exiting"
)
return cid
@keyword('List Containers')
def list_containers(wallet: str):
"""
A wrapper for `neofs-cli container list` call. It returns all the
available containers for the given wallet.
Args:
wallet (str): a wallet on whose behalf we list the containers
Returns:
(list): list of containers
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'--config {WALLET_PASS} container list'
)
output = _cmd_run(cmd)
return output.split()
@keyword('Get Container Attributes')
def get_container_attributes(wallet: str, cid: str):
"""
A wrapper for `neofs-cli container get` call. It extracts
container attributes and rearranges them to more compact view.
Args:
wallet (str): a wallet on whose behalf we get the container
cid (str): ID of the container to get
Returns:
(dict): dict of container attributes
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'--config {WALLET_PASS} --cid {cid} container get --json'
)
output = _cmd_run(cmd)
container_info = json.loads(output)
attributes = dict()
for attr in container_info['attributes']:
attributes[attr['key']] = attr['value']
return attributes
@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(wallet: str, cid: str):
"""
A wrapper for `neofs-cli container delete` call.
Args:
wallet (str): a wallet on whose behalf we delete the container
cid (str): ID of the container to delete
This function doesn't return anything.
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'--config {WALLET_PASS} container delete --cid {cid}'
)
_cmd_run(cmd)
def _parse_cid(ouptut: 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.
Args:
ouptut (str): a command run output
Returns:
(str): extracted CID
"""
try:
# taking first string from command output
fst_str = ouptut.split('\n')[0]
except Exception:
logger.error(f"Got empty output: {ouptut}")
splitted = fst_str.split(": ")
if len(splitted) != 2:
raise ValueError(f"no CID was parsed from command output: \t{fst_str}")
return splitted[1]

View file

@ -0,0 +1,21 @@
"""
A bunch of functions which might rearrange some data or
change their representation.
"""
from functools import reduce
def dict_to_attrs(attrs: dict):
'''
This function takes dictionary of object attributes and converts them
into the string. The string is passed to `--attibutes` key of the
neofs-cli.
Args:
attrs (dict): object attirbutes in {"a": "b", "c": "d"} format.
Returns:
(str): string in "a=b,c=d" format.
'''
return reduce(lambda a,b: f"{a},{b}", map(lambda i: f"{i}={attrs[i]}", attrs))

View file

@ -17,7 +17,6 @@ from robot.api.deco import keyword
from robot.api import logger
from cli_helpers import _run_with_passwd, _cmd_run
import neofs_verbs
import json_transformers
ROBOT_AUTO_KEYWORDS = False
@ -123,53 +122,6 @@ def validate_storage_policy_for_object(wallet: str, expected_copies: int, cid, o
raise Exception(f"Found node list '{found_nodes}' is not equal to expected list '{expected_node_list}'")
@keyword('Create container')
def create_container(wallet: str, basic_acl:str, rule:str, user_headers: str='', session: str=''):
if rule == "":
logger.error("Cannot create container with empty placement rule")
if basic_acl:
basic_acl = f"--basic-acl {basic_acl}"
if user_headers:
user_headers = f"--attributes {user_headers}"
if session:
session = f"--session {session}"
createContainerCmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'container create --policy "{rule}" {basic_acl} {user_headers} {session} --config {WALLET_PASS} --await'
)
output = _cmd_run(createContainerCmd)
cid = _parse_cid(output)
logger.info(f"Created container {cid} with rule {rule}")
return cid
@keyword('Container List')
def container_list(wallet: str):
Cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'container list --config {WALLET_PASS}'
)
output = _cmd_run(Cmd)
container_list = re.findall(r'(\w{43,44})', output)
logger.info(f"Containers list: {container_list}")
return container_list
@keyword('Container Existing')
def container_existing(wallet: str, cid: str):
Cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'container list --config {WALLET_PASS}'
)
output = _cmd_run(Cmd)
_find_cid(output, cid)
return
@keyword('Verify Head Tombstone')
def verify_head_tombstone(wallet: str, cid: str, oid_ts: str, oid: str, addr: str):
# TODO: replace with HEAD from neofs_verbs.py
@ -219,50 +171,6 @@ def verify_head_tombstone(wallet: str, cid: str, oid_ts: str, oid: str, addr: st
raise Exception("Header Session OID (deleted object) is not expected.")
@keyword('Get container attributes')
def get_container_attributes(wallet: str, cid: str, endpoint: str="", json_output: bool = False):
if endpoint == "":
endpoint = NEOFS_ENDPOINT
container_cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wallet {wallet} --config {WALLET_PASS} '
f'--cid {cid} container get {"--json" if json_output else ""}'
)
output = _cmd_run(container_cmd)
return output
@keyword('Decode Container Attributes Json')
def decode_container_attributes_json(header):
result_header = dict()
json_header = json.loads(header)
attributes = []
attribute_list = json_header["attributes"]
if attribute_list is not None:
for e in attribute_list:
values_list = list(e.values())
attribute = values_list[0] + '=' + values_list[1]
attributes.append(attribute)
result_header["Attributes"] = attributes
else:
raise Exception(f"no Attributes were parsed from header: \t{header}")
return result_header
@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, wallet: str):
deleteContainerCmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'container delete --cid {cid} --config {WALLET_PASS}'
)
_cmd_run(deleteContainerCmd)
@keyword('Get file hash')
def get_file_hash(filename : str):
file_hash = _get_file_hash(filename)
@ -286,6 +194,7 @@ def get_control_endpoint_with_wif(endpoint_number: str = ''):
return endpoint_num, endpoint_control, wif
@keyword('Get Locode')
def get_locode():
endpoint_values = random.choice(list(NEOFS_NETMAP_DICT.values()))
@ -438,6 +347,7 @@ def delete_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str=""):
raise Exception(f"no Tombstone ID was parsed from command output: \t{output}")
return oid
@keyword('Generate Session Token')
def generate_session_token(owner: str, pub_key: str, cid: str = "", wildcard: bool = False) -> str:
@ -497,17 +407,6 @@ def _get_file_hash(filename):
logger.info(f"Hash: {hash.hexdigest()}")
return hash.hexdigest()
def _find_cid(output: str, cid: str):
"""
This function parses CID from given CLI output.
Parameters:
- output: a string with command run output
"""
if re.search(fr'({cid})', output):
logger.info(f"CID {cid} was parsed from command output: \t{output}")
else:
raise Exception(f"no CID {cid} was parsed from command output: \t{output}")
return cid
def _parse_oid(input_str: str):
"""
@ -531,28 +430,6 @@ def _parse_oid(input_str: str):
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 _search_object(node:str, wallet: str, cid:str, oid: str):
Cmd = (

View file

@ -9,11 +9,11 @@ import os
import re
import random
import uuid
from functools import reduce
from common import NEOFS_ENDPOINT, ASSETS_DIR, NEOFS_NETMAP, WALLET_PASS
from cli_helpers import _cmd_run
import json_transformers
from data_formatters import dict_to_attrs
from robot.api.deco import keyword
from robot.api import logger
@ -108,7 +108,7 @@ def put_object(wallet: str, path: str, cid: str, bearer: str="", user_headers: d
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wallet {wallet} '
f'object put --file {path} --cid {cid} {options} --config {WALLET_PASS} '
f'{"--bearer " + bearer if bearer else ""} '
f'{"--attributes " + _dict_to_attrs(user_headers) if user_headers else ""}'
f'{"--attributes " + dict_to_attrs(user_headers) if user_headers else ""}'
)
output = _cmd_run(cmd)
# splitting CLI output to lines and taking the penultimate line
@ -282,18 +282,3 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str="",
logger.info("decoding simple header")
return json_transformers.decode_simple_header(decoded)
def _dict_to_attrs(attrs: dict):
'''
This function takes dictionary of object attributes and converts them
into the string. The string is passed to `--attibutes` key of the
neofs-cli.
Args:
attrs (dict): object attirbutes in {"a": "b", "c": "d"} format.
Returns:
(str): string in "a=b,c=d" format.
'''
return reduce(lambda a,b: f"{a},{b}", map(lambda i: f"{i}={attrs[i]}", attrs))

View file

@ -2,30 +2,23 @@
Variables common.py
Variables wellknown_acl.py
Library container.py
*** Keywords ***
Create Private Container
[Arguments] ${USER_KEY}
Log Create Private Container
${PRIV_CID_GEN} = Create container ${USER_KEY} ${PRIVATE_ACL_F} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${USER_KEY} ${PRIV_CID_GEN}
${PRIV_CID_GEN} = Create container ${USER_KEY} basic_acl=${PRIVATE_ACL_F}
[Return] ${PRIV_CID_GEN}
Create Public Container
[Arguments] ${USER_KEY}
Log Create Public Container
${PUBLIC_CID_GEN} = Create container ${USER_KEY} ${PUBLIC_ACL_F} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${USER_KEY} ${PUBLIC_CID_GEN}
${PUBLIC_CID_GEN} = Create container ${USER_KEY} basic_acl=${PUBLIC_ACL_F}
[Return] ${PUBLIC_CID_GEN}
Create Read-Only Container
[Arguments] ${USER_KEY}
Log Create Read-Only Container
${READONLY_CID_GEN} = Create container ${USER_KEY} ${READONLY_ACL_F} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${USER_KEY} ${READONLY_CID_GEN}
${READONLY_CID_GEN} = Create container ${USER_KEY} basic_acl=${READONLY_ACL_F}
[Return] ${READONLY_CID_GEN}

View file

@ -2,20 +2,18 @@
Variables common.py
Variables wellknown_acl.py
Library container.py
*** Keywords ***
Create Container Public
[Arguments] ${USER_KEY}
${PUBLIC_CID_GEN} = Create container ${USER_KEY} ${PUBLIC_ACL} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${USER_KEY} ${PUBLIC_CID_GEN}
${PUBLIC_CID_GEN} = Create container ${USER_KEY} basic_acl=${PUBLIC_ACL}
[Return] ${PUBLIC_CID_GEN}
Create Container Inaccessible
[Arguments] ${USER_KEY}
${INACCESSIBLE_CID_GEN} = Create container ${USER_KEY} ${INACCESSIBLE_ACL} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${USER_KEY} ${INACCESSIBLE_CID_GEN}
${INACCESSIBLE_CID_GEN} = Create container ${USER_KEY} basic_acl=${INACCESSIBLE_ACL}
[Return] ${INACCESSIBLE_CID_GEN}

View file

@ -3,8 +3,10 @@ Variables common.py
Variables eacl_object_filters.py
Library acl.py
Library container.py
Library neofs.py
Library neofs_verbs.py
Library Collections
Resource common_steps_acl_basic.robot
@ -21,10 +23,7 @@ ${EACL_ERR_MSG} = *
Create Container Public
[Arguments] ${WALLET}
Log Create Public Container
${PUBLIC_CID_GEN} = Create container ${WALLET} ${PUBLIC_ACL} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${PUBLIC_CID_GEN}
${PUBLIC_CID_GEN} = Create container ${WALLET} basic_acl=${PUBLIC_ACL}
[Return] ${PUBLIC_CID_GEN}
Generate files

View file

@ -1,22 +1,16 @@
*** Settings ***
Variables common.py
Library container.py
Library wallet_keywords.py
Library rpc_call_keywords.py
*** Variables ***
${PLACEMENT_RULE} = REP 2 IN X CBF 1 SELECT 2 FROM * AS X
${CONTAINER_WAIT_INTERVAL} = 1 min
*** Keywords ***
Prepare container
[Arguments] ${WIF} ${WALLET}
${NEOFS_BALANCE} = Get NeoFS Balance ${WIF}
${CID} = Create container ${WALLET} ${EMPTY} ${PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
${CID} = Create container ${WALLET}
${NEW_NEOFS_BALANCE} = Get NeoFS Balance ${WIF}
Should Be True ${NEW_NEOFS_BALANCE} < ${NEOFS_BALANCE}

View file

@ -1,15 +1,16 @@
*** Settings ***
Variables common.py
Library Collections
Library container.py
Library neofs.py
Library neofs_verbs.py
Library acl.py
Library payment_neogo.py
Library contract_keywords.py
Library wallet_keywords.py
Library Collections
Resource eacl_tables.robot
Resource common_steps_acl_bearer.robot
Resource payment_operations.robot
@ -25,7 +26,7 @@ ${DEPOSIT} = ${30}
*** Test cases ***
eACL Deny Replication Operations
[Documentation] Testcase to validate NeoFS replication with eACL deny rules.
[Tags] ACL NeoFS_CLI Replication
[Tags] ACL Replication
[Timeout] 20 min
[Setup] Setup
@ -35,15 +36,10 @@ eACL Deny Replication Operations
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
Log Check Replication with eACL deny - object should be replicated
# https://github.com/nspcc-dev/neofs-node/issues/881
${FILE} = Generate file of bytes ${SIMPLE_OBJ_SIZE}
${CID} = Create container ${WALLET} ${PUBLIC_ACL} ${FULL_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
${CID} = Create container ${WALLET} basic_acl=${PUBLIC_ACL} rule=${FULL_PLACEMENT_RULE}
Prepare eACL Role rules ${CID}
${OID} = Put object ${WALLET} ${FILE} ${CID}

View file

@ -1,6 +1,7 @@
*** Settings ***
Variables common.py
Library container.py
Library neofs.py
Library payment_neogo.py
Library String
@ -11,18 +12,16 @@ Resource payment_operations.robot
Resource 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
${CONTAINER_WAIT_INTERVAL} = 1 min
&{ATTR_TIME} = Timestamp=new
&{ATTR_NONE} = NoAttribute=
&{ATTR_SINGLE} = AttrNum=one
${ERROR_MSG} = invalid container attribute
*** Test Cases ***
Duplicated Container Attributes
[Documentation] Testcase to check duplicated container attributes.
[Tags] Container NeoFS NeoCLI
[Timeout] 10 min
[Tags] Container
[Timeout] 5 min
[Setup] Setup
@ -32,30 +31,33 @@ Duplicated Container Attributes
# Checking that container attributes cannot duplicate
######################################################
Run Keyword And Expect Error *
... Create container ${WALLET} ${EMPTY} ${POLICY} ${ATTR_TIME}
Run Keyword And Expect Error *
... Create container ${WALLET} ${EMPTY} ${POLICY} ${ATTR_DUPLICATE}
# TODO: unstable case, the behaviour needs to be defined
# https://github.com/nspcc-dev/neofs-node/issues/1339
#Run Keyword And Expect Error *
#... Create container ${WALLET} attributes=${ATTR_TIME}
${ERR} = Run Keyword And Expect Error *
... Create Container ${WALLET} options=--attributes Size=small, Size=big
Should Contain ${ERR} ${ERROR_MSG}
######################################################
# Checking that container cannot have empty attribute
######################################################
Run Keyword And Expect Error *
... Create container ${WALLET} ${EMPTY} ${POLICY} ${ATTR_NONE}
# TODO: the same unstable case, referenced in the above issue
#${ERR} = Run Keyword And Expect Error *
# ... Create Container ${WALLET} attributes=${ATTR_NONE}
# Should Contain ${ERR} ${ERROR_MSG}
#####################################################
# Checking a successful step with a single attribute
#####################################################
${CID} = Create container ${WALLET} ${EMPTY} ${POLICY} ${ATTR_SINGLE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
${ATTRIBUTES} = Get container attributes ${WALLET} ${CID} ${EMPTY} json_output=True
&{ATTRIBUTES_DICT} = Decode Container Attributes Json ${ATTRIBUTES}
List Should Contain Value
... ${ATTRIBUTES_DICT}[Attributes]
${CID} = Create Container ${WALLET} attributes=${ATTR_SINGLE}
&{ATTRIBUTES} = Get Container Attributes ${WALLET} ${CID}
Dictionary Should Contain Sub Dictionary
... ${ATTRIBUTES}
... ${ATTR_SINGLE}
... "No expected container attributes found"
... msg="No expected container attributes found"
[Teardown] Teardown container_attributes

View file

@ -1,46 +1,49 @@
*** Settings ***
Variables common.py
Variables wellknown_acl.py
Library neofs.py
Library payment_neogo.py
Library container.py
Library wallet_keywords.py
Library contract_keywords.py
Library Collections
Resource setup_teardown.robot
Resource payment_operations.robot
*** Variables ***
${CONTAINER_WAIT_INTERVAL} = 1 min
*** Test Cases ***
Delete Containers
[Documentation] Testcase to check if containers can be deleted.
[Documentation] Testcase to check if containers can be deleted by its owner only.
[Tags] Container
[Timeout] 10 min
[Timeout] 2 min
[Setup] Setup
${_} ${_} ${USER_KEY} = Prepare Wallet And Deposit
${_} ${_} ${OTHER_KEY} = Prepare Wallet And Deposit
${CID} = Create container ${USER_KEY} ${PRIVATE_ACL_F} ${COMMON_PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${USER_KEY} ${CID}
${CID} = Create container ${USER_KEY}
################################################################
# No explicit error is expected upon container deletion attempt
################################################################
Delete Container ${CID} ${OTHER_KEY}
Delete Container ${OTHER_KEY} ${CID}
Tick Epoch
Get container attributes ${USER_KEY} ${CID}
@{CONTAINERS} = List Containers ${USER_KEY}
List Should Contain Value
... ${CONTAINERS}
... ${CID}
... msg="A key which doesn't owe the container is able to delete ${CID}"
Delete Container ${CID} ${USER_KEY}
Delete Container ${USER_KEY} ${CID}
Tick Epoch
Run Keyword And Expect Error *
... Get container attributes ${USER_KEY} ${CID}
@{CONTAINERS} = List Containers ${USER_KEY}
List Should Not Contain Value
... ${CONTAINERS}
... ${CID}
... msg="${CID} is still in container list"
Log If one tries to delete an already deleted container, they should expect success.
Delete Container ${CID} ${USER_KEY}
###################################################################################
# If one tries to delete an already deleted container, they should expect success.
###################################################################################
Delete Container ${USER_KEY} ${CID}
[Teardown] Teardown container_delete

View file

@ -5,8 +5,10 @@ Variables wellknown_acl.py
Resource setup_teardown.robot
Resource payment_operations.robot
Library Process
Library container.py
Library neofs.py
Library Process
Library String
Library OperatingSystem
@ -29,14 +31,10 @@ Session Token for Container
${PUB_PART} = Get Line ${UTIL.stdout} 1
${SESSION_TOKEN} = Generate Session Token ${OWNER} ${PUB_PART} wildcard=True
Sign Session token ${SESSION_TOKEN} ${WALLET} ${SIGNED_FILE}
${CID} = Create Container ${GEN_WALLET} ${PRIVATE_ACL_F} ${COMMON_PLACEMENT_RULE} ${EMPTY} ${SIGNED_FILE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
Run Keyword And Expect Error *
... Container Existing ${GEN_WALLET} ${CID}
${CID} = Create Container ${WALLET} basic_acl=${PRIVATE_ACL_F}
... session_token=${SIGNED_FILE} session_wallet=${GEN_WALLET}
########################
# Check container owner

View file

@ -2,11 +2,12 @@
Variables common.py
Variables wellknown_acl.py
Library container.py
Library contract_keywords.py
Library neofs.py
Library neofs_verbs.py
Library payment_neogo.py
Library String
Library Process
@ -15,13 +16,9 @@ Resource payment_operations.robot
Resource storage.robot
Resource complex_object_operations.robot
*** Variables ***
${CONTAINER_WAIT_INTERVAL} = 1 min
*** Test Cases ***
Drop command in control group
[Documentation] Testcase to check drop-objects command from control group.
[Tags] NeoFSCLI
[Timeout] 10 min
[Setup] Setup
@ -35,9 +32,8 @@ Drop command in control group
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
${PRIV_CID} = Create container ${WALLET} ${PRIVATE_ACL_F} REP 1 CBF 1 SELECT 1 FROM * FILTER 'UN-LOCODE' EQ '${LOCODE}' AS LOC
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${PRIV_CID}
${PRIV_CID} = Create container ${WALLET} basic_acl=${PRIVATE_ACL_F}
... rule=REP 1 CBF 1 SELECT 1 FROM * FILTER 'UN-LOCODE' EQ '${LOCODE}' AS LOC
#########################
# Dropping simple object

View file

@ -1,6 +1,7 @@
*** Settings ***
Variables common.py
Library container.py
Library neofs.py
Library neofs_verbs.py
Library payment_neogo.py
@ -16,7 +17,7 @@ ${CONTAINER_WAIT_INTERVAL} = 1 min
*** Test cases ***
NeoFS Simple Netmap
[Documentation] Testcase to validate NeoFS Netmap.
[Tags] Netmap NeoFS NeoCLI
[Tags] Netmap
[Timeout] 20 min
[Setup] Setup
@ -24,53 +25,53 @@ NeoFS Simple Netmap
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
${FILE} = Generate file of bytes ${SIMPLE_OBJ_SIZE}
Validate Policy ${USER_WALLET} ${FILE_S} REP 2 IN X CBF 2 SELECT 2 FROM * AS X 2 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 2 IN X CBF 2 SELECT 2 FROM * AS X 2 @{EMPTY}
Validate Policy ${USER_WALLET} ${FILE_S} REP 2 IN X CBF 1 SELECT 2 FROM * AS X 2 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 2 IN X CBF 1 SELECT 2 FROM * AS X 2 @{EMPTY}
Validate Policy ${USER_WALLET} ${FILE_S} REP 3 IN X CBF 1 SELECT 3 FROM * AS X 3 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 3 IN X CBF 1 SELECT 3 FROM * AS X 3 @{EMPTY}
Validate Policy ${USER_WALLET} ${FILE_S} REP 1 IN X CBF 1 SELECT 1 FROM * AS X 1 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 1 IN X CBF 1 SELECT 1 FROM * AS X 1 @{EMPTY}
Validate Policy ${USER_WALLET} ${FILE_S} REP 1 IN X CBF 2 SELECT 1 FROM * AS X 1 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 1 IN X CBF 2 SELECT 1 FROM * AS X 1 @{EMPTY}
Validate Policy ${USER_WALLET} ${FILE_S} REP 4 IN X CBF 1 SELECT 4 FROM * AS X 4 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 4 IN X CBF 1 SELECT 4 FROM * AS X 4 @{EMPTY}
Validate Policy ${USER_WALLET} ${FILE_S} REP 2 IN X CBF 1 SELECT 4 FROM * AS X 2 @{EMPTY}
Validate Policy ${WALLET} ${FILE} REP 2 IN X CBF 1 SELECT 4 FROM * AS X 2 @{EMPTY}
@{EXPECTED} = Create List s01.neofs.devenv:8080 s02.neofs.devenv:8080 s03.neofs.devenv:8080 s04.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 4 IN X CBF 1 SELECT 4 FROM * AS X 4 @{EXPECTED}
Validate Policy ${WALLET} ${FILE} REP 4 IN X CBF 1 SELECT 4 FROM * AS X 4 @{EXPECTED}
@{EXPECTED} = Create List s03.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 1 IN LOC_PLACE CBF 1 SELECT 1 FROM LOC_SW AS LOC_PLACE FILTER Country EQ Sweden AS LOC_SW
Validate Policy ${WALLET} ${FILE} REP 1 IN LOC_PLACE CBF 1 SELECT 1 FROM LOC_SW AS LOC_PLACE FILTER Country EQ Sweden AS LOC_SW
... 1 @{EXPECTED}
@{EXPECTED} = Create List s02.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 1 CBF 1 SELECT 1 FROM LOC_SPB FILTER 'UN-LOCODE' EQ 'RU LED' AS LOC_SPB 1 @{EXPECTED}
Validate Policy ${WALLET} ${FILE} REP 1 CBF 1 SELECT 1 FROM LOC_SPB FILTER 'UN-LOCODE' EQ 'RU LED' AS LOC_SPB 1 @{EXPECTED}
@{EXPECTED} = Create List s01.neofs.devenv:8080 s02.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 1 IN LOC_SPB_PLACE REP 1 IN LOC_MSK_PLACE CBF 1 SELECT 1 FROM LOC_SPB AS LOC_SPB_PLACE SELECT 1 FROM LOC_MSK AS LOC_MSK_PLACE FILTER 'UN-LOCODE' EQ 'RU LED' AS LOC_SPB FILTER 'UN-LOCODE' EQ 'RU MOW' AS LOC_MSK
Validate Policy ${WALLET} ${FILE} REP 1 IN LOC_SPB_PLACE REP 1 IN LOC_MSK_PLACE CBF 1 SELECT 1 FROM LOC_SPB AS LOC_SPB_PLACE SELECT 1 FROM LOC_MSK AS LOC_MSK_PLACE FILTER 'UN-LOCODE' EQ 'RU LED' AS LOC_SPB FILTER 'UN-LOCODE' EQ 'RU MOW' AS LOC_MSK
... 2 @{EXPECTED}
@{EXPECTED} = Create List s01.neofs.devenv:8080 s02.neofs.devenv:8080 s03.neofs.devenv:8080 s04.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 4 CBF 1 SELECT 4 FROM LOC_EU FILTER Continent EQ Europe AS LOC_EU 4 @{EXPECTED}
Validate Policy ${WALLET} ${FILE} REP 4 CBF 1 SELECT 4 FROM LOC_EU FILTER Continent EQ Europe AS LOC_EU 4 @{EXPECTED}
@{EXPECTED} = Create List s02.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 1 CBF 1 SELECT 1 FROM LOC_SPB FILTER 'UN-LOCODE' NE 'RU MOW' AND 'UN-LOCODE' NE 'SE STO' AND 'UN-LOCODE' NE 'FI HEL' AS LOC_SPB
Validate Policy ${WALLET} ${FILE} REP 1 CBF 1 SELECT 1 FROM LOC_SPB FILTER 'UN-LOCODE' NE 'RU MOW' AND 'UN-LOCODE' NE 'SE STO' AND 'UN-LOCODE' NE 'FI HEL' AS LOC_SPB
... 1 @{EXPECTED}
@{EXPECTED} = Create List s01.neofs.devenv:8080 s02.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 2 CBF 1 SELECT 2 FROM LOC_RU FILTER SubDivCode NE 'AB' AND SubDivCode NE '18' AS LOC_RU 2 @{EXPECTED}
Validate Policy ${WALLET} ${FILE} REP 2 CBF 1 SELECT 2 FROM LOC_RU FILTER SubDivCode NE 'AB' AND SubDivCode NE '18' AS LOC_RU 2 @{EXPECTED}
@{EXPECTED} = Create List s01.neofs.devenv:8080 s02.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 2 CBF 1 SELECT 2 FROM LOC_RU FILTER Country EQ 'Russia' AS LOC_RU 2 @{EXPECTED}
Validate Policy ${WALLET} ${FILE} REP 2 CBF 1 SELECT 2 FROM LOC_RU FILTER Country EQ 'Russia' AS LOC_RU 2 @{EXPECTED}
@{EXPECTED} = Create List s03.neofs.devenv:8080 s04.neofs.devenv:8080
Validate Policy ${USER_WALLET} ${FILE_S} REP 2 CBF 1 SELECT 2 FROM LOC_EU FILTER Country NE 'Russia' AS LOC_EU 2 @{EXPECTED}
Validate Policy ${WALLET} ${FILE} REP 2 CBF 1 SELECT 2 FROM LOC_EU FILTER Country NE 'Russia' AS LOC_EU 2 @{EXPECTED}
Log Put operation should be failed with error "not enough nodes to SELECT from: 'X'"
Run Keyword And Expect Error *
... Validate Policy ${USER_WALLET} ${FILE_S} REP 2 IN X CBF 2 SELECT 6 FROM * AS X 2 @{EMPTY}
... Validate Policy ${WALLET} ${FILE} REP 2 IN X CBF 2 SELECT 6 FROM * AS X 2 @{EMPTY}
[Teardown] Teardown netmap_simple
@ -81,9 +82,7 @@ Validate Policy
Log Container with rule ${POLICY}
${CID} = Create container ${WALLET} ${EMPTY} ${POLICY}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
${CID} = Create container ${WALLET} rule=${POLICY}
${S_OID} = Put object ${WALLET} ${FILE} ${CID}
Validate storage policy for object ${WALLET} ${EXPECTED_VAL} ${CID} ${S_OID} ${EXPECTED_LIST}
Get object ${WALLET} ${CID} ${S_OID} ${EMPTY} s_file_read

View file

@ -2,7 +2,7 @@
Variables common.py
Variables wellknown_acl.py
Library Collections
Library container.py
Library payment_neogo.py
Library neofs.py
Library neofs_verbs.py
@ -10,19 +10,19 @@ Library wallet_keywords.py
Library rpc_call_keywords.py
Library contract_keywords.py
Library Collections
Resource payment_operations.robot
Resource setup_teardown.robot
*** Variables ***
${PLACEMENT_RULE} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X
${EXPECTED_COPIES} = ${2}
${CHECK_INTERVAL} = 1 min
${CONTAINER_WAIT_INTERVAL} = 1 min
*** Test cases ***
NeoFS Object Replication
[Documentation] Testcase to validate NeoFS object replication.
[Tags] Migration Replication NeoFS NeoCLI
[Tags] Migration Replication
[Timeout] 25 min
[Setup] Setup
@ -39,9 +39,7 @@ Check Replication
[Arguments] ${ACL}
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
${CID} = Create Container ${WALLET} ${ACL} ${PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
${CID} = Create Container ${WALLET} basic_acl=${ACL}
${FILE} = Generate file of bytes ${SIMPLE_OBJ_SIZE}
${FILE_HASH} = Get file hash ${FILE}

View file

@ -2,6 +2,7 @@
Variables common.py
Variables wellknown_acl.py
Library container.py
Library neofs.py
Library neofs_verbs.py
Library payment_neogo.py
@ -12,7 +13,6 @@ Resource setup_teardown.robot
Resource 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=''
@ -22,14 +22,14 @@ ${ATTR_DUPLICATE} = FileType=jpg,FileType=png
Duplicated Object Attributes
[Documentation] Testcase to check duplicated attributes.
[Tags] Object NeoFS NeoCLI
[Tags] Object
[Timeout] 10 min
[Setup] Setup
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
${PUBLIC_CID} = Create container ${WALLET} ${PUBLIC_ACL_F} ${POLICY} ${EMPTY}
${PUBLIC_CID} = Create Container ${WALLET} basic_acl=${PUBLIC_ACL_F}
${FILE_S} = Generate file of bytes ${SIMPLE_OBJ_SIZE}

View file

@ -2,6 +2,7 @@
Variables common.py
Variables wellknown_acl.py
Library container.py
Library neofs.py
Library neofs_verbs.py
Library http_gate.py
@ -11,7 +12,6 @@ Resource setup_teardown.robot
*** Variables ***
${PLACEMENT_RULE} = REP 1 IN X CBF 1 SELECT 1 FROM * AS X
${CONTAINER_WAIT_INTERVAL} = 1 min
@{INCLUDE_SVC} = http_gate
*** Test cases ***
@ -24,11 +24,7 @@ NeoFS HTTP Gateway
Make Up ${INCLUDE_SVC}
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
${CID} = Create container ${WALLET} ${PUBLIC_ACL} ${PLACEMENT_RULE}
Wait Until Keyword Succeeds ${MORPH_BLOCK_TIME} ${CONTAINER_WAIT_INTERVAL}
... Container Existing ${WALLET} ${CID}
${CID} = Create container ${WALLET} rule=${PLACEMENT_RULE} basic_acl=${PUBLIC_ACL}
${FILE} = Generate file of bytes ${SIMPLE_OBJ_SIZE}
${FILE_L} = Generate file of bytes ${COMPLEX_OBJ_SIZE}
${FILE_HASH} = Get file hash ${FILE}

View file

@ -4,6 +4,7 @@ Variables common.py
Library Collections
Library OperatingSystem
Library container.py
Library neofs.py
Library s3_gate.py
Library contract_keywords.py
@ -35,8 +36,8 @@ Objects in NeoFS S3 Gateway
... ${SEC_ACCESS_KEY}
... ${OWNER_PRIV_KEY} = Init S3 Credentials ${WALLET}
${CONTEINERS_LIST} = Container List ${WALLET}
List Should Contain Value ${CONTEINERS_LIST} ${CID}
@{CONTAINERS_LIST} = List Containers ${WALLET}
List Should Contain Value ${CONTAINERS_LIST} ${CID}
${S3_CLIENT} = Config S3 client ${ACCESS_KEY_ID} ${SEC_ACCESS_KEY}