diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2023-10-25 09:42:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 09:42:13 +0200 |
commit | fe94a99aa291d129aa6432e5d50e7117d9c6aae3 (patch) | |
tree | fb3101b574eec8099975889d8f6a567f07f94386 /test/integration | |
parent | Remove obsolete requirements from prepare_http_tests (diff) | |
download | ansible-fe94a99aa291d129aa6432e5d50e7117d9c6aae3.tar.xz ansible-fe94a99aa291d129aa6432e5d50e7117d9c6aae3.zip |
any_errors_fatal fixes (#78680)
Fixes #31543
Fixes #36308
Fixes #73246
Fixes #80981
Fixes #81533
ci_complete
Diffstat (limited to 'test/integration')
8 files changed, 104 insertions, 0 deletions
diff --git a/test/integration/targets/any_errors_fatal/31543.yml b/test/integration/targets/any_errors_fatal/31543.yml new file mode 100644 index 0000000000..19b0ba879e --- /dev/null +++ b/test/integration/targets/any_errors_fatal/31543.yml @@ -0,0 +1,12 @@ +- hosts: testhost,testhost2 + gather_facts: false + any_errors_fatal: true + tasks: + - block: + - fail: + when: inventory_hostname == 'testhost' + always: + - debug: + + - debug: + msg: SHOULD NOT HAPPEN diff --git a/test/integration/targets/any_errors_fatal/36308.yml b/test/integration/targets/any_errors_fatal/36308.yml new file mode 100644 index 0000000000..ec5d1ae784 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/36308.yml @@ -0,0 +1,14 @@ +- hosts: testhost + gather_facts: false + any_errors_fatal: true + force_handlers: true + tasks: + - command: echo + notify: + - handler1 + + - fail: + handlers: + - name: handler1 + debug: + msg: handler1 ran diff --git a/test/integration/targets/any_errors_fatal/73246.yml b/test/integration/targets/any_errors_fatal/73246.yml new file mode 100644 index 0000000000..50f20d9715 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/73246.yml @@ -0,0 +1,11 @@ +- hosts: testhost + gather_facts: false + any_errors_fatal: true + tasks: + - block: + - block: + - fail: + always: + - block: + - debug: + msg: PASSED diff --git a/test/integration/targets/any_errors_fatal/80981.yml b/test/integration/targets/any_errors_fatal/80981.yml new file mode 100644 index 0000000000..51cf8dfe14 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/80981.yml @@ -0,0 +1,17 @@ +- hosts: testhost,testhost2 + gather_facts: false + any_errors_fatal: true + tasks: + - block: + - fail: + when: inventory_hostname == "testhost" + - name: any_errors_fatal fails all hosts when any of them fails + debug: + msg: SHOULD NOT HAPPEN + rescue: + - name: Rescues both hosts + debug: + msg: rescue + - name: You can recover from fatal errors by adding a rescue section to the block. + debug: + msg: recovered diff --git a/test/integration/targets/any_errors_fatal/runme.sh b/test/integration/targets/any_errors_fatal/runme.sh index c54ea8d5e0..58f0ddfcaf 100755 --- a/test/integration/targets/any_errors_fatal/runme.sh +++ b/test/integration/targets/any_errors_fatal/runme.sh @@ -35,3 +35,17 @@ for test_name in test_include_role test_include_tasks; do exit 1 fi done + +ansible-playbook -i inventory "$@" 31543.yml | tee out.txt +[ "$(grep -c 'SHOULD NOT HAPPEN' out.txt)" -eq 0 ] + +ansible-playbook -i inventory "$@" 36308.yml | tee out.txt +[ "$(grep -c 'handler1 ran' out.txt)" -eq 1 ] + +ansible-playbook -i inventory "$@" 73246.yml | tee out.txt +[ "$(grep -c 'PASSED' out.txt)" -eq 1 ] + +ansible-playbook -i inventory "$@" 80981.yml | tee out.txt +[ "$(grep -c 'SHOULD NOT HAPPEN' out.txt)" -eq 0 ] +[ "$(grep -c 'rescue' out.txt)" -eq 2 ] +[ "$(grep -c 'recovered' out.txt)" -eq 2 ] diff --git a/test/integration/targets/handlers/force_handlers_blocks_81533-1.yml b/test/integration/targets/handlers/force_handlers_blocks_81533-1.yml new file mode 100644 index 0000000000..20605e451e --- /dev/null +++ b/test/integration/targets/handlers/force_handlers_blocks_81533-1.yml @@ -0,0 +1,16 @@ +- hosts: A,B + gather_facts: false + force_handlers: true + tasks: + - fail: + when: inventory_hostname == "A" + + - run_once: true + block: + - debug: + msg: task1 + - debug: + msg: task2 + + - debug: + msg: hosts_left diff --git a/test/integration/targets/handlers/force_handlers_blocks_81533-2.yml b/test/integration/targets/handlers/force_handlers_blocks_81533-2.yml new file mode 100644 index 0000000000..4284a3751c --- /dev/null +++ b/test/integration/targets/handlers/force_handlers_blocks_81533-2.yml @@ -0,0 +1,12 @@ +- hosts: A,B + gather_facts: false + force_handlers: true + tasks: + - fail: + when: inventory_hostname == "A" + + - meta: clear_host_errors + when: false + + - debug: + msg: hosts_left diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh index 757200de38..e26fdd7a1b 100755 --- a/test/integration/targets/handlers/runme.sh +++ b/test/integration/targets/handlers/runme.sh @@ -198,3 +198,11 @@ ansible-playbook test_include_tasks_in_include_role.yml "$@" 2>&1 | tee out.txt ansible-playbook test_run_once.yml -i inventory.handlers "$@" 2>&1 | tee out.txt [ "$(grep out.txt -ce 'handler ran once')" = "1" ] + +ansible-playbook force_handlers_blocks_81533-1.yml -i inventory.handlers "$@" 2>&1 | tee out.txt +[ "$(grep out.txt -ce 'task1')" = "1" ] +[ "$(grep out.txt -ce 'task2')" = "1" ] +[ "$(grep out.txt -ce 'hosts_left')" = "1" ] + +ansible-playbook force_handlers_blocks_81533-2.yml -i inventory.handlers "$@" 2>&1 | tee out.txt +[ "$(grep out.txt -ce 'hosts_left')" = "1" ] |