From 4a2de764ecf9cfcbb57e33ab4d5b3f119b837230 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 17 Jan 2024 08:22:40 +0000 Subject: [PATCH] Fix issues with ansible-playbook-callbacks test (#82407) The timing of the async tasks was a little unpredictable, meaning that sometimes we would get an unexpected number of v2_runner_on_async_poll callbacks, and fail the test. This change fixes the issue by increasing the poll interval to 2 seconds and the sleep duration to 3 seconds, such that on a reasonably responsive system we will poll twice per task, with the sleep ending in the middle of the two polls. The include_me.yml file does not exist in this integration test. It has been added. The remote_tmp_dir.path expression is invalid - the setup_remote_tmp_dir role uses set_fact to set remote_tmp_dir to remote_tmp_dir.path. The integration tests run with ANSIBLE_HOST_PATTERN_MISMATCH=error, meaning that the final play was never reached. Set ANSIBLE_HOST_PATTERN_MISMATCH=warning to continue past the play and trigger the v2_playbook_on_no_hosts_matched callback. --- .../ansible-playbook-callbacks/all-callbacks.yml | 14 +++++++------- .../callbacks_list.expected | 12 +++++++----- .../ansible-playbook-callbacks/include_me.yml | 0 .../targets/ansible-playbook-callbacks/runme.sh | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 test/integration/targets/ansible-playbook-callbacks/include_me.yml diff --git a/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml b/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml index 8ea3a571897..85a53c744c6 100644 --- a/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml +++ b/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml @@ -96,14 +96,14 @@ ignore_errors: true - name: async poll ok - command: sleep 2 - async: 3 - poll: 1 + command: sleep 3 + async: 5 + poll: 2 - name: async poll failed - shell: sleep 2; false - async: 3 - poll: 1 + shell: sleep 3; false + async: 5 + poll: 2 ignore_errors: true - include_tasks: include_me.yml @@ -111,7 +111,7 @@ - name: diff copy: content: diff - dest: '{{ remote_tmp_dir.path }}/diff.txt' + dest: '{{ remote_tmp_dir }}/diff.txt' diff: true - hosts: i_dont_exist diff --git a/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected b/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected index 39e5cafa0e8..1d064a23db1 100644 --- a/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected +++ b/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected @@ -1,12 +1,14 @@ 1 __init__ -83 v2_on_any +92 v2_on_any + 1 v2_on_file_diff 4 v2_playbook_on_handler_task_start 2 v2_playbook_on_include + 1 v2_playbook_on_no_hosts_matched 3 v2_playbook_on_notify - 1 v2_playbook_on_play_start + 3 v2_playbook_on_play_start 1 v2_playbook_on_start 1 v2_playbook_on_stats -17 v2_playbook_on_task_start +19 v2_playbook_on_task_start 1 v2_playbook_on_vars_prompt 1 v2_runner_item_on_failed 2 v2_runner_item_on_ok @@ -15,8 +17,8 @@ 1 v2_runner_on_async_ok 2 v2_runner_on_async_poll 5 v2_runner_on_failed -15 v2_runner_on_ok +16 v2_runner_on_ok 1 v2_runner_on_skipped -21 v2_runner_on_start +23 v2_runner_on_start 1 v2_runner_on_unreachable 2 v2_runner_retry diff --git a/test/integration/targets/ansible-playbook-callbacks/include_me.yml b/test/integration/targets/ansible-playbook-callbacks/include_me.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/integration/targets/ansible-playbook-callbacks/runme.sh b/test/integration/targets/ansible-playbook-callbacks/runme.sh index 73c8a3d0799..933863e572f 100755 --- a/test/integration/targets/ansible-playbook-callbacks/runme.sh +++ b/test/integration/targets/ansible-playbook-callbacks/runme.sh @@ -5,6 +5,7 @@ set -eux export ANSIBLE_CALLBACK_PLUGINS=../support-callback_plugins/callback_plugins export ANSIBLE_ROLES_PATH=../ export ANSIBLE_STDOUT_CALLBACK=callback_debug +export ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook all-callbacks.yml 2>/dev/null | sort | uniq -c | tee callbacks_list.out