Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions ansible/roles/test/tasks/run_command_with_log_analyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,24 @@
register: expects_found
when: errors_expected == true

- name: Check that expected error messages are found (negative tests only).
fail: msg="Expected error messages are not found while running {{ testname }} / {{ command_to_run }}"
when: errors_expected == true and expects_found.stdout == "0"

- name: Get the total number of error messages.
shell: grep "TOTAL MATCHES" "{{ test_out_dir }}/{{ summary_file }}" | sed -n "s/TOTAL MATCHES:[[:space:]]*//p"
register: errors_found

- name: Check the number of error messages (positive tests only).
fail: msg="{{ errors_found.stdout }} errors found while running {{ testname }} / {{ command_to_run }}."
when: errors_expected == false and errors_found.stdout != "0"

- name: Copy test data to host.
fetch: src={{ test_out_dir }}/{{ item }} dest=failed-test-data/{{ testname_unique }}/{{ item }}
fetch:
src: "{{ test_out_dir }}/{{ item }}"
dest: "test/{{ inventory_hostname }}/{{ item | basename }}"
flat: yes
with_items:
- "{{ summary_file }}"
- "{{ result_file }}"
when: (errors_expected == true and expects_found.stdout == "0") or (errors_expected == false and errors_found.stdout != "0")

- name: Check that expected error messages are found (negative tests only).
fail: msg="Expected error messages are not found while running {{ testname }} / {{ command_to_run }}"
when: errors_expected == true and expects_found.stdout == "0"

- name: Check the number of error messages (positive tests only).
fail: msg="{{ errors_found.stdout }} errors found while running {{ testname }} / {{ command_to_run }}."
when: errors_expected == false and errors_found.stdout != "0"