mirror of https://github.com/ansible/ansible.git
Adding block integration tests
parent
f3b691ccaf
commit
f4bd3be71f
@ -0,0 +1,63 @@
|
||||
Using /etc/ansible/ansible.cfg as config file
|
||||
2 plays in test_blocks/main.yml
|
||||
|
||||
PLAY [simple block test] *******************************************************
|
||||
|
||||
TASK [setup] *******************************************************************
|
||||
ok: [localhost]
|
||||
|
||||
TASK [set block tasks run flag] ************************************************
|
||||
ok: [localhost] => {"ansible_facts": {"block_tasks_run": true}, "changed": false}
|
||||
|
||||
TASK [fail in tasks] ***********************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [set block rescue run flag] ***********************************************
|
||||
ok: [localhost] => {"ansible_facts": {"block_rescue_run": true}, "changed": false}
|
||||
|
||||
TASK [fail in rescue] **********************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [set block always run flag] ***********************************************
|
||||
ok: [localhost] => {"ansible_facts": {"block_always_run": true}, "changed": false}
|
||||
|
||||
TASK [set nested block always run flag] ****************************************
|
||||
ok: [localhost] => {"ansible_facts": {"nested_block_always_run": true}, "changed": false}
|
||||
|
||||
TASK [fail in always] **********************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [assert] ******************************************************************
|
||||
ok: [localhost] => {"changed": false, "msg": "all assertions passed"}
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [localhost] => {
|
||||
"msg": "TEST COMPLETE"
|
||||
}
|
||||
|
||||
PLAY [block with includes] *****************************************************
|
||||
|
||||
TASK [setup] *******************************************************************
|
||||
ok: [localhost]
|
||||
|
||||
TASK [include fail.yml in tasks] ***********************************************
|
||||
included: /data/devel/ansible/test/integration/test_blocks/fail.yml for localhost
|
||||
|
||||
TASK [fail] ********************************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "failed from tasks"}
|
||||
|
||||
TASK [set_fact] ****************************************************************
|
||||
ok: [localhost] => {"ansible_facts": {"rescue_run_after_include_fail": true}, "changed": false}
|
||||
|
||||
TASK [include fail.yml in rescue] **********************************************
|
||||
included: /data/devel/ansible/test/integration/test_blocks/fail.yml for localhost
|
||||
|
||||
TASK [fail] ********************************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "failed from rescue"}
|
||||
|
||||
TASK [set_fact] ****************************************************************
|
||||
ok: [localhost] => {"ansible_facts": {"always_run_after_include_fail_in_rescue": true}, "changed": false}
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
localhost : ok=12 changed=0 unreachable=0 failed=3
|
||||
|
@ -0,0 +1,57 @@
|
||||
Using /etc/ansible/ansible.cfg as config file
|
||||
2 plays in test.yml
|
||||
|
||||
PLAY [simple block test] *******************************************************
|
||||
|
||||
TASK [setup] *******************************************************************
|
||||
ok: [localhost]
|
||||
|
||||
TASK [set block tasks run flag] ************************************************
|
||||
ok: [localhost] => {"ansible_facts": {"block_tasks_run": true}, "changed": false}
|
||||
|
||||
TASK [fail in tasks] ***********************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [set block rescue run flag] ***********************************************
|
||||
ok: [localhost] => {"ansible_facts": {"block_rescue_run": true}, "changed": false}
|
||||
|
||||
TASK [fail in rescue] **********************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [set block always run flag] ***********************************************
|
||||
ok: [localhost] => {"ansible_facts": {"block_always_run": true}, "changed": false}
|
||||
|
||||
TASK [set nested block always run flag] ****************************************
|
||||
ok: [localhost] => {"ansible_facts": {"nested_block_always_run": true}, "changed": false}
|
||||
|
||||
TASK [fail in always] **********************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [assert] ******************************************************************
|
||||
ok: [localhost] => {"changed": false, "msg": "all assertions passed"}
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [localhost] => {
|
||||
"msg": "TEST COMPLETE"
|
||||
}
|
||||
|
||||
PLAY [block with includes] *****************************************************
|
||||
|
||||
TASK [setup] *******************************************************************
|
||||
ok: [localhost]
|
||||
|
||||
TASK [include fail.yml in tasks] ***********************************************
|
||||
included: /root/testing/test_blocks/fail.yml for localhost
|
||||
|
||||
TASK [fail] ********************************************************************
|
||||
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "failed from tasks"}
|
||||
|
||||
TASK [set_fact] ****************************************************************
|
||||
ok: [localhost] => {"ansible_facts": {"rescue_run_after_include_fail": true}, "changed": false}
|
||||
|
||||
TASK [set_fact] ****************************************************************
|
||||
ok: [localhost] => {"ansible_facts": {"always_run_after_include_fail_in_rescue": true}, "changed": false}
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
localhost : ok=11 changed=0 unreachable=0 failed=2
|
||||
|
@ -0,0 +1 @@
|
||||
- fail: msg="{{msg}}"
|
@ -0,0 +1,101 @@
|
||||
- name: simple block test
|
||||
hosts: localhost
|
||||
gather_facts: yes
|
||||
vars:
|
||||
block_tasks_run: false
|
||||
block_rescue_run: false
|
||||
block_always_run: false
|
||||
nested_block_always_run: false
|
||||
tasks_run_after_failure: false
|
||||
rescue_run_after_failure: false
|
||||
always_run_after_failure: false
|
||||
tasks:
|
||||
- block:
|
||||
- name: set block tasks run flag
|
||||
set_fact:
|
||||
block_tasks_run: true
|
||||
- name: fail in tasks
|
||||
fail:
|
||||
- name: tasks flag should not be set after failure
|
||||
set_fact:
|
||||
tasks_run_after_failure: true
|
||||
rescue:
|
||||
- name: set block rescue run flag
|
||||
set_fact:
|
||||
block_rescue_run: true
|
||||
- name: fail in rescue
|
||||
fail:
|
||||
- name: tasks flag should not be set after failure in rescue
|
||||
set_fact:
|
||||
rescue_run_after_failure: true
|
||||
always:
|
||||
- name: set block always run flag
|
||||
set_fact:
|
||||
block_always_run: true
|
||||
- block:
|
||||
- meta: noop
|
||||
always:
|
||||
- name: set nested block always run flag
|
||||
set_fact:
|
||||
nested_block_always_run: true
|
||||
- name: fail in always
|
||||
fail:
|
||||
- name: tasks flag should not be set after failure in always
|
||||
set_fact:
|
||||
always_run_after_failure: true
|
||||
- meta: clear_host_errors
|
||||
|
||||
post_tasks:
|
||||
- assert:
|
||||
that:
|
||||
- block_tasks_run
|
||||
- block_rescue_run
|
||||
- block_always_run
|
||||
- nested_block_always_run
|
||||
- not tasks_run_after_failure
|
||||
- not rescue_run_after_failure
|
||||
- not always_run_after_failure
|
||||
- debug: msg="TEST COMPLETE"
|
||||
|
||||
- name: block with includes
|
||||
hosts: localhost
|
||||
gather_facts: yes
|
||||
vars:
|
||||
rescue_run_after_include_fail: false
|
||||
always_run_after_include_fail_in_rescue: false
|
||||
tasks_run_after_failure: false
|
||||
rescue_run_after_failure: false
|
||||
always_run_after_failure: false
|
||||
tasks:
|
||||
- block:
|
||||
- name: include fail.yml in tasks
|
||||
include: fail.yml
|
||||
args:
|
||||
msg: "failed from tasks"
|
||||
- name: tasks flag should not be set after failure
|
||||
set_fact:
|
||||
tasks_run_after_failure: true
|
||||
rescue:
|
||||
- set_fact:
|
||||
rescue_run_after_include_fail: true
|
||||
- name: include fail.yml in rescue
|
||||
include: fail.yml
|
||||
args:
|
||||
msg: "failed from rescue"
|
||||
- name: tasks flag should not be set after failure in rescue
|
||||
set_fact:
|
||||
rescue_run_after_failure: true
|
||||
always:
|
||||
- set_fact:
|
||||
always_run_after_include_fail_in_rescue: true
|
||||
- meta: clear_host_errors
|
||||
|
||||
post_tasks:
|
||||
- assert:
|
||||
that:
|
||||
- rescue_run_after_include_fail
|
||||
- always_run_after_include_fail_in_rescue
|
||||
- not tasks_run_after_failure
|
||||
- not rescue_run_after_failure
|
||||
- not always_run_after_failure
|
||||
- debug: msg="TEST COMPLETE"
|
@ -0,0 +1,3 @@
|
||||
- include: fail.yml
|
||||
args:
|
||||
msg: "nested {{msg}}"
|
@ -0,0 +1,3 @@
|
||||
- include: nested_fail.yml
|
||||
args:
|
||||
msg: "nested {{msg}}"
|
Loading…
Reference in New Issue