(#93) Add netmap_control.robot; fix resources for netmap tets; remove _get_storage_nodes

Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
This commit is contained in:
Elizaveta Chichindaeva 2021-09-09 11:13:37 +03:00
parent 92488f0bec
commit 636eb65e5c
3 changed files with 96 additions and 18 deletions

View file

@ -55,15 +55,15 @@ def start_nodes(*nodes_list):
node = m.group(1)
client = docker.APIClient()
client.start(node)
@keyword('Get nodes with object')
def get_nodes_with_object(private_key: str, cid: str, oid: str):
storage_nodes = _get_storage_nodes()
copies = 0
nodes_list = []
for node in storage_nodes:
for node in NEOFS_NETMAP:
search_res = _search_object(node, private_key, cid, oid)
if search_res:
if re.search(fr'({oid})', search_res):
@ -75,12 +75,11 @@ def get_nodes_with_object(private_key: str, cid: str, oid: str):
@keyword('Get nodes without object')
def get_nodes_without_object(private_key: str, cid: str, oid: str):
storage_nodes = _get_storage_nodes()
copies = 0
nodes_list = []
for node in storage_nodes:
for node in NEOFS_NETMAP:
search_res = _search_object(node, private_key, cid, oid)
if search_res:
if not re.search(fr'({oid})', search_res):
@ -95,7 +94,7 @@ def get_nodes_without_object(private_key: str, cid: str, oid: str):
@keyword('Validate storage policy for object')
def validate_storage_policy_for_object(private_key: str, expected_copies: int, cid, oid,
expected_node_list=[], storage_nodes=[]):
storage_nodes = storage_nodes if len(storage_nodes) != 0 else _get_storage_nodes()
storage_nodes = storage_nodes if len(storage_nodes) != 0 else NEOFS_NETMAP
copies = 0
found_nodes = []
@ -222,8 +221,7 @@ def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: s
def get_component_objects(private_key: str, cid: str, oid: str):
logger.info("Collect Split objects list from Linked object.")
split_id = ""
nodes = _get_storage_nodes()
for node in nodes:
for node in NEOFS_NETMAP:
try:
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
if header_virtual:
@ -271,8 +269,7 @@ def verify_split_chain(private_key: str, cid: str, oid: str):
# Get Latest object
logger.info("Collect Split objects information and verify chain of the objects.")
nodes = _get_storage_nodes()
for node in nodes:
for node in NEOFS_NETMAP:
try:
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
@ -730,7 +727,7 @@ def put_object(private_key: str, path: str, cid: str, bearer: str, user_headers:
logger.info("Going to put the object")
if not endpoint:
endpoint = random.sample(_get_storage_nodes(), 1)[0]
endpoint = random.sample(NEOFS_NETMAP, 1)[0]
if user_headers:
user_headers = f"--attributes {user_headers}"
@ -748,18 +745,35 @@ def put_object(private_key: str, path: str, cid: str, bearer: str, user_headers:
return oid
@keyword('Get control endpoint with wif')
def get_control_endpoint_with_wif(endpoint_number: str = ''):
if endpoint_number == '':
netmap = []
for key in NEOFS_NETMAP_DICT.keys():
netmap.append(key)
endpoint_num = random.sample(netmap, 1)[0]
logger.info(f'Random node chosen: {endpoint_num}')
else:
endpoint_num = endpoint_number
endpoint_values = NEOFS_NETMAP_DICT[f'{endpoint_num}']
endpoint_control = endpoint_values['control']
wif = endpoint_values['wif']
return endpoint_num, endpoint_control, wif
@keyword('Get Nodes Log Latest Timestamp')
def get_logs_latest_timestamp():
"""
Keyword return:
nodes_logs_time -- structure (dict) of nodes container name (key) and latest logs timestamp (value)
"""
nodes = _get_storage_nodes()
client_api = docker.APIClient()
nodes_logs_time = dict()
for node in nodes:
for node in NEOFS_NETMAP:
container = node.split('.')[0]
log_line = client_api.logs(container, tail=1)
@ -832,7 +846,7 @@ def get_object(private_key: str, cid: str, oid: str, bearer_token: str,
logger.info("Going to get the object")
if not endpoint:
endpoint = random.sample(_get_storage_nodes(), 1)[0]
endpoint = random.sample(NEOFS_NETMAP, 1)[0]
if bearer_token:
@ -1003,10 +1017,6 @@ def _parse_cid(input_str: str):
raise Exception(f"no CID was parsed from command output: \t{fst_str}")
return splitted[1]
def _get_storage_nodes():
# TODO: fix to get netmap from neofs-cli
logger.info(f"Storage nodes: {NEOFS_NETMAP}")
return NEOFS_NETMAP
def _search_object(node:str, private_key: str, cid:str, oid: str):
if oid:

View file

@ -0,0 +1,54 @@
*** Settings ***
Variables ../../../variables/common.py
Library Process
Library contract_keywords.py
Library neofs.py
Library String
Library acl.py
Resource setup_teardown.robot
Resource payment_operations.robot
*** Test Cases ***
Control Operations with storage nodes
[Documentation] Testcase to check NetworkInfo control command.
[Tags] NeoFSCLI NetworkInfo
[Timeout] 5 min
[Setup] Setup
${NODE_NUM} ${NODE} ${WIF} = Get control endpoint with wif
${empty_list} = Create List
${SNAPSHOT} = Run Process neofs-cli control netmap-snapshot -r ${NODE} --wif ${WIF} shell=True
${HEALTHCHECK} = Run Process neofs-cli control healthcheck -r ${NODE} --wif ${WIF} shell=True
Should Be Equal As Integers ${HEALTHCHECK.rc} 0
Run Process neofs-cli control set-status -r ${NODE} --wif ${WIF} --status 'offline' shell=True
Sleep ${MAINNET_BLOCK_TIME}
Tick Epoch
${SNAPSHOT_OFFLINE}= Run Process neofs-cli control netmap-snapshot -r ${NODE} --wif ${WIF} shell=True
${NODE_NUM_OFFLINE}= Get Regexp Matches ${SNAPSHOT_OFFLINE.stdout} ${NODE_NUM}
Should Be Equal ${NODE_NUM_OFFLINE} ${empty_list}
${HEALTHCHECK_OFFLINE} = Run Process neofs-cli control healthcheck -r ${NODE} --wif ${WIF} shell=True
Should Be Equal As Integers ${HEALTHCHECK_OFFLINE.rc} 0
Should Not Be Equal ${HEALTHCHECK.stdout} ${HEALTHCHECK_OFFLINE.stdout}
Run Process neofs-cli control set-status -r ${NODE} --wif ${WIF} --status 'online' shell=True
Sleep ${MAINNET_BLOCK_TIME}
Tick Epoch
${SNAPSHOT_ONLINE} = Run Process neofs-cli control netmap-snapshot -r ${NODE} --wif ${WIF} shell=True
${NODE_NUM_ONLINE} = Get Regexp Matches ${SNAPSHOT_ONLINE.stdout} ${NODE_NUM}
Should Be Equal ${NODE_NUM_ONLINE}[0] ${NODE_NUM}
${HEALTHCHECK_ONLINE} = Run Process neofs-cli control healthcheck -r ${NODE} --wif ${WIF} shell=True
Should Be Equal As Integers ${HEALTHCHECK_ONLINE.rc} 0
Should Be Equal ${HEALTHCHECK.stdout} ${HEALTHCHECK_ONLINE.stdout}
[Teardown] Teardown netmap_control

View file

@ -30,7 +30,6 @@ NEO_MAINNET_ENDPOINT = os.getenv("NEO_MAINNET_ENDPOINT", 'http://main_chain.neof
NEOFS_NEO_API_ENDPOINT = os.getenv("NEOFS_NEO_API_ENDPOINT", 'http://morph_chain.neofs.devenv:30333')
HTTP_GATE = os.getenv("HTTP_GATE", 'http://http.neofs.devenv')
S3_GATE = os.getenv("S3_GATE", 'https://s3.neofs.devenv:8080')
NEOFS_NETMAP = os.getenv("NEOFS_NETMAP", ['s01.neofs.devenv:8080', 's02.neofs.devenv:8080','s03.neofs.devenv:8080','s04.neofs.devenv:8080'])
GAS_HASH = '0xd2a4cff31913016155e38e474a2c06d08be276cf'
NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT")
@ -42,3 +41,18 @@ ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/")
MORPH_MAGIC = os.environ["MORPH_MAGIC"]
GATE_PUB_KEY = '0313b1ac3a8076e155a7e797b24f0b650cccad5941ea59d7cfd51a024a8b2a06bf'
NEOFS_NETMAP_DICT = {'s01': {'rpc': 's01.neofs.devenv:8080',
'control': 's01.neofs.devenv:8081',
'wif': 'Kwk6k2eC3L3QuPvD8aiaNyoSXgQ2YL1bwS5CP1oKoA9waeAze97s'},
's02': {'rpc': 's02.neofs.devenv:8080',
'control': 's02.neofs.devenv:8081',
'wif': 'L1NdHdnrTNGQZH1fJSrdUZJyeYFHvaQSSHZHxhK3udiGFdr5YaZ6'},
's03': {'rpc': 's03.neofs.devenv:8080',
'control': 's03.neofs.devenv:8081',
'wif': 'KzN38k39af6ACWJjK8YrnARWo86ddcc1EuBWz7xFEdcELcP3ZTym'},
's04': {'rpc': 's04.neofs.devenv:8080',
'control': 's04.neofs.devenv:8081',
'wif': 'Kzk1Z3dowAqfNyjqeYKWenZMduFV3NAKgXg9K1sA4jRKYxEc8HEW'}
}
NEOFS_NETMAP = [i['rpc'] for i in NEOFS_NETMAP_DICT.values()]