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 tarfile
|
||||
import uuid
|
||||
import hashlib
|
||||
import docker
|
||||
|
||||
from neo3 import wallet
|
||||
from common import SIMPLE_OBJ_SIZE, ASSETS_DIR
|
||||
from cli_helpers import _cmd_run
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
from cli_helpers import _cmd_run
|
||||
|
||||
|
||||
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
|
||||
"""
|
||||
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:
|
||||
fout.write(os.urandom(size))
|
||||
logger.info(f"file with size {size} bytes has been generated: {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')
|
||||
def get_container_logs(testcase_name: str) -> None:
|
||||
client = docker.APIClient(base_url='unix://var/run/docker.sock')
|
||||
|
@ -82,3 +102,12 @@ def make_down(services: list=[]):
|
|||
_cmd_run(cmd, timeout=60)
|
||||
|
||||
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
|
||||
|
||||
Library container.py
|
||||
Library neofs.py
|
||||
Library neofs_verbs.py
|
||||
Library payment_neogo.py
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource common_steps_acl_basic.robot
|
||||
Resource payment_operations.robot
|
||||
Resource setup_teardown.robot
|
||||
|
||||
|
|
|
@ -2,16 +2,12 @@
|
|||
Variables common.py
|
||||
|
||||
Library container.py
|
||||
Library neofs.py
|
||||
Library neofs_verbs.py
|
||||
Library payment_neogo.py
|
||||
Library storage_group.py
|
||||
Library Collections
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource payment_operations.robot
|
||||
Resource setup_teardown.robot
|
||||
Resource storage_group.robot
|
||||
Resource common_steps_acl_basic.robot
|
||||
|
||||
|
||||
*** Test cases ***
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
Variables common.py
|
||||
|
||||
Library container.py
|
||||
Library neofs.py
|
||||
Library neofs_verbs.py
|
||||
Library payment_neogo.py
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource common_steps_acl_basic.robot
|
||||
Resource payment_operations.robot
|
||||
Resource setup_teardown.robot
|
||||
|
||||
|
|
|
@ -2,13 +2,9 @@
|
|||
Variables common.py
|
||||
|
||||
Library container.py
|
||||
Library neofs.py
|
||||
Library neofs_verbs.py
|
||||
Library payment_neogo.py
|
||||
Library contract_keywords.py
|
||||
Library storage_group.py
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource common_steps_acl_basic.robot
|
||||
Resource payment_operations.robot
|
||||
Resource setup_teardown.robot
|
||||
Resource storage_group.robot
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
Variables common.py
|
||||
|
||||
Library container.py
|
||||
Library neofs.py
|
||||
Library neofs_verbs.py
|
||||
Library payment_neogo.py
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource common_steps_acl_basic.robot
|
||||
Resource payment_operations.robot
|
||||
Resource setup_teardown.robot
|
||||
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
Variables common.py
|
||||
|
||||
Library container.py
|
||||
Library neofs.py
|
||||
Library neofs_verbs.py
|
||||
Library payment_neogo.py
|
||||
Library storage_group.py
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource common_steps_acl_basic.robot
|
||||
Resource payment_operations.robot
|
||||
Resource setup_teardown.robot
|
||||
Resource storage_group.robot
|
||||
|
|
Loading…
Reference in a new issue