forked from TrueCloudLab/frostfs-testcases
Add non-global Generate File in acl_basic_*
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
This commit is contained in:
parent
2ea007164c
commit
3ea4578683
8 changed files with 40 additions and 35 deletions
|
@ -3,14 +3,14 @@
|
||||||
import os
|
import os
|
||||||
import tarfile
|
import tarfile
|
||||||
import uuid
|
import uuid
|
||||||
|
import hashlib
|
||||||
import docker
|
import docker
|
||||||
|
|
||||||
from neo3 import wallet
|
|
||||||
from common import SIMPLE_OBJ_SIZE, ASSETS_DIR
|
from common import SIMPLE_OBJ_SIZE, ASSETS_DIR
|
||||||
|
from cli_helpers import _cmd_run
|
||||||
from robot.api.deco import keyword
|
from robot.api.deco import keyword
|
||||||
from robot.api import logger
|
from robot.api import logger
|
||||||
from robot.libraries.BuiltIn import BuiltIn
|
from robot.libraries.BuiltIn import BuiltIn
|
||||||
from cli_helpers import _cmd_run
|
|
||||||
|
|
||||||
|
|
||||||
ROBOT_AUTO_KEYWORDS = False
|
ROBOT_AUTO_KEYWORDS = False
|
||||||
|
@ -22,12 +22,32 @@ def generate_file_of_bytes(size: str) -> str:
|
||||||
:param size: the size in bytes, can be declared as 6e+6 for example
|
:param size: the size in bytes, can be declared as 6e+6 for example
|
||||||
"""
|
"""
|
||||||
size = int(float(size))
|
size = int(float(size))
|
||||||
filename = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}"
|
filename = f"{os.getcwd()}/{ASSETS_DIR}/{uuid.uuid4()}"
|
||||||
with open(filename, 'wb') as fout:
|
with open(filename, 'wb') as fout:
|
||||||
fout.write(os.urandom(size))
|
fout.write(os.urandom(size))
|
||||||
logger.info(f"file with size {size} bytes has been generated: {filename}")
|
logger.info(f"file with size {size} bytes has been generated: {filename}")
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
@keyword('Generate file')
|
||||||
|
def generate_file_and_file_hash(size: str) -> str:
|
||||||
|
"""
|
||||||
|
Function generates a big binary file with the specified size in bytes and its hash.
|
||||||
|
Args:
|
||||||
|
size (str): the size in bytes, can be declared as 6e+6 for example
|
||||||
|
Returns:
|
||||||
|
(str): the path to the generated file
|
||||||
|
(str): the hash of the generated file
|
||||||
|
"""
|
||||||
|
size = int(float(size))
|
||||||
|
filename = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}"
|
||||||
|
with open(filename, 'wb') as fout:
|
||||||
|
fout.write(os.urandom(size))
|
||||||
|
logger.info(f"file with size {size} bytes has been generated: {filename}")
|
||||||
|
|
||||||
|
file_hash = _get_file_hash(filename)
|
||||||
|
|
||||||
|
return filename, file_hash
|
||||||
|
|
||||||
@keyword('Get Docker Logs')
|
@keyword('Get Docker Logs')
|
||||||
def get_container_logs(testcase_name: str) -> None:
|
def get_container_logs(testcase_name: str) -> None:
|
||||||
client = docker.APIClient(base_url='unix://var/run/docker.sock')
|
client = docker.APIClient(base_url='unix://var/run/docker.sock')
|
||||||
|
@ -82,3 +102,12 @@ def make_down(services: list=[]):
|
||||||
_cmd_run(cmd, timeout=60)
|
_cmd_run(cmd, timeout=60)
|
||||||
|
|
||||||
os.chdir(test_path)
|
os.chdir(test_path)
|
||||||
|
|
||||||
|
def _get_file_hash(filename: str):
|
||||||
|
blocksize = 65536
|
||||||
|
file_hash = hashlib.md5()
|
||||||
|
with open(filename, "rb") as out:
|
||||||
|
for block in iter(lambda: out.read(blocksize), b""):
|
||||||
|
file_hash.update(block)
|
||||||
|
logger.info(f"Hash: {file_hash.hexdigest()}")
|
||||||
|
return file_hash.hexdigest()
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
*** Keywords ***
|
|
||||||
|
|
||||||
Generate file
|
|
||||||
[Arguments] ${SIZE}
|
|
||||||
${FILE_S_GEN} = Generate file of bytes ${SIZE}
|
|
||||||
${FILE_S_HASH_GEN} = Get file hash ${FILE_S_GEN}
|
|
||||||
[Return] ${FILE_S_GEN} ${FILE_S_HASH_GEN}
|
|
|
@ -2,11 +2,9 @@
|
||||||
Variables common.py
|
Variables common.py
|
||||||
|
|
||||||
Library container.py
|
Library container.py
|
||||||
Library neofs.py
|
|
||||||
Library neofs_verbs.py
|
Library neofs_verbs.py
|
||||||
Library payment_neogo.py
|
Library utility_keywords.py
|
||||||
|
|
||||||
Resource common_steps_acl_basic.robot
|
|
||||||
Resource payment_operations.robot
|
Resource payment_operations.robot
|
||||||
Resource setup_teardown.robot
|
Resource setup_teardown.robot
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,12 @@
|
||||||
Variables common.py
|
Variables common.py
|
||||||
|
|
||||||
Library container.py
|
Library container.py
|
||||||
Library neofs.py
|
|
||||||
Library neofs_verbs.py
|
Library neofs_verbs.py
|
||||||
Library payment_neogo.py
|
Library utility_keywords.py
|
||||||
Library storage_group.py
|
|
||||||
Library Collections
|
|
||||||
|
|
||||||
Resource payment_operations.robot
|
Resource payment_operations.robot
|
||||||
Resource setup_teardown.robot
|
Resource setup_teardown.robot
|
||||||
Resource storage_group.robot
|
Resource storage_group.robot
|
||||||
Resource common_steps_acl_basic.robot
|
|
||||||
|
|
||||||
|
|
||||||
*** Test cases ***
|
*** Test cases ***
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
Variables common.py
|
Variables common.py
|
||||||
|
|
||||||
Library container.py
|
Library container.py
|
||||||
Library neofs.py
|
|
||||||
Library neofs_verbs.py
|
Library neofs_verbs.py
|
||||||
Library payment_neogo.py
|
Library utility_keywords.py
|
||||||
|
|
||||||
Resource common_steps_acl_basic.robot
|
|
||||||
Resource payment_operations.robot
|
Resource payment_operations.robot
|
||||||
Resource setup_teardown.robot
|
Resource setup_teardown.robot
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,9 @@
|
||||||
Variables common.py
|
Variables common.py
|
||||||
|
|
||||||
Library container.py
|
Library container.py
|
||||||
Library neofs.py
|
|
||||||
Library neofs_verbs.py
|
Library neofs_verbs.py
|
||||||
Library payment_neogo.py
|
Library utility_keywords.py
|
||||||
Library contract_keywords.py
|
|
||||||
Library storage_group.py
|
|
||||||
|
|
||||||
Resource common_steps_acl_basic.robot
|
|
||||||
Resource payment_operations.robot
|
Resource payment_operations.robot
|
||||||
Resource setup_teardown.robot
|
Resource setup_teardown.robot
|
||||||
Resource storage_group.robot
|
Resource storage_group.robot
|
||||||
|
@ -52,4 +48,4 @@ Check Public Container
|
||||||
|
|
||||||
# System isn't allowed to DELETE in Public Container
|
# System isn't allowed to DELETE in Public Container
|
||||||
Run Storage Group Operations On System's Behalf In RO Container
|
Run Storage Group Operations On System's Behalf In RO Container
|
||||||
... ${PUBLIC_CID} ${OBJECTS} ${RUN_TYPE}
|
... ${PUBLIC_CID} ${OBJECTS} ${RUN_TYPE}
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
Variables common.py
|
Variables common.py
|
||||||
|
|
||||||
Library container.py
|
Library container.py
|
||||||
Library neofs.py
|
|
||||||
Library neofs_verbs.py
|
Library neofs_verbs.py
|
||||||
Library payment_neogo.py
|
Library utility_keywords.py
|
||||||
|
|
||||||
Resource common_steps_acl_basic.robot
|
|
||||||
Resource payment_operations.robot
|
Resource payment_operations.robot
|
||||||
Resource setup_teardown.robot
|
Resource setup_teardown.robot
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,9 @@
|
||||||
Variables common.py
|
Variables common.py
|
||||||
|
|
||||||
Library container.py
|
Library container.py
|
||||||
Library neofs.py
|
|
||||||
Library neofs_verbs.py
|
Library neofs_verbs.py
|
||||||
Library payment_neogo.py
|
Library utility_keywords.py
|
||||||
Library storage_group.py
|
|
||||||
|
|
||||||
Resource common_steps_acl_basic.robot
|
|
||||||
Resource payment_operations.robot
|
Resource payment_operations.robot
|
||||||
Resource setup_teardown.robot
|
Resource setup_teardown.robot
|
||||||
Resource storage_group.robot
|
Resource storage_group.robot
|
||||||
|
|
Loading…
Reference in a new issue