summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPierre-Louis Bonicoli <pierre-louis.bonicoli@gmx.fr>2015-07-20 14:11:31 +0200
committerPierre-Louis Bonicoli <pierre-louis.bonicoli@gmx.fr>2015-07-20 14:41:03 +0200
commitaa23ea8462430a2b3b17a3a869a63c1617389ee2 (patch)
treef00de13cad4f47a3a96fa01586f4d1de1545469e /test
parentadded callback that skipts 'skipped' (diff)
downloadansible-aa23ea8462430a2b3b17a3a869a63c1617389ee2.tar.xz
ansible-aa23ea8462430a2b3b17a3a869a63c1617389ee2.zip
tests: checks that handlers work with loops
Diffstat (limited to 'test')
-rw-r--r--test/integration/Makefile3
-rw-r--r--test/integration/roles/test_handlers/handlers/main.yml2
-rw-r--r--test/integration/roles/test_handlers/tasks/main.yml14
-rw-r--r--test/integration/test_handlers.yml3
4 files changed, 20 insertions, 2 deletions
diff --git a/test/integration/Makefile b/test/integration/Makefile
index 3d4555b54f..ec790ae709 100644
--- a/test/integration/Makefile
+++ b/test/integration/Makefile
@@ -51,7 +51,8 @@ test_group_by:
ansible-playbook test_group_by.yml -i inventory.group_by -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
test_handlers:
- ansible-playbook test_handlers.yml -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
+ ansible-playbook test_handlers.yml --tags scenario1 -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
+ [ "$$(ansible-playbook test_handlers.yml --tags scenario2 -l A -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) | grep -Po 'RUNNING HANDLER \[test_handlers : \K[^\]]+')" = "test handler" ]
# Not forcing, should only run on successful host
[ "$$(ansible-playbook test_force_handlers.yml --tags normal -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ]
# Forcing from command line
diff --git a/test/integration/roles/test_handlers/handlers/main.yml b/test/integration/roles/test_handlers/handlers/main.yml
index 117741f825..b8ee48b5c8 100644
--- a/test/integration/roles/test_handlers/handlers/main.yml
+++ b/test/integration/roles/test_handlers/handlers/main.yml
@@ -1,3 +1,5 @@
- name: set handler fact
set_fact:
handler_called: True
+- name: test handler
+ debug: msg="handler called"
diff --git a/test/integration/roles/test_handlers/tasks/main.yml b/test/integration/roles/test_handlers/tasks/main.yml
index 6f11768188..1c1d819269 100644
--- a/test/integration/roles/test_handlers/tasks/main.yml
+++ b/test/integration/roles/test_handlers/tasks/main.yml
@@ -20,19 +20,33 @@
- name: reset handler_called variable to false for all hosts
set_fact:
handler_called: False
+ tags: scenario1
- name: notify the handler for host A only
shell: echo
notify:
- set handler fact
when: inventory_hostname == 'A'
+ tags: scenario1
- name: force handler execution now
meta: "flush_handlers"
+ tags: scenario1
- debug: var=handler_called
+ tags: scenario1
- name: validate the handler only ran on one host
assert:
that:
- "inventory_hostname == 'A' and handler_called == True or handler_called == False"
+ tags: scenario1
+
+- name: 'test notify with loop'
+ debug: msg='a task'
+ changed_when: item == 1
+ notify: test handler
+ with_items:
+ - 1
+ - 2
+ tags: scenario2
diff --git a/test/integration/test_handlers.yml b/test/integration/test_handlers.yml
index 6a5366408c..dafa9ceebe 100644
--- a/test/integration/test_handlers.yml
+++ b/test/integration/test_handlers.yml
@@ -4,7 +4,7 @@
gather_facts: False
connection: local
roles:
- - { role: test_handlers_meta }
+ - { role: test_handlers_meta, tags: ['scenario1'] }
- name: verify final handler was run
hosts: A
@@ -16,6 +16,7 @@
that:
- "not hostvars[inventory_hostname]['handler1_called']"
- "'handler2_called' in hostvars[inventory_hostname]"
+ tags: ['scenario1']
- name: test handlers
hosts: testgroup