Skip to content

Commit

Permalink
fix: Fix pytest tests results fetching #2020
Browse files Browse the repository at this point in the history
  • Loading branch information
jmv74211 committed Oct 27, 2021
1 parent d2c7c19 commit 3fdbeb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def run(self, ansible_inventory_path):
run_test_task_unix = {
'name': f"Launch pytest in {self.tests_run_dir} (Unix)",
'shell': pytest_command, 'args': {'chdir': self.tests_run_dir},
'register': 'test_output',
'register': 'test_output_unix',
'ignore_errors': 'yes',
'become':True,
'when': 'ansible_system != "Win32NT"'
Expand All @@ -160,7 +160,7 @@ def run(self, ansible_inventory_path):
run_test_task_windows = {
'name': f"Launch pytest in {self.tests_run_dir} (Windows)",
'win_shell': pytest_command, 'args': {'chdir': self.tests_run_dir},
'register': 'test_output',
'register': 'test_output_windows',
'ignore_errors': 'yes',
'become': True,
'become_method': 'runas',
Expand All @@ -170,14 +170,14 @@ def run(self, ansible_inventory_path):

create_plain_report_unix = {
'name': f"Create plain report file in {plain_report_file_path} (Unix)",
'copy': {'dest': plain_report_file_path, 'content': "{{test_output.stdout}}"},
'copy': {'dest': plain_report_file_path, 'content': "{{test_output_unix.stdout}}"},
'become': True,
'when': 'ansible_system != "Win32NT"'
}

create_plain_report_windows = {
'name': f"Create plain report file in {plain_report_file_path} (Windows)",
'win_copy': {'dest': plain_report_file_path, 'content': "{{test_output.stdout}}"},
'win_copy': {'dest': plain_report_file_path, 'content': "{{test_output_windows.stdout}}"},
'become': True,
'become_method': 'runas',
'become_user': self.ansible_admin_user,
Expand Down Expand Up @@ -245,6 +245,12 @@ def run(self, ansible_inventory_path):

# Print test result in stdout
if self.qa_ctl_configuration.logging_enable:
Pytest.LOGGER.info(self.result)
if os.path.exists(self.result.plain_report_file_path):
Pytest.LOGGER.info(self.result)
else:
Pytest.LOGGER.error(f"Test results could not be saved in {self.result.plain_report_file_path} file")
else:
print(self.result)
if os.path.exists(self.result.plain_report_file_path):
print(self.result)
else:
print(f"Test results could not be saved in {self.result.plain_report_file_path} file")
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __set_local_internal_options(self, hosts, modules, component, system, wazuh_
'name': 'Set custom local internal configuration (Windows)',
'win_lineinfile': {'path': local_internal_options_path,
'line': "{{ item }}"},
'with_items': local_internal_options_content,
'with_items': local_internal_options_content.copy(),
'become': True,
'become_method': 'runas',
'become_user': ansible_admin_user,
Expand Down

0 comments on commit 3fdbeb8

Please sign in to comment.