From 83acb89760132266f76a29ac5aa5605c700d5980 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 17 Jun 2019 11:18:27 +0000 Subject: [PATCH] [loganalyzer] Fix the files not copied issue in run_command_with_log_analyzer.yml The copy files task was after the fail tests. In case of failure, the copy task would never get a chance to run. This commit adjusted the task sequence. In case of failure, copy the files, then fail the test. The original copy task copies files with deep folder structure. This issue was also fixed in this commit. Signed-off-by: Xin Wang --- .../tasks/run_command_with_log_analyzer.yml | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ansible/roles/test/tasks/run_command_with_log_analyzer.yml b/ansible/roles/test/tasks/run_command_with_log_analyzer.yml index a9e5bd169f9..6f04d1e16d5 100644 --- a/ansible/roles/test/tasks/run_command_with_log_analyzer.yml +++ b/ansible/roles/test/tasks/run_command_with_log_analyzer.yml @@ -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"