Skip to content

Commit

Permalink
refactor(#3142): collection of errors and some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromalara committed Aug 19, 2022
1 parent e6d11cd commit 0d81f1b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
9 changes: 8 additions & 1 deletion tests/end_to_end/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ def validate_environments(request):
remove_file(general_playbook)
# If the general validations have failed, then abort the execution finishing with an error. Else, continue.
if general_validation_runner.status == 'failed':
# Collect inventory_hostnames with errors
hosts_with_errors = [key for key in general_validation_runner.stats['failures']]
# Collect list of errors
errors = []
errors.extend([general_validation_runner.get_fact_cache(host)['phase_results'] for host in hosts_with_errors])
errors = ''.join(errors)
# Raise the exception with errors details
raise Exception(f"The general validations have failed. Please check that the environments meet the expected "
'requirements.')
f"requirements. Result:\n{errors}")
# -------------------------------------------------- End of Step 3 -------------------------------------------------

# ------------------------------------ Step 4: Execute test-specific validations -----------------------------------
Expand Down
17 changes: 15 additions & 2 deletions tests/end_to_end/data/env_requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,21 @@
"distros": []
}
},
"test_brute_force": {
"test_brute_force_ssh": {
"manager": {
"instances": 1,
"distros": [
"CentOS"
]
},
"agent": {
"instances": 1,
"distros": [
"CentOS"
]
}
},
"test_brute_force_rdp": {
"manager": {
"instances": 1,
"distros": [
Expand All @@ -33,7 +47,6 @@
"agent": {
"instances": 2,
"distros": [
"CentOS",
"Windows"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
delegate_to: localhost
when: (os == 'Linux' and 'server' in wazuh_info.stdout)

- debug: var=test_result
when: test_result is failed

- debug: var=test_result.stderr

- name: Check the connection between Controller node and Wazuh Indexer
set_fact:
check_result: 'true'
Expand Down
4 changes: 4 additions & 0 deletions tests/end_to_end/roles/host_checker/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
# ----------------------------------------------------------------------------

# -------- Task to identify whether the validation step fails or not. --------
- set_fact:
phase_results: "{{ errors }}"
cacheable: yes

- name: Verify if any check have failed
fail:
msg: "Some validations were fail:\n'{{ errors }}'"
Expand Down

0 comments on commit 0d81f1b

Please sign in to comment.