forked from TrueCloudLab/frostfs-testcases
Some linter fixes.
Signed-off-by: a.y.volkov <a.y.volkov@yadro.com>
This commit is contained in:
parent
e086d0d62b
commit
0e27ea02c1
19 changed files with 291 additions and 275 deletions
|
@ -1,34 +1,34 @@
|
|||
#!/usr/bin/python3.8
|
||||
|
||||
from enum import Enum, auto
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
from enum import Enum, auto
|
||||
|
||||
import base64
|
||||
import base58
|
||||
from cli_helpers import _cmd_run
|
||||
from common import ASSETS_DIR, NEOFS_ENDPOINT, WALLET_PASS
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
|
||||
from robot.api.deco import keyword
|
||||
|
||||
"""
|
||||
Robot Keywords and helper functions for work with NeoFS ACL.
|
||||
"""
|
||||
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
# path to neofs-cli executable
|
||||
NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
|
||||
EACL_LIFETIME = 100500
|
||||
|
||||
|
||||
class AutoName(Enum):
|
||||
def _generate_next_value_(name, start, count, last_values):
|
||||
return name
|
||||
|
||||
|
||||
class Role(AutoName):
|
||||
USER = auto()
|
||||
SYSTEM = auto()
|
||||
|
@ -65,12 +65,13 @@ def _encode_cid_for_eacl(cid: str) -> str:
|
|||
cid_base58 = base58.b58decode(cid)
|
||||
return base64.b64encode(cid_base58).decode("utf-8")
|
||||
|
||||
|
||||
@keyword('Create eACL')
|
||||
def create_eacl(cid: str, rules_list: list):
|
||||
table = f"{os.getcwd()}/{ASSETS_DIR}/eacl_table_{str(uuid.uuid4())}.json"
|
||||
rules = ""
|
||||
for rule in rules_list:
|
||||
# TODO: check if $Object: is still necessary for filtering in the newest releases
|
||||
# TODO: check if $Object: is still necessary for filtering in the newest releases
|
||||
rules += f"--rule '{rule}' "
|
||||
cmd = (
|
||||
f"{NEOFS_CLI_EXEC} acl extended create --cid {cid} "
|
||||
|
@ -119,7 +120,7 @@ def form_bearertoken_file(wif: str, cid: str, eacl_records: list) -> str:
|
|||
}
|
||||
|
||||
if not eacl_records:
|
||||
raise(f"Got empty eacl_records list: {eacl_records}")
|
||||
raise (f"Got empty eacl_records list: {eacl_records}")
|
||||
for record in eacl_records:
|
||||
op_data = {
|
||||
"operation": record['Operation'],
|
||||
|
@ -137,7 +138,7 @@ def form_bearertoken_file(wif: str, cid: str, eacl_records: list) -> str:
|
|||
else:
|
||||
op_data['targets'] = [
|
||||
{
|
||||
"keys": [ record['Role'] ]
|
||||
"keys": [record['Role']]
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ and other CLIs.
|
|||
"""
|
||||
|
||||
import subprocess
|
||||
import pexpect
|
||||
|
||||
import pexpect
|
||||
from robot.api import logger
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
@ -35,6 +35,7 @@ def _cmd_run(cmd, timeout=30):
|
|||
f"{exc.output.decode('utf-8') if type(exc.output) is bytes else exc.output}")
|
||||
raise
|
||||
|
||||
|
||||
def _run_with_passwd(cmd):
|
||||
child = pexpect.spawn(cmd)
|
||||
child.expect(".*")
|
||||
|
|
|
@ -6,6 +6,7 @@ from robot.api.deco import keyword
|
|||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
@keyword('Run Process And Enter Empty Password')
|
||||
def run_proccess_and_interact(cmd: str) -> str:
|
||||
p = pexpect.spawn(cmd)
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
first non-null response.
|
||||
"""
|
||||
|
||||
from common import NEOFS_NETMAP
|
||||
import neofs_verbs
|
||||
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
|
||||
import neofs_verbs
|
||||
from common import NEOFS_NETMAP
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
@keyword('Get Link Object')
|
||||
def get_link_object(wallet: str, cid: str, oid: str, bearer_token: str=""):
|
||||
def get_link_object(wallet: str, cid: str, oid: str, bearer_token: str = ""):
|
||||
"""
|
||||
Args:
|
||||
wallet (str): path to the wallet on whose behalf the Storage Nodes
|
||||
|
|
|
@ -8,22 +8,21 @@
|
|||
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
|
||||
import json_transformers
|
||||
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
|
||||
import json_transformers
|
||||
from cli_helpers import _cmd_run
|
||||
from common import NEOFS_ENDPOINT, COMMON_PLACEMENT_RULE, NEOFS_CLI_EXEC, WALLET_PASS
|
||||
from data_formatters import dict_to_attrs
|
||||
|
||||
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=''):
|
||||
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.
|
||||
|
||||
|
@ -65,7 +64,7 @@ def create_container(wallet: str, rule: str=COMMON_PLACEMENT_RULE, basic_acl: st
|
|||
if cid in containers:
|
||||
break
|
||||
logger.info(f"There is no {cid} in {containers} yet; continue")
|
||||
if i+1 == deadline_to_persist:
|
||||
if i + 1 == deadline_to_persist:
|
||||
raise RuntimeError(
|
||||
f"After {deadline_to_persist} seconds the container "
|
||||
f"{cid} hasn't been persisted; exiting"
|
||||
|
|
|
@ -7,15 +7,15 @@ 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
|
||||
into the string. The string is passed to `--attributes` key of the
|
||||
neofs-cli.
|
||||
|
||||
Args:
|
||||
attrs (dict): object attirbutes in {"a": "b", "c": "d"} format.
|
||||
attrs (dict): object attributes 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))
|
||||
"""
|
||||
return reduce(lambda a, b: f"{a},{b}", map(lambda i: f"{i}={attrs[i]}", attrs))
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
import shutil
|
||||
|
||||
import requests
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
|
||||
from common import HTTP_GATE
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
ASSETS_DIR = BuiltIn().get_variable_value("${ASSETS_DIR}")
|
||||
|
||||
|
||||
@keyword('Get via HTTP Gate')
|
||||
def get_via_http_gate(cid: str, oid: str):
|
||||
"""
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
'''
|
||||
"""
|
||||
When doing requests to NeoFS, we get JSON output as an automatically decoded
|
||||
structure from protobuf. Some fields are decoded with boilerplates and binary
|
||||
values are Base64-encoded.
|
||||
|
||||
This module contains functions which rearrange the structure and reencode binary
|
||||
data from Base64 to Base58.
|
||||
'''
|
||||
|
||||
"""
|
||||
|
||||
import base64
|
||||
|
||||
import base58
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
def decode_simple_header(data: dict):
|
||||
'''
|
||||
"""
|
||||
This function reencodes Simple Object header and its attributes.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
data = decode_common_fields(data)
|
||||
|
||||
|
@ -34,12 +35,12 @@ def decode_simple_header(data: dict):
|
|||
|
||||
|
||||
def decode_split_header(data: dict):
|
||||
'''
|
||||
"""
|
||||
This function rearranges Complex Object header.
|
||||
The header holds SplitID, a random unique
|
||||
number, which is common among all splitted objects, and IDs of the Linking
|
||||
Object and the last splitted Object.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
data["splitId"] = json_reencode(data["splitId"])
|
||||
data["lastPart"] = (
|
||||
|
@ -55,11 +56,12 @@ def decode_split_header(data: dict):
|
|||
|
||||
return data
|
||||
|
||||
|
||||
def decode_linking_object(data: dict):
|
||||
'''
|
||||
"""
|
||||
This function reencodes Linking Object header.
|
||||
It contains IDs of child Objects and Split Chain data.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
data = decode_simple_header(data)
|
||||
# reencoding Child Object IDs
|
||||
|
@ -82,9 +84,9 @@ def decode_linking_object(data: dict):
|
|||
|
||||
|
||||
def decode_storage_group(data: dict):
|
||||
'''
|
||||
"""
|
||||
This function reencodes Storage Group header.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
data = decode_common_fields(data)
|
||||
except Exception as exc:
|
||||
|
@ -92,10 +94,11 @@ def decode_storage_group(data: dict):
|
|||
|
||||
return data
|
||||
|
||||
|
||||
def decode_tombstone(data: dict):
|
||||
'''
|
||||
"""
|
||||
This function reencodes Tombstone header.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
data = decode_simple_header(data)
|
||||
data['header']['sessionToken'] = decode_session_token(
|
||||
|
@ -106,39 +109,41 @@ def decode_tombstone(data: dict):
|
|||
|
||||
|
||||
def decode_session_token(data: dict):
|
||||
'''
|
||||
"""
|
||||
This function reencodes a fragment of header which contains
|
||||
information about session token.
|
||||
'''
|
||||
"""
|
||||
data['body']['object']['address']['containerID'] = json_reencode(
|
||||
data['body']['object']['address']['containerID']['value'])
|
||||
data['body']['object']['address']['objectID'] = json_reencode(
|
||||
data['body']['object']['address']['objectID']['value'])
|
||||
return data
|
||||
|
||||
|
||||
def json_reencode(data: str):
|
||||
'''
|
||||
"""
|
||||
According to JSON protocol, binary data (Object/Container/Storage Group IDs, etc)
|
||||
is converted to string via Base58 encoder. But we usually operate with Base64-encoded
|
||||
format.
|
||||
This function reencodes given Base58 string into the Base64 one.
|
||||
'''
|
||||
"""
|
||||
return base58.b58encode(base64.b64decode(data)).decode("utf-8")
|
||||
|
||||
|
||||
def encode_for_json(data: str):
|
||||
'''
|
||||
"""
|
||||
This function encodes binary data for sending them as protobuf
|
||||
structures.
|
||||
'''
|
||||
"""
|
||||
return base64.b64encode(base58.b58decode(data)).decode('utf-8')
|
||||
|
||||
|
||||
def decode_common_fields(data: dict):
|
||||
'''
|
||||
"""
|
||||
Despite of type (simple/complex Object, Storage Group, etc) every Object
|
||||
header contains several common fields.
|
||||
This function rearranges these fields.
|
||||
'''
|
||||
"""
|
||||
# reencoding binary IDs
|
||||
data["objectID"] = json_reencode(data["objectID"]["value"])
|
||||
data["header"]["containerID"] = json_reencode(data["header"]["containerID"]["value"])
|
||||
|
|
|
@ -5,12 +5,13 @@ import os
|
|||
import random
|
||||
|
||||
from neo3 import wallet
|
||||
from common import NEOFS_NETMAP_DICT
|
||||
import neofs_verbs
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
|
||||
import neofs_verbs
|
||||
from common import NEOFS_NETMAP_DICT
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
# path to neofs-cli executable
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import random
|
||||
import re
|
||||
import uuid
|
||||
|
||||
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
|
||||
from robot.api.deco import keyword
|
||||
|
||||
import json_transformers
|
||||
from cli_helpers import _cmd_run
|
||||
from common import NEOFS_ENDPOINT, ASSETS_DIR, NEOFS_NETMAP, WALLET_PASS
|
||||
from data_formatters import dict_to_attrs
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
@ -25,9 +25,9 @@ NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
|
|||
|
||||
|
||||
@keyword('Get object')
|
||||
def get_object(wallet: str, cid: str, oid: str, bearer_token: str="",
|
||||
write_object: str="", endpoint: str="", options: str="" ):
|
||||
'''
|
||||
def get_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
|
||||
write_object: str = "", endpoint: str = "", options: str = ""):
|
||||
"""
|
||||
GET from NeoFS.
|
||||
|
||||
Args:
|
||||
|
@ -40,7 +40,7 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: str="",
|
|||
options (optional, str): any options which `neofs-cli object get` accepts
|
||||
Returns:
|
||||
(str): path to downloaded file
|
||||
'''
|
||||
"""
|
||||
|
||||
if not write_object:
|
||||
write_object = str(uuid.uuid4())
|
||||
|
@ -62,8 +62,8 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: str="",
|
|||
# TODO: make `bearer_token` optional
|
||||
@keyword('Get Range Hash')
|
||||
def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut: str,
|
||||
options: str=""):
|
||||
'''
|
||||
options: str = ""):
|
||||
"""
|
||||
GETRANGEHASH of given Object.
|
||||
|
||||
Args:
|
||||
|
@ -76,7 +76,7 @@ def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut
|
|||
options (optional, str): any options which `neofs-cli object hash` accepts
|
||||
Returns:
|
||||
None
|
||||
'''
|
||||
"""
|
||||
cmd = (
|
||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
|
||||
f'object hash --cid {cid} --oid {oid} --range {range_cut} --config {WALLET_PASS} '
|
||||
|
@ -89,9 +89,9 @@ def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut
|
|||
|
||||
|
||||
@keyword('Put object')
|
||||
def put_object(wallet: str, path: str, cid: str, bearer: str="", user_headers: dict={},
|
||||
endpoint: str="", options: str="" ):
|
||||
'''
|
||||
def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers: dict = {},
|
||||
endpoint: str = "", options: str = ""):
|
||||
"""
|
||||
PUT of given file.
|
||||
|
||||
Args:
|
||||
|
@ -104,7 +104,7 @@ def put_object(wallet: str, path: str, cid: str, bearer: str="", user_headers: d
|
|||
options (optional, str): any options which `neofs-cli object put` accepts
|
||||
Returns:
|
||||
(str): ID of uploaded Object
|
||||
'''
|
||||
"""
|
||||
if not endpoint:
|
||||
endpoint = random.sample(NEOFS_NETMAP, 1)[0]
|
||||
cmd = (
|
||||
|
@ -121,8 +121,8 @@ def put_object(wallet: str, path: str, cid: str, bearer: str="", user_headers: d
|
|||
|
||||
|
||||
@keyword('Delete object')
|
||||
def delete_object(wallet: str, cid: str, oid: str, bearer: str="", options: str=""):
|
||||
'''
|
||||
def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", options: str = ""):
|
||||
"""
|
||||
DELETE an Object.
|
||||
|
||||
Args:
|
||||
|
@ -133,7 +133,7 @@ def delete_object(wallet: str, cid: str, oid: str, bearer: str="", options: str=
|
|||
options (optional, str): any options which `neofs-cli object delete` accepts
|
||||
Returns:
|
||||
(str): Tombstone ID
|
||||
'''
|
||||
"""
|
||||
cmd = (
|
||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
|
||||
f'object delete --cid {cid} --oid {oid} {options} --config {WALLET_PASS} '
|
||||
|
@ -149,20 +149,21 @@ def delete_object(wallet: str, cid: str, oid: str, bearer: str="", options: str=
|
|||
# TODO: make `bearer` an optional parameter
|
||||
@keyword('Get Range')
|
||||
def get_range(wallet: str, cid: str, oid: str, file_path: str, bearer: str, range_cut: str,
|
||||
options:str=""):
|
||||
'''
|
||||
options: str = ""):
|
||||
"""
|
||||
GETRANGE an Object.
|
||||
|
||||
Args:
|
||||
wallet (str): wallet on whose behalf GETRANGE is done
|
||||
cid (str): ID of Container where we get the Object from
|
||||
oid (str): ID of Object we are going to request
|
||||
file_path (str): file path
|
||||
range_cut (str): range to take data from in the form offset:length
|
||||
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
|
||||
options (optional, str): any options which `neofs-cli object range` accepts
|
||||
Returns:
|
||||
(void)
|
||||
'''
|
||||
"""
|
||||
range_file = f"{ASSETS_DIR}/{uuid.uuid4()}"
|
||||
cmd = (
|
||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
|
||||
|
@ -178,9 +179,9 @@ def get_range(wallet: str, cid: str, oid: str, file_path: str, bearer: str, rang
|
|||
|
||||
|
||||
@keyword('Search object')
|
||||
def search_object(wallet: str, cid: str, keys: str="", bearer: str="", filters: dict={},
|
||||
def search_object(wallet: str, cid: str, keys: str = "", bearer: str = "", filters: dict = {},
|
||||
expected_objects_list=[]):
|
||||
'''
|
||||
"""
|
||||
SEARCH an Object.
|
||||
|
||||
Args:
|
||||
|
@ -193,7 +194,7 @@ def search_object(wallet: str, cid: str, keys: str="", bearer: str="", filters:
|
|||
expected_objects_list (optional, list): a list of ObjectIDs to compare found Objects with
|
||||
Returns:
|
||||
(list): list of found ObjectIDs
|
||||
'''
|
||||
"""
|
||||
filters_result = ""
|
||||
if filters:
|
||||
filters_result += "--filters "
|
||||
|
@ -221,10 +222,10 @@ def search_object(wallet: str, cid: str, keys: str="", bearer: str="", filters:
|
|||
|
||||
|
||||
@keyword('Head object')
|
||||
def head_object(wallet: str, cid: str, oid: str, bearer_token: str="",
|
||||
options:str="", endpoint: str="", json_output: bool = True,
|
||||
def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
|
||||
options: str = "", endpoint: str = "", json_output: bool = True,
|
||||
is_raw: bool = False, is_direct: bool = False):
|
||||
'''
|
||||
"""
|
||||
HEAD an Object.
|
||||
|
||||
Args:
|
||||
|
@ -245,7 +246,7 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str="",
|
|||
(dict): HEAD response in JSON format
|
||||
or
|
||||
(str): HEAD response as a plain text
|
||||
'''
|
||||
"""
|
||||
cmd = (
|
||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint if endpoint else NEOFS_ENDPOINT} '
|
||||
f'--wallet {wallet} --config {WALLET_PASS} '
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
import random
|
||||
|
||||
import docker
|
||||
|
||||
from robot.api.deco import keyword
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
@keyword('Stop Nodes')
|
||||
def stop_nodes(number: int, nodes: list):
|
||||
"""
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import pexpect
|
||||
import re
|
||||
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
import pexpect
|
||||
from neo3 import wallet
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
|
||||
from common import *
|
||||
import rpc_client
|
||||
import contract
|
||||
import rpc_client
|
||||
from common import *
|
||||
from wrappers import run_sh_with_passwd_contract
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
@ -78,7 +77,7 @@ def get_balance(wif: str):
|
|||
)
|
||||
logger.info(resp)
|
||||
value = int(resp['stack'][0]['value'])
|
||||
return value/(10**MORPH_TOKEN_POWER)
|
||||
return value / (10 ** MORPH_TOKEN_POWER)
|
||||
except Exception as e:
|
||||
logger.error(f"failed to get {wif} balance: {e}")
|
||||
raise e
|
||||
|
|
|
@ -6,12 +6,12 @@ import uuid
|
|||
|
||||
import boto3
|
||||
import botocore
|
||||
from cli_helpers import _run_with_passwd
|
||||
|
||||
from common import GATE_PUB_KEY, NEOFS_ENDPOINT, S3_GATE
|
||||
import urllib3
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
|
||||
from cli_helpers import _run_with_passwd
|
||||
from common import GATE_PUB_KEY, NEOFS_ENDPOINT, S3_GATE
|
||||
|
||||
##########################################################
|
||||
# Disabling warnings on self-signed certificate which the
|
||||
|
@ -24,6 +24,7 @@ CREDENTIALS_CREATE_TIMEOUT = '30s'
|
|||
|
||||
NEOFS_EXEC = os.getenv('NEOFS_EXEC', 'neofs-authmate')
|
||||
|
||||
|
||||
@keyword('Init S3 Credentials')
|
||||
def init_s3_credentials(wallet):
|
||||
bucket = str(uuid.uuid4())
|
||||
|
@ -179,7 +180,6 @@ def put_object_s3(s3_client, bucket, filepath):
|
|||
|
||||
@keyword('Head object S3')
|
||||
def head_object_s3(s3_client, bucket, object_key):
|
||||
|
||||
try:
|
||||
response = s3_client.head_object(Bucket=bucket, Key=object_key)
|
||||
logger.info(f"S3 Head object result: {response}")
|
||||
|
|
|
@ -10,12 +10,12 @@ import os
|
|||
import uuid
|
||||
|
||||
from neo3 import wallet
|
||||
from common import WALLET_PASS, ASSETS_DIR
|
||||
from cli_helpers import _cmd_run
|
||||
import json_transformers
|
||||
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
|
||||
import json_transformers
|
||||
from cli_helpers import _cmd_run
|
||||
from common import WALLET_PASS, ASSETS_DIR
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
@ -24,7 +24,7 @@ NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
|
|||
|
||||
|
||||
@keyword('Generate Session Token')
|
||||
def generate_session_token(owner: str, session_wallet: str, cid: str='') -> str:
|
||||
def generate_session_token(owner: str, session_wallet: str, cid: str = '') -> str:
|
||||
"""
|
||||
This function generates session token for ContainerSessionContext
|
||||
and writes it to the file. It is able to prepare session token file
|
||||
|
@ -53,23 +53,22 @@ def generate_session_token(owner: str, session_wallet: str, cid: str='') -> str:
|
|||
).decode('utf-8')
|
||||
|
||||
session_token = {
|
||||
"body":{
|
||||
"id":f"{base64.b64encode(uuid.uuid4().bytes).decode('utf-8')}",
|
||||
"ownerID":{
|
||||
"value":f"{json_transformers.encode_for_json(owner)}"
|
||||
"body": {
|
||||
"id": f"{base64.b64encode(uuid.uuid4().bytes).decode('utf-8')}",
|
||||
"ownerID": {
|
||||
"value": f"{json_transformers.encode_for_json(owner)}"
|
||||
},
|
||||
"lifetime":{
|
||||
"exp":"100000000",
|
||||
"nbf":"0",
|
||||
"iat":"0"
|
||||
"lifetime": {
|
||||
"exp": "100000000",
|
||||
"nbf": "0",
|
||||
"iat": "0"
|
||||
},
|
||||
"sessionKey":f"{pub_key_64}",
|
||||
"container":{
|
||||
"verb":"PUT",
|
||||
"sessionKey": f"{pub_key_64}",
|
||||
"container": {
|
||||
"verb": "PUT",
|
||||
"wildcard": cid != '',
|
||||
**({ "containerID":
|
||||
{"value":
|
||||
f"{base64.b64encode(cid.encode('utf-8')).decode('utf-8')}"}
|
||||
**({"containerID":
|
||||
{"value": f"{base64.b64encode(cid.encode('utf-8')).decode('utf-8')}"}
|
||||
} if cid != '' else {}
|
||||
)
|
||||
}
|
||||
|
@ -83,7 +82,7 @@ def generate_session_token(owner: str, session_wallet: str, cid: str='') -> str:
|
|||
return file_path
|
||||
|
||||
|
||||
@keyword ('Sign Session Token')
|
||||
@keyword('Sign Session Token')
|
||||
def sign_session_token(session_token: str, wlt: str):
|
||||
"""
|
||||
This function signs the session token by the given wallet.
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
It contains wrappers for `neofs-cli storagegroup` verbs.
|
||||
"""
|
||||
|
||||
from cli_helpers import _cmd_run
|
||||
|
||||
from common import NEOFS_CLI_EXEC, NEOFS_ENDPOINT, WALLET_PASS
|
||||
from robot.api.deco import keyword
|
||||
|
||||
from cli_helpers import _cmd_run
|
||||
from common import NEOFS_CLI_EXEC, NEOFS_ENDPOINT, WALLET_PASS
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
@keyword('Put Storagegroup')
|
||||
def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str=""):
|
||||
def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str = ""):
|
||||
"""
|
||||
Wrapper for `neofs-cli storagegroup put`. Before the SG is created,
|
||||
neofs-cli performs HEAD on `objects`, so this verb must be allowed
|
||||
|
@ -40,7 +40,7 @@ def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str="")
|
|||
|
||||
|
||||
@keyword('List Storagegroup')
|
||||
def list_storagegroup(wallet: str, cid: str, bearer_token: str=""):
|
||||
def list_storagegroup(wallet: str, cid: str, bearer_token: str = ""):
|
||||
"""
|
||||
Wrapper for `neofs-cli storagegroup list`. This operation
|
||||
requires SEARCH allowed for `wallet` in `cid`.
|
||||
|
@ -64,7 +64,7 @@ def list_storagegroup(wallet: str, cid: str, bearer_token: str=""):
|
|||
|
||||
|
||||
@keyword('Get Storagegroup')
|
||||
def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str=''):
|
||||
def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = ''):
|
||||
"""
|
||||
Wrapper for `neofs-cli storagegroup get`.
|
||||
Args:
|
||||
|
@ -103,7 +103,7 @@ def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str=''):
|
|||
|
||||
|
||||
@keyword('Delete Storagegroup')
|
||||
def delete_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str=""):
|
||||
def delete_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = ""):
|
||||
"""
|
||||
Wrapper for `neofs-cli storagegroup delete`.
|
||||
Args:
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
that storage policies are kept.
|
||||
'''
|
||||
|
||||
from common import NEOFS_NETMAP
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
|
||||
import complex_object_actions
|
||||
import neofs_verbs
|
||||
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from common import NEOFS_NETMAP
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
#!/usr/bin/python3.8
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import tarfile
|
||||
import uuid
|
||||
import hashlib
|
||||
import docker
|
||||
|
||||
from common import SIMPLE_OBJ_SIZE, ASSETS_DIR
|
||||
from cli_helpers import _cmd_run
|
||||
from robot.api.deco import keyword
|
||||
import docker
|
||||
from robot.api import logger
|
||||
from robot.api.deco import keyword
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
|
||||
from cli_helpers import _cmd_run
|
||||
from common import SIMPLE_OBJ_SIZE, ASSETS_DIR
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
@keyword('Generate file')
|
||||
def generate_file_and_file_hash(size: int) -> str:
|
||||
"""
|
||||
|
@ -60,15 +61,16 @@ def get_container_logs(testcase_name: str) -> None:
|
|||
container_name = container['Names'][0][1:]
|
||||
if client.inspect_container(container_name)['Config']['Domainname'] == "neofs.devenv":
|
||||
file_name = f"{logs_dir}/docker_log_{container_name}"
|
||||
with open(file_name,'wb') as out:
|
||||
with open(file_name, 'wb') as out:
|
||||
out.write(client.logs(container_name))
|
||||
logger.info(f"Collected logs from container {container_name}")
|
||||
tar.add(file_name)
|
||||
os.remove(file_name)
|
||||
tar.close()
|
||||
|
||||
|
||||
@keyword('Make Up')
|
||||
def make_up(services: list=[], config_dict: dict={}):
|
||||
def make_up(services: list = [], config_dict: dict = {}):
|
||||
test_path = os.getcwd()
|
||||
dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env')
|
||||
os.chdir(dev_path)
|
||||
|
@ -87,8 +89,9 @@ def make_up(services: list=[], config_dict: dict={}):
|
|||
|
||||
os.chdir(test_path)
|
||||
|
||||
|
||||
@keyword('Make Down')
|
||||
def make_down(services: list=[]):
|
||||
def make_down(services: list = []):
|
||||
test_path = os.getcwd()
|
||||
dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env')
|
||||
os.chdir(dev_path)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
|
||||
ROOT='../..'
|
||||
CERT="%s/../../ca" % ROOT
|
||||
ROOT = '../..'
|
||||
CERT = "%s/../../ca" % ROOT
|
||||
|
||||
# Common NeoFS variables can be declared from neofs-dev-env env variables.
|
||||
# High priority is accepted for those envs.
|
||||
|
@ -19,7 +19,7 @@ MAINNET_TIMEOUT = os.getenv('MAINNET_TIMEOUT', "1min")
|
|||
MORPH_BLOCK_TIME = os.getenv("MORPH_BLOCK_TIME", '1s')
|
||||
NEOFS_CONTRACT_CACHE_TIMEOUT = os.getenv("NEOFS_CONTRACT_CACHE_TIMEOUT", "30s")
|
||||
|
||||
#TODO: change to NEOFS_STORAGE_DEFAULT_GC_REMOVER_SLEEP_INTERVAL
|
||||
# TODO: change to NEOFS_STORAGE_DEFAULT_GC_REMOVER_SLEEP_INTERVAL
|
||||
|
||||
SHARD_0_GC_SLEEP = os.getenv("NEOFS_STORAGE_SHARD_0_GC_REMOVER_SLEEP_INTERVAL", "1m")
|
||||
|
||||
|
@ -43,22 +43,27 @@ COMMON_PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X"
|
|||
|
||||
ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/")
|
||||
|
||||
MORPH_MAGIC = os.environ["MORPH_MAGIC"]
|
||||
MORPH_MAGIC = os.getenv("MORPH_MAGIC")
|
||||
GATE_PUB_KEY = '0313b1ac3a8076e155a7e797b24f0b650cccad5941ea59d7cfd51a024a8b2a06bf'
|
||||
|
||||
NEOFS_NETMAP_DICT = {'s01': {'rpc': 's01.neofs.devenv:8080',
|
||||
STORAGE_NODE_1 = os.getenv('DATA_NODE_1', 's01.neofs.devenv:8080')
|
||||
STORAGE_NODE_2 = os.getenv('DATA_NODE_2', 's02.neofs.devenv:8080')
|
||||
STORAGE_NODE_3 = os.getenv('DATA_NODE_3', 's03.neofs.devenv:8080')
|
||||
STORAGE_NODE_4 = os.getenv('DATA_NODE_4', 's04.neofs.devenv:8080')
|
||||
|
||||
NEOFS_NETMAP_DICT = {'s01': {'rpc': STORAGE_NODE_1,
|
||||
'control': 's01.neofs.devenv:8081',
|
||||
'wif': 'Kwk6k2eC3L3QuPvD8aiaNyoSXgQ2YL1bwS5CP1oKoA9waeAze97s',
|
||||
'UN-LOCODE': 'RU MOW'},
|
||||
's02': {'rpc': 's02.neofs.devenv:8080',
|
||||
's02': {'rpc': STORAGE_NODE_2,
|
||||
'control': 's02.neofs.devenv:8081',
|
||||
'wif': 'L1NdHdnrTNGQZH1fJSrdUZJyeYFHvaQSSHZHxhK3udiGFdr5YaZ6',
|
||||
'UN-LOCODE': 'RU LED'},
|
||||
's03': {'rpc': 's03.neofs.devenv:8080',
|
||||
's03': {'rpc': STORAGE_NODE_3,
|
||||
'control': 's03.neofs.devenv:8081',
|
||||
'wif': 'KzN38k39af6ACWJjK8YrnARWo86ddcc1EuBWz7xFEdcELcP3ZTym',
|
||||
'UN-LOCODE': 'SE STO'},
|
||||
's04': {'rpc': 's04.neofs.devenv:8080',
|
||||
's04': {'rpc': STORAGE_NODE_4,
|
||||
'control': 's04.neofs.devenv:8081',
|
||||
'wif': 'Kzk1Z3dowAqfNyjqeYKWenZMduFV3NAKgXg9K1sA4jRKYxEc8HEW',
|
||||
'UN-LOCODE': 'FI HEL'}
|
||||
|
|
Loading…
Reference in a new issue