From f21aca04ef3aa8bf057b0427528551ea9a99686b Mon Sep 17 00:00:00 2001 From: jmv74211 Date: Fri, 27 Aug 2021 15:21:38 +0200 Subject: [PATCH] add: Add QACTL test results to stdout logging #1794 --- .../wazuh_testing/qa_ctl/run_tests/pytest.py | 11 +++++++++-- .../wazuh_testing/qa_ctl/run_tests/test_result.py | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/pytest.py b/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/pytest.py index 6b82aaa564..e6f2097a7b 100644 --- a/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/pytest.py +++ b/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/pytest.py @@ -185,6 +185,13 @@ def run(self, ansible_inventory_path): output=self.qa_ctl_configuration.ansible_output) self.result = TestResult(html_report_file_path=os.path.join(self.tests_result_path, html_report_file_name), - plain_report_file_path=os.path.join(self.tests_result_path, plain_report_file_name)) + plain_report_file_path=os.path.join(self.tests_result_path, plain_report_file_name), + test_name=self.tests_path) - Pytest.LOGGER.debug(f"{self.tests_path} tests of {self.hosts} hosts were saved in {self.tests_result_path}") \ No newline at end of file + Pytest.LOGGER.debug(f"{self.tests_path} tests of {self.hosts} hosts were saved in {self.tests_result_path}") + + # Print test result in stdout + if self.qa_ctl_configuration.logging_enable: + Pytest.LOGGER.info(self.result) + else: + print(self.result) diff --git a/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/test_result.py b/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/test_result.py index 5fd559548f..6abb623be1 100644 --- a/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/test_result.py +++ b/deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/test_result.py @@ -12,11 +12,22 @@ class TestResult: custom_report_file_path (str, None): Local file path pointing to the custom report """ - def __init__(self, html_report_file_path=None, plain_report_file_path=None, - custom_report_file_path=None): + def __init__(self, html_report_file_path=None, plain_report_file_path=None, custom_report_file_path=None, + test_name=None): self.html_report_file_path = html_report_file_path self.plain_report_file_path = plain_report_file_path self.custom_report_file_path = custom_report_file_path + self.test_name = test_name + + def __str__(self): + result = '\n' * 2 + + with open(self.plain_report_file_path) as plain_report_file: + result += plain_report_file.read() + + result += '\n' * 2 + + return result def generate_custom_report(self): pass