Skip to content

Commit bb3600a

Browse files
committed
solve the logger_test
1 parent b5edbe7 commit bb3600a

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

.github/workflows/check_plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
- uses: actions/checkout@v3
99
- run: python3 -m pip install ansible
1010
- name: Run the test_logger playbook.
11-
run: cd ci && rm -rf test_run_result.out && ${HOME}/.local/bin/ansible-playbook -v github/test_logger.yml && diff -s test_run_result.out github/test_logger_expected
11+
run: cd ci && rm -rf ~/test_run_result.out && ${HOME}/.local/bin/ansible-playbook -v github/test_logger.yml && diff -s ~/test_run_result.out github/test_logger_expected
1212

callback_plugins/custom_logger.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def __init__(self):
3434
self.output_dir = os.path.expanduser("~/")
3535
self.results = {}
3636

37-
#def playbook_on_stats(self, stats):
38-
# Log results for each host
39-
# hosts= stats.processed
40-
# for host in hosts:
41-
# self.log_summary_results(host)
37+
def playbook_on_stats(self, stats):
38+
#Log results for each host
39+
hosts= stats.processed
40+
for host in hosts:
41+
self.log_summary_results(host)
4242

4343
def log_task_result(self, host, result, task_name):
4444
# test_run_result.out only interested in the test tasks, not setup or debug.

ci/report_result.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
ansible.builtin.shell:
44
cmd: |
55
cp ~/test_run_result.out {{ autoscaling_logs_dir }}/test_run_result.log
6-
cp ~/summary_results.log {{ autoscaling_logs_dir }}/summary_results.log
6+
# cp ~/summary_results.log {{ autoscaling_logs_dir }}/summary_results.log
77
88
- name: Grep the number of failed tasks
99
ansible.builtin.shell:
1010
cmd: |
11-
grep "Tasks Failed:" ~/summary_results.log | awk '{print $3}'
11+
grep -c "failed" ~/test_run_result.out
1212
register: tasks_failed
13+
changed_when: false
1314

1415
- name: Determine success or failure based on the number of failed tasks
1516
ansible.builtin.assert:
1617
that:
17-
- tasks_failed.stdout == "0"
18-
fail_msg: "Tasks Failed: {{ tasks_failed.stdout }}. Check the logs in {{ autoscaling_logs_dir }}/summary_results.log."
18+
- tasks_failed.stdout|int == 0
19+
fail_msg: "Tasks Failed: {{ tasks_failed.stdout }}. Check the logs ."
1920
success_msg: "Tasks Failed: {{ tasks_failed.stdout }}. All tasks succeeded."

0 commit comments

Comments
 (0)