mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
Split integration tests out from Makefile. (#17976)
This commit is contained in:
parent
bf3d546d9a
commit
80a5c70ad7
169 changed files with 612 additions and 420 deletions
2
test/integration/targets/test_infra/inventory.local
Normal file
2
test/integration/targets/test_infra/inventory.local
Normal file
|
@ -0,0 +1,2 @@
|
|||
testhost ansible_connection=local
|
||||
|
23
test/integration/targets/test_infra/runme.sh
Executable file
23
test/integration/targets/test_infra/runme.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ux
|
||||
|
||||
# ensure fail/assert work locally and can stop execution with non-zero exit code
|
||||
PB_OUT=$(ansible-playbook -i inventory.local test_test_infra.yml)
|
||||
APB_RC=$?
|
||||
echo "$PB_OUT"
|
||||
echo "rc was $APB_RC (must be non-zero)"
|
||||
[ $$APB_RC -ne 0 ]
|
||||
echo "ensure playbook output shows assert/fail works (True)"
|
||||
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
|
||||
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
|
||||
|
||||
# ensure we work using all specified test args, overridden inventory, etc
|
||||
PB_OUT=$(ansible-playbook -i ../../inventory test_test_infra.yml "$@")
|
||||
APB_RC=$?
|
||||
echo "$PB_OUT"
|
||||
echo "rc was $APB_RC (must be non-zero)"
|
||||
[ $$APB_RC -ne 0 ]
|
||||
echo "ensure playbook output shows assert/fail works (True)"
|
||||
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
|
||||
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
|
26
test/integration/targets/test_infra/test_test_infra.yml
Normal file
26
test/integration/targets/test_infra/test_test_infra.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
- hosts: testhost
|
||||
gather_facts: no
|
||||
tags:
|
||||
- always
|
||||
tasks:
|
||||
- name: ensure fail action produces a failing result
|
||||
fail:
|
||||
ignore_errors: yes
|
||||
register: fail_out
|
||||
|
||||
- debug:
|
||||
msg: fail works ({{ fail_out.failed }})
|
||||
|
||||
- name: ensure assert produces a failing result
|
||||
assert:
|
||||
that: false
|
||||
ignore_errors: yes
|
||||
register: assert_out
|
||||
|
||||
- debug:
|
||||
msg: assert works ({{ assert_out.failed }})
|
||||
|
||||
- name: EXPECTED FAILURE ensure fail action stops execution
|
||||
fail:
|
||||
msg: fail actually failed (this is expected)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue