forked from TrueCloudLab/frostfs-testlib
Adding code validation targets
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
62216293f8
commit
4896abcec3
11 changed files with 80 additions and 41 deletions
|
@ -6,6 +6,7 @@ from docstring_parser.google import DEFAULT_SECTIONS, Section, SectionType
|
|||
|
||||
DEFAULT_SECTIONS.append(Section("Steps", "steps", SectionType.MULTIPLE))
|
||||
|
||||
|
||||
class TestCase:
|
||||
"""
|
||||
Test case object implementation for use in collector and exporters
|
||||
|
@ -106,7 +107,9 @@ class TestCaseCollector:
|
|||
# Read test_case suite and section name from test class if possible and get test function from class
|
||||
if test.cls:
|
||||
suite_name = test.cls.__dict__.get("__test_case_suite_name__", suite_name)
|
||||
suite_section_name = test.cls.__dict__.get("__test_case_suite_section__", suite_section_name)
|
||||
suite_section_name = test.cls.__dict__.get(
|
||||
"__test_case_suite_section__", suite_section_name
|
||||
)
|
||||
test_function = test.cls.__dict__[test.originalname]
|
||||
else:
|
||||
# If no test class, read test function from module
|
||||
|
@ -117,7 +120,9 @@ class TestCaseCollector:
|
|||
test_case_title = test_function.__dict__.get("__test_case_title__", None)
|
||||
test_case_priority = test_function.__dict__.get("__test_case_priority__", None)
|
||||
suite_name = test_function.__dict__.get("__test_case_suite_name__", suite_name)
|
||||
suite_section_name = test_function.__dict__.get("__test_case_suite_section__", suite_section_name)
|
||||
suite_section_name = test_function.__dict__.get(
|
||||
"__test_case_suite_section__", suite_section_name
|
||||
)
|
||||
|
||||
# Parce test_steps if they define in __doc__
|
||||
doc_string = parse(test_function.__doc__, style=DocstringStyle.GOOGLE)
|
||||
|
@ -125,7 +130,9 @@ class TestCaseCollector:
|
|||
if doc_string.short_description:
|
||||
test_case_description = doc_string.short_description
|
||||
if doc_string.long_description:
|
||||
test_case_description = f"{doc_string.short_description}\r\n{doc_string.long_description}"
|
||||
test_case_description = (
|
||||
f"{doc_string.short_description}\r\n{doc_string.long_description}"
|
||||
)
|
||||
|
||||
if doc_string.meta:
|
||||
for meta in doc_string.meta:
|
||||
|
@ -140,25 +147,27 @@ class TestCaseCollector:
|
|||
test_case_params = test_case_call_spec.id
|
||||
# Format title with params
|
||||
if test_case_title:
|
||||
test_case_title = self.__format_string_with_params__(test_case_title,test_case_call_spec.params)
|
||||
test_case_title = self.__format_string_with_params__(
|
||||
test_case_title, test_case_call_spec.params
|
||||
)
|
||||
# Format steps with params
|
||||
if test_case_steps:
|
||||
for key, value in test_case_steps.items():
|
||||
value = self.__format_string_with_params__(value,test_case_call_spec.params)
|
||||
value = self.__format_string_with_params__(value, test_case_call_spec.params)
|
||||
test_case_steps[key] = value
|
||||
|
||||
# If there is set basic test case attributes create TestCase and return
|
||||
if test_case_id and test_case_title and suite_name and suite_name:
|
||||
test_case = TestCase(
|
||||
id=test_case_id,
|
||||
title=test_case_title,
|
||||
description=test_case_description,
|
||||
priority=test_case_priority,
|
||||
steps=test_case_steps,
|
||||
params=test_case_params,
|
||||
suite_name=suite_name,
|
||||
suite_section_name=suite_section_name,
|
||||
)
|
||||
uuid_id=test_case_id,
|
||||
title=test_case_title,
|
||||
description=test_case_description,
|
||||
priority=test_case_priority,
|
||||
steps=test_case_steps,
|
||||
params=test_case_params,
|
||||
suite_name=suite_name,
|
||||
suite_section_name=suite_section_name,
|
||||
)
|
||||
return test_case
|
||||
# Return None if there is no enough information for return test case
|
||||
return None
|
||||
|
@ -187,4 +196,4 @@ class TestCaseCollector:
|
|||
test_case = self.__get_test_case_from_pytest_test__(test)
|
||||
if test_case:
|
||||
test_cases.append(test_case)
|
||||
return test_cases
|
||||
return test_cases
|
||||
|
|
|
@ -67,6 +67,6 @@ class TestExporter(ABC):
|
|||
steps = [{"content": value, "expected": " "} for key, value in test_case.steps.items()]
|
||||
|
||||
if test_case_in_tms:
|
||||
self.update_test_case(test_case, test_case_in_tms)
|
||||
self.update_test_case(test_case, test_case_in_tms, test_suite, test_section)
|
||||
else:
|
||||
self.create_test_case(test_case)
|
||||
self.create_test_case(test_case, test_suite, test_section)
|
||||
|
|
|
@ -135,13 +135,19 @@ class DockerHost(Host):
|
|||
timeout=service_attributes.start_timeout,
|
||||
)
|
||||
|
||||
def wait_for_service_to_be_in_state(self, systemd_service_name: str, expected_state: str, timeout: int) -> None:
|
||||
def wait_for_service_to_be_in_state(
|
||||
self, systemd_service_name: str, expected_state: str, timeout: int
|
||||
) -> None:
|
||||
raise NotImplementedError("Not implemented for docker")
|
||||
|
||||
|
||||
def get_data_directory(self, service_name: str) -> str:
|
||||
service_attributes = self._get_service_attributes(service_name)
|
||||
return service_attributes.data_directory_path
|
||||
|
||||
client = self._get_docker_client()
|
||||
volume_info = client.inspect_volume(service_attributes.volume_name)
|
||||
volume_path = volume_info["Mountpoint"]
|
||||
|
||||
return volume_path
|
||||
|
||||
def delete_metabase(self, service_name: str) -> None:
|
||||
raise NotImplementedError("Not implemented for docker")
|
||||
|
@ -159,11 +165,7 @@ class DockerHost(Host):
|
|||
raise NotImplementedError("Not implemented for docker")
|
||||
|
||||
def delete_storage_node_data(self, service_name: str, cache_only: bool = False) -> None:
|
||||
service_attributes = self._get_service_attributes(service_name)
|
||||
|
||||
client = self._get_docker_client()
|
||||
volume_info = client.inspect_volume(service_attributes.volume_name)
|
||||
volume_path = volume_info["Mountpoint"]
|
||||
volume_path = self.get_data_directory(service_name)
|
||||
|
||||
shell = self.get_shell()
|
||||
meta_clean_cmd = f"rm -rf {volume_path}/meta*/*"
|
||||
|
|
|
@ -68,9 +68,7 @@ def _cmd_run(cmd: str, timeout: int = 90) -> str:
|
|||
end_time = datetime.now()
|
||||
_attach_allure_log(cmd, cmd_output, return_code, start_time, end_time)
|
||||
logger.info(
|
||||
f"Command: {cmd}\n"
|
||||
f"Error:\nreturn code: {return_code}\n"
|
||||
f"Output: {exc.output.decode('utf-8') if type(exc.output) is bytes else exc.output}"
|
||||
f"Command: {cmd}\n" f"Error:\nreturn code: {return_code}\n" f"Output: {cmd_output}"
|
||||
)
|
||||
raise
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue