forked from TrueCloudLab/frostfs-testcases
[#297] remove robot.logger
Signed-off-by: Yulia Kovshova <y.kovshova@yadro.com>
This commit is contained in:
parent
035175894d
commit
a8a00c1c53
15 changed files with 811 additions and 713 deletions
|
@ -2,18 +2,19 @@
|
|||
|
||||
import allure
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import tarfile
|
||||
from typing import Tuple
|
||||
import uuid
|
||||
from typing import Tuple
|
||||
|
||||
import allure
|
||||
import docker
|
||||
import wallet
|
||||
from common import ASSETS_DIR, SIMPLE_OBJ_SIZE
|
||||
from cli_helpers import _cmd_run
|
||||
from robot.api import logger
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
from common import ASSETS_DIR, SIMPLE_OBJ_SIZE
|
||||
|
||||
logger = logging.getLogger("NeoLogger")
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
|
||||
|
@ -26,14 +27,14 @@ def generate_file(size: int = SIMPLE_OBJ_SIZE) -> str:
|
|||
(str): the path to the generated file
|
||||
"""
|
||||
file_path = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}"
|
||||
with open(file_path, 'wb') as fout:
|
||||
with open(file_path, "wb") as fout:
|
||||
fout.write(os.urandom(size))
|
||||
logger.info(f"file with size {size} bytes has been generated: {file_path}")
|
||||
|
||||
return file_path
|
||||
|
||||
|
||||
@allure.step('Generate file')
|
||||
@allure.step("Generate file")
|
||||
def generate_file_and_file_hash(size: int) -> Tuple[str, str]:
|
||||
"""
|
||||
Function generates a binary file with the specified size in bytes
|
||||
|
@ -50,7 +51,7 @@ def generate_file_and_file_hash(size: int) -> Tuple[str, str]:
|
|||
return file_path, file_hash
|
||||
|
||||
|
||||
@allure.step('Get File Hash')
|
||||
@allure.step("Get File Hash")
|
||||
def get_file_hash(filename: str, len: int = None):
|
||||
"""
|
||||
This function generates hash for the specified file.
|
||||
|
@ -69,23 +70,22 @@ def get_file_hash(filename: str, len: int = None):
|
|||
return file_hash.hexdigest()
|
||||
|
||||
|
||||
@allure.step('Generate Wallet')
|
||||
@allure.step("Generate Wallet")
|
||||
def generate_wallet():
|
||||
return wallet.init_wallet(ASSETS_DIR)
|
||||
|
||||
|
||||
@allure.step('Get Docker Logs')
|
||||
@allure.step("Get Docker Logs")
|
||||
def get_container_logs(testcase_name: str) -> None:
|
||||
client = docker.APIClient(base_url='unix://var/run/docker.sock')
|
||||
logs_dir = BuiltIn().get_variable_value("${OUTPUT_DIR}")
|
||||
client = docker.APIClient(base_url="unix://var/run/docker.sock")
|
||||
logs_dir = os.getenv("${OUTPUT_DIR}")
|
||||
tar_name = f"{logs_dir}/dockerlogs({testcase_name}).tar.gz"
|
||||
tar = tarfile.open(tar_name, "w:gz")
|
||||
for container in client.containers():
|
||||
container_name = container['Names'][0][1:]
|
||||
if (client.inspect_container(container_name)['Config']['Domainname']
|
||||
== "neofs.devenv"):
|
||||
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)
|
||||
|
@ -93,10 +93,10 @@ def get_container_logs(testcase_name: str) -> None:
|
|||
tar.close()
|
||||
|
||||
|
||||
@allure.step('Make Up')
|
||||
@allure.step("Make Up")
|
||||
def make_up(services: list = [], config_dict: dict = {}):
|
||||
test_path = os.getcwd()
|
||||
dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env')
|
||||
dev_path = os.getenv("DEVENV_PATH", "../neofs-dev-env")
|
||||
os.chdir(dev_path)
|
||||
|
||||
if len(services) > 0:
|
||||
|
@ -104,33 +104,30 @@ def make_up(services: list = [], config_dict: dict = {}):
|
|||
if config_dict != {}:
|
||||
with open(f"{dev_path}/.int_test.env", "a") as out:
|
||||
for key, value in config_dict.items():
|
||||
out.write(f'{key}={value}')
|
||||
cmd = f'make up/{service}'
|
||||
out.write(f"{key}={value}")
|
||||
cmd = f"make up/{service}"
|
||||
_cmd_run(cmd)
|
||||
else:
|
||||
cmd = (
|
||||
f'make up/basic;'
|
||||
f'make update.max_object_size val={SIMPLE_OBJ_SIZE}'
|
||||
)
|
||||
cmd = f"make up/basic;" f"make update.max_object_size val={SIMPLE_OBJ_SIZE}"
|
||||
_cmd_run(cmd, timeout=120)
|
||||
|
||||
os.chdir(test_path)
|
||||
|
||||
|
||||
@allure.step('Make Down')
|
||||
@allure.step("Make Down")
|
||||
def make_down(services: list = []):
|
||||
test_path = os.getcwd()
|
||||
dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env')
|
||||
dev_path = os.getenv("DEVENV_PATH", "../neofs-dev-env")
|
||||
os.chdir(dev_path)
|
||||
|
||||
if len(services) > 0:
|
||||
for service in services:
|
||||
cmd = f'make down/{service}'
|
||||
cmd = f"make down/{service}"
|
||||
_cmd_run(cmd)
|
||||
with open(f"{dev_path}/.int_test.env", "w"):
|
||||
pass
|
||||
else:
|
||||
cmd = 'make down; make clean'
|
||||
cmd = "make down; make clean"
|
||||
_cmd_run(cmd, timeout=60)
|
||||
|
||||
os.chdir(test_path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue