Testcases to cover S3 in the smoke test and updates in accordance with NeoFS 0.13.0 have been updated (#5)

* Coverage of the S3 gateway and "S3-gate - NeoFS - HTTP-gate" interaction has been added to the Selectel smoke test.
This commit is contained in:
anatoly-bogatyrev 2020-12-16 14:19:24 +03:00 committed by GitHub
parent a20ec58614
commit bb3c2bd208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 259 additions and 162 deletions

View file

@ -9,13 +9,16 @@ import hashlib
from robot.api.deco import keyword
from robot.api import logger
import random
import base64
import base58
import docker
if os.getenv('ROBOT_PROFILE') == 'selectel_smoke':
from selectelcdn_smoke_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT)
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT, NEOFS_NETMAP)
else:
from neofs_int_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT)
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT, NEOFS_NETMAP)
ROBOT_AUTO_KEYWORDS = False
@ -64,22 +67,13 @@ def stop_nodes(down_num: int, *nodes_list):
# select nodes to stop from list
stop_nodes = random.sample(nodes_list, down_num)
for node in stop_nodes:
m = re.search(r'(s\d+).', node)
node = m.group(1)
Cmd = f'docker stop {node}'
logger.info("Cmd: %s" % Cmd)
try:
complProc = subprocess.run(Cmd, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=150, shell=True)
output = complProc.stdout
logger.info("Output: %s" % output)
except subprocess.CalledProcessError as e:
raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
client = docker.APIClient()
client.stop(node)
return stop_nodes
@ -90,20 +84,9 @@ def start_nodes(*nodes_list):
for node in nodes_list:
m = re.search(r'(s\d+).', node)
node = m.group(1)
Cmd = f'docker start {node}'
logger.info("Cmd: %s" % Cmd)
try:
complProc = subprocess.run(Cmd, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=150, shell=True)
output = complProc.stdout
logger.info("Output: %s" % output)
except subprocess.CalledProcessError as e:
raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
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(private_key)
@ -205,6 +188,10 @@ def form_bearertoken_file_for_all_ops(file_name: str, private_key: str, cid: str
eacl = get_eacl(private_key, cid)
input_records = ""
cid_base58_b = base58.b58decode(cid)
cid_base64 = base64.b64encode(cid_base58_b).decode("utf-8")
if eacl:
res_json = re.split(r'[\s\n]+\][\s\n]+\}[\s\n]+Signature:', eacl)
records = re.split(r'"records": \[', res_json[0])
@ -215,7 +202,7 @@ def form_bearertoken_file_for_all_ops(file_name: str, private_key: str, cid: str
"body": {
"eaclTable": {
"containerID": {
"value": \"""" + cid + """"
"value": \"""" + str(cid_base64) + """"
},
"records": [
{
@ -317,6 +304,10 @@ def form_bearertoken_file_filter_for_all_ops(file_name: str, private_key: str, c
# SEARCH should be allowed without filters to use GET, HEAD, DELETE, and SEARCH? Need to clarify.
eacl = get_eacl(private_key, cid)
cid_base58_b = base58.b58decode(cid)
cid_base64 = base64.b64encode(cid_base58_b).decode("utf-8")
input_records = ""
if eacl:
res_json = re.split(r'[\s\n]+\][\s\n]+\}[\s\n]+Signature:', eacl)
@ -328,7 +319,7 @@ def form_bearertoken_file_filter_for_all_ops(file_name: str, private_key: str, c
"body": {
"eaclTable": {
"containerID": {
"value": \"""" + cid + """"
"value": \"""" + str(cid_base64) + """"
},
"records": [
{
@ -535,7 +526,7 @@ def create_container(private_key: str, basic_acl:str="", rule:str="REP 2 IN X CB
createContainerCmd = f'neofs-cli --rpc-endpoint {NEOFS_ENDPOINT} --key {private_key} container create --policy "{rule}" {basic_acl} --await'
logger.info("Cmd: %s" % createContainerCmd)
complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=150, shell=True)
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=300, shell=True)
output = complProc.stdout
logger.info("Output: %s" % output)
cid = _parse_cid(output)
@ -816,9 +807,10 @@ def delete_object(private_key: str, cid: str, oid: str, bearer: str):
bearer_token = f"--bearer {bearer}"
ObjectCmd = f'neofs-cli --rpc-endpoint {NEOFS_ENDPOINT} --key {private_key} object delete --cid {cid} --oid {oid} {bearer_token}'
logger.info("Cmd: %s" % ObjectCmd)
try:
complProc = subprocess.run(ObjectCmd, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True)
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30, shell=True)
logger.info("Output: %s" % complProc.stdout)
except subprocess.CalledProcessError as e:
raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
@ -995,7 +987,7 @@ def _parse_cid(output: str):
return cid
def _get_storage_nodes(private_key: bytes):
storage_nodes = ['s01.neofs.devenv:8080', 's02.neofs.devenv:8080','s03.neofs.devenv:8080','s04.neofs.devenv:8080']
#storage_nodes = ['s01.neofs.devenv:8080', 's02.neofs.devenv:8080','s03.neofs.devenv:8080','s04.neofs.devenv:8080']
#NetmapCmd = f'{CLI_PREFIX}neofs-cli --host {NEOFS_ENDPOINT} --key {binascii.hexlify(private_key).decode()} status netmap'
#complProc = subprocess.run(NetmapCmd, check=True, universal_newlines=True,
# stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True)
@ -1011,8 +1003,8 @@ def _get_storage_nodes(private_key: bytes):
# Will be fixed when netmap will be added to cli
#storage_nodes.append()
logger.info("Storage nodes: %s" % storage_nodes)
return storage_nodes
logger.info("Storage nodes: %s" % NEOFS_NETMAP)
return NEOFS_NETMAP
def _search_object(node:str, private_key: str, cid:str, oid: str):