summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatt Davis <mdavis@ansible.com>2016-12-22 16:50:08 -0800
committerMatt Davis <mdavis@ansible.com>2016-12-23 09:48:23 -0800
commit7683715cafaa9145f40f53e5911e11fb00fa4da8 (patch)
tree8ae5d3eef901544aa88c24eb82f006ae9d44e814 /test
parent3c7987f3a4f467bef9ee05c6d58e463cbc95abae (diff)
downloadansible-7683715cafaa9145f40f53e5911e11fb00fa4da8.tar.gz
fix multiple handler notifications
Fixes #19647 Adds integration test to catch multiple handler notifications (cherry picked from commit c2495677b0364d7e31dfcb51865976ba46586732)
Diffstat (limited to 'test')
-rw-r--r--test/integration/roles/test_handlers_meta/handlers/main.yml3
-rw-r--r--test/integration/roles/test_handlers_meta/tasks/main.yml35
2 files changed, 38 insertions, 0 deletions
diff --git a/test/integration/roles/test_handlers_meta/handlers/main.yml b/test/integration/roles/test_handlers_meta/handlers/main.yml
index 634e6eca2a..9996625a1c 100644
--- a/test/integration/roles/test_handlers_meta/handlers/main.yml
+++ b/test/integration/roles/test_handlers_meta/handlers/main.yml
@@ -5,3 +5,6 @@
- name: set_handler_fact_2
set_fact:
handler2_called: True
+
+- name: count_handler
+ shell: echo . >> {{ handler_countpath }}
diff --git a/test/integration/roles/test_handlers_meta/tasks/main.yml b/test/integration/roles/test_handlers_meta/tasks/main.yml
index 047b61ce88..46f4859287 100644
--- a/test/integration/roles/test_handlers_meta/tasks/main.yml
+++ b/test/integration/roles/test_handlers_meta/tasks/main.yml
@@ -30,6 +30,41 @@
- "handler1_called is defined"
- "handler2_called is not defined"
+- name: make a tempfile for counting
+ shell: mktemp
+ register: mktemp_out
+
+- name: register tempfile path
+ set_fact:
+ handler_countpath: "{{ mktemp_out.stdout }}"
+
+- name: notify the counting handler
+ shell: echo
+ notify:
+ - count_handler
+
+- name: notify the counting handler again
+ shell: echo
+ notify:
+ - count_handler
+
+- name: force handler execution now
+ meta: flush_handlers
+
+- name: get handler execution count
+ shell: cat {{ handler_countpath }} | grep -o . | wc -l
+ register: exec_count_out
+
+- debug: var=exec_count_out.stdout
+
+- name: ensure single execution
+ assert:
+ that:
+ - exec_count_out.stdout | int == 1
+
+- name: cleanup tempfile
+ file: path={{ handler_countpath }} state=absent
+
- name: reset handler1_called
set_fact:
handler1_called: False