From 383ef3ea80bcb269d10b4fb2be23c7146d78242d Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 19 Mar 2020 22:05:43 -0700 Subject: Rename tests (#68356) * Rename `tests` test to match plugin type. * Rename `test_infra` test to avoid confusion. This test target is not a test for test plugins. * Rename `vars_prompt` test to avoid confusion. * Update sanity ignores. --- .../targets/builtin_vars_prompt/aliases | 3 + .../targets/builtin_vars_prompt/runme.sh | 6 + .../builtin_vars_prompt/test-vars_prompt.py | 127 +++++++++++++++++++++ .../targets/builtin_vars_prompt/unsafe.yml | 20 ++++ .../targets/builtin_vars_prompt/unsupported.yml | 18 +++ .../targets/builtin_vars_prompt/vars_prompt-1.yml | 15 +++ .../targets/builtin_vars_prompt/vars_prompt-2.yml | 16 +++ .../targets/builtin_vars_prompt/vars_prompt-3.yml | 17 +++ .../targets/builtin_vars_prompt/vars_prompt-4.yml | 16 +++ .../targets/builtin_vars_prompt/vars_prompt-5.yml | 14 +++ .../targets/builtin_vars_prompt/vars_prompt-6.yml | 20 ++++ .../targets/builtin_vars_prompt/vars_prompt-7.yml | 12 ++ test/integration/targets/infra/aliases | 3 + test/integration/targets/infra/inventory.local | 2 + test/integration/targets/infra/library/test.py | 21 ++++ test/integration/targets/infra/runme.sh | 39 +++++++ test/integration/targets/infra/test_test_infra.yml | 25 ++++ test/integration/targets/test_core/aliases | 2 + test/integration/targets/test_core/tasks/main.yml | 35 ++++++ test/integration/targets/test_infra/aliases | 3 - .../integration/targets/test_infra/inventory.local | 2 - .../integration/targets/test_infra/library/test.py | 21 ---- test/integration/targets/test_infra/runme.sh | 39 ------- .../targets/test_infra/test_test_infra.yml | 25 ---- test/integration/targets/tests/aliases | 2 - test/integration/targets/tests/tasks/main.yml | 35 ------ test/integration/targets/vars_prompt/aliases | 3 - test/integration/targets/vars_prompt/runme.sh | 6 - .../targets/vars_prompt/test-vars_prompt.py | 127 --------------------- test/integration/targets/vars_prompt/unsafe.yml | 20 ---- .../targets/vars_prompt/unsupported.yml | 18 --- .../targets/vars_prompt/vars_prompt-1.yml | 15 --- .../targets/vars_prompt/vars_prompt-2.yml | 16 --- .../targets/vars_prompt/vars_prompt-3.yml | 17 --- .../targets/vars_prompt/vars_prompt-4.yml | 16 --- .../targets/vars_prompt/vars_prompt-5.yml | 14 --- .../targets/vars_prompt/vars_prompt-6.yml | 20 ---- .../targets/vars_prompt/vars_prompt-7.yml | 12 -- test/sanity/ignore.txt | 8 +- 39 files changed, 415 insertions(+), 415 deletions(-) create mode 100644 test/integration/targets/builtin_vars_prompt/aliases create mode 100755 test/integration/targets/builtin_vars_prompt/runme.sh create mode 100644 test/integration/targets/builtin_vars_prompt/test-vars_prompt.py create mode 100644 test/integration/targets/builtin_vars_prompt/unsafe.yml create mode 100644 test/integration/targets/builtin_vars_prompt/unsupported.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-1.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-2.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-3.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-4.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-5.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-6.yml create mode 100644 test/integration/targets/builtin_vars_prompt/vars_prompt-7.yml create mode 100644 test/integration/targets/infra/aliases create mode 100644 test/integration/targets/infra/inventory.local create mode 100644 test/integration/targets/infra/library/test.py create mode 100755 test/integration/targets/infra/runme.sh create mode 100644 test/integration/targets/infra/test_test_infra.yml create mode 100644 test/integration/targets/test_core/aliases create mode 100644 test/integration/targets/test_core/tasks/main.yml delete mode 100644 test/integration/targets/test_infra/aliases delete mode 100644 test/integration/targets/test_infra/inventory.local delete mode 100644 test/integration/targets/test_infra/library/test.py delete mode 100755 test/integration/targets/test_infra/runme.sh delete mode 100644 test/integration/targets/test_infra/test_test_infra.yml delete mode 100644 test/integration/targets/tests/aliases delete mode 100644 test/integration/targets/tests/tasks/main.yml delete mode 100644 test/integration/targets/vars_prompt/aliases delete mode 100755 test/integration/targets/vars_prompt/runme.sh delete mode 100644 test/integration/targets/vars_prompt/test-vars_prompt.py delete mode 100644 test/integration/targets/vars_prompt/unsafe.yml delete mode 100644 test/integration/targets/vars_prompt/unsupported.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-1.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-2.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-3.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-4.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-5.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-6.yml delete mode 100644 test/integration/targets/vars_prompt/vars_prompt-7.yml diff --git a/test/integration/targets/builtin_vars_prompt/aliases b/test/integration/targets/builtin_vars_prompt/aliases new file mode 100644 index 0000000000..4317d11262 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/aliases @@ -0,0 +1,3 @@ +setup/always/setup_passlib +setup/always/setup_pexpect +shippable/posix/group4 diff --git a/test/integration/targets/builtin_vars_prompt/runme.sh b/test/integration/targets/builtin_vars_prompt/runme.sh new file mode 100755 index 0000000000..af5557940e --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/runme.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eux + +# Interactively test vars_prompt +python test-vars_prompt.py -i ../../inventory "$@" diff --git a/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py b/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py new file mode 100644 index 0000000000..6c805fdd90 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python + +import os +import pexpect +import sys + +from ansible.module_utils.six import PY2 + +if PY2: + log_buffer = sys.stdout +else: + log_buffer = sys.stdout.buffer + +env_vars = { + 'ANSIBLE_ROLES_PATH': './roles', + 'ANSIBLE_NOCOLOR': 'True', + 'ANSIBLE_RETRY_FILES_ENABLED': 'False', +} + + +def run_test(playbook, test_spec, args=None, timeout=10, env=None): + + if not env: + env = os.environ.copy() + env.update(env_vars) + + if not args: + args = sys.argv[1:] + + vars_prompt_test = pexpect.spawn( + 'ansible-playbook', + args=[playbook] + args, + timeout=timeout, + env=env, + ) + + vars_prompt_test.logfile = log_buffer + for item in test_spec[0]: + vars_prompt_test.expect(item[0]) + if item[1]: + vars_prompt_test.send(item[1]) + vars_prompt_test.expect(test_spec[1]) + vars_prompt_test.expect(pexpect.EOF) + vars_prompt_test.close() + + +# These are the tests to run. Each test is a playbook and a test_spec. +# +# The test_spec is a list with two elements. +# +# The first element is a list of two element tuples. The first is the regexp to look +# for in the output, the second is the line to send. +# +# The last element is the last string of text to look for in the output. +# +tests = [ + # Basic vars_prompt + {'playbook': 'vars_prompt-1.yml', + 'test_spec': [ + [('input:', 'some input\r')], + '"input": "some input"']}, + + # Custom prompt + {'playbook': 'vars_prompt-2.yml', + 'test_spec': [ + [('Enter some input:', 'some more input\r')], + '"input": "some more input"']}, + + # Test confirm, both correct and incorrect + {'playbook': 'vars_prompt-3.yml', + 'test_spec': [ + [('input:', 'confirm me\r'), + ('confirm input:', 'confirm me\r')], + '"input": "confirm me"']}, + + {'playbook': 'vars_prompt-3.yml', + 'test_spec': [ + [('input:', 'confirm me\r'), + ('confirm input:', 'incorrect\r'), + (r'\*\*\*\*\* VALUES ENTERED DO NOT MATCH \*\*\*\*', ''), + ('input:', 'confirm me\r'), + ('confirm input:', 'confirm me\r')], + '"input": "confirm me"']}, + + # Test private + {'playbook': 'vars_prompt-4.yml', + 'test_spec': [ + [('not_secret', 'this is displayed\r'), + ('this is displayed', '')], + '"not_secret": "this is displayed"']}, + + # Test hashing + {'playbook': 'vars_prompt-5.yml', + 'test_spec': [ + [('password', 'Scenic-Improving-Payphone\r'), + ('confirm password', 'Scenic-Improving-Payphone\r')], + r'"password": "\$6\$']}, + + # Test variables in prompt field + # https://github.com/ansible/ansible/issues/32723 + {'playbook': 'vars_prompt-6.yml', + 'test_spec': [ + [('prompt from variable:', 'input\r')], + '']}, + + # Test play vars coming from vars_prompt + # https://github.com/ansible/ansible/issues/37984 + {'playbook': 'vars_prompt-7.yml', + 'test_spec': [ + [('prompting for host:', 'testhost\r')], + r'testhost.*ok=1']}, + + # Test play unsafe toggle + {'playbook': 'unsafe.yml', + 'test_spec': [ + [('prompting for variable:', '{{whole}}\r')], + r'testhost.*ok=2']}, + + # Test unsupported keys + {'playbook': 'unsupported.yml', + 'test_spec': [ + [], + "Invalid vars_prompt data structure, found unsupported key 'when'"]}, +] + +for t in tests: + run_test(playbook=t['playbook'], test_spec=t['test_spec']) diff --git a/test/integration/targets/builtin_vars_prompt/unsafe.yml b/test/integration/targets/builtin_vars_prompt/unsafe.yml new file mode 100644 index 0000000000..348ce152d6 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/unsafe.yml @@ -0,0 +1,20 @@ +- name: Test vars_prompt unsafe + hosts: testhost + become: no + gather_facts: no + vars: + whole: INVALID + vars_prompt: + - name: input + prompt: prompting for variable + unsafe: true + + tasks: + - name: + assert: + that: + - input != whole + - input != 'INVALID' + + - debug: + var: input diff --git a/test/integration/targets/builtin_vars_prompt/unsupported.yml b/test/integration/targets/builtin_vars_prompt/unsupported.yml new file mode 100644 index 0000000000..eab02fd64f --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/unsupported.yml @@ -0,0 +1,18 @@ +- name: Test vars_prompt unsupported key + hosts: testhost + become: no + gather_facts: no + vars_prompt: + - name: input + prompt: prompting for variable + # Unsupported key for vars_prompt + when: foo is defined + + tasks: + - name: + assert: + that: + - input is not defined + + - debug: + var: input diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-1.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-1.yml new file mode 100644 index 0000000000..727c60e7fa --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-1.yml @@ -0,0 +1,15 @@ +- name: Basic vars_prompt test + hosts: testhost + become: no + gather_facts: no + + vars_prompt: + - name: input + + tasks: + - assert: + that: + - input == 'some input' + + - debug: + var: input diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-2.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-2.yml new file mode 100644 index 0000000000..d8f20db801 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-2.yml @@ -0,0 +1,16 @@ +- name: Test vars_prompt custom prompt + hosts: testhost + become: no + gather_facts: no + + vars_prompt: + - name: input + prompt: "Enter some input" + + tasks: + - assert: + that: + - input == 'some more input' + + - debug: + var: input diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-3.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-3.yml new file mode 100644 index 0000000000..f8148182b8 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-3.yml @@ -0,0 +1,17 @@ +- name: Test vars_prompt confirm + hosts: testhost + become: no + gather_facts: no + + vars_prompt: + - name: input + confirm: yes + + tasks: + - name: + assert: + that: + - input == 'confirm me' + + - debug: + var: input diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-4.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-4.yml new file mode 100644 index 0000000000..d33cc90215 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-4.yml @@ -0,0 +1,16 @@ +- name: Test vars_prompt not private + hosts: testhost + become: no + gather_facts: no + + vars_prompt: + - name: not_secret + private: no + + tasks: + - assert: + that: + - not_secret == 'this is displayed' + + - debug: + var: not_secret diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-5.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-5.yml new file mode 100644 index 0000000000..62c8ad8efa --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-5.yml @@ -0,0 +1,14 @@ +- name: Test vars_prompt hashing + hosts: testhost + become: no + gather_facts: no + + vars_prompt: + - name: password + confirm: yes + encrypt: sha512_crypt + salt: 'jESIyad4F08hP3Ta' + + tasks: + - debug: + var: password diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-6.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-6.yml new file mode 100644 index 0000000000..ea3fe6209c --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-6.yml @@ -0,0 +1,20 @@ +- name: Test vars_prompt custom variables in prompt + hosts: testhost + become: no + gather_facts: no + + vars: + prompt_var: prompt from variable + + vars_prompt: + - name: input + prompt: "{{ prompt_var }}" + + tasks: + - name: + assert: + that: + - input == 'input' + + - debug: + var: input diff --git a/test/integration/targets/builtin_vars_prompt/vars_prompt-7.yml b/test/integration/targets/builtin_vars_prompt/vars_prompt-7.yml new file mode 100644 index 0000000000..a6b086d0d7 --- /dev/null +++ b/test/integration/targets/builtin_vars_prompt/vars_prompt-7.yml @@ -0,0 +1,12 @@ +- name: Test vars_prompt play vars + hosts: "{{ target_hosts }}" + become: no + gather_facts: no + + vars_prompt: + - name: target_hosts + prompt: prompting for host + private: no + + tasks: + - ping: diff --git a/test/integration/targets/infra/aliases b/test/integration/targets/infra/aliases new file mode 100644 index 0000000000..d342950a28 --- /dev/null +++ b/test/integration/targets/infra/aliases @@ -0,0 +1,3 @@ +shippable/posix/group3 +needs/file/hacking/test-module.py +needs/file/lib/ansible/modules/system/ping.py diff --git a/test/integration/targets/infra/inventory.local b/test/integration/targets/infra/inventory.local new file mode 100644 index 0000000000..2baa1f88fb --- /dev/null +++ b/test/integration/targets/infra/inventory.local @@ -0,0 +1,2 @@ +testhost ansible_connection=local + diff --git a/test/integration/targets/infra/library/test.py b/test/integration/targets/infra/library/test.py new file mode 100644 index 0000000000..9386057517 --- /dev/null +++ b/test/integration/targets/infra/library/test.py @@ -0,0 +1,21 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from ansible.module_utils.basic import AnsibleModule + + +def main(): + module = AnsibleModule( + argument_spec=dict(), + ) + result = { + 'selinux_special_fs': module._selinux_special_fs, + 'tmpdir': module._tmpdir, + 'keep_remote_files': module._keep_remote_files, + 'version': module.ansible_version, + } + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/test/integration/targets/infra/runme.sh b/test/integration/targets/infra/runme.sh new file mode 100755 index 0000000000..7996a43140 --- /dev/null +++ b/test/integration/targets/infra/runme.sh @@ -0,0 +1,39 @@ +#!/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 + +set -e + +PING_MODULE_PATH="../../../../lib/ansible/modules/system/ping.py" + +# ensure test-module.py script works without passing Python interpreter path +../../../../hacking/test-module.py -m "$PING_MODULE_PATH" + +# ensure test-module.py script works well +../../../../hacking/test-module.py -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)" + +# ensure module.ansible_version is defined when using test-module.py +../../../../hacking/test-module.py -m library/test.py -I ansible_python_interpreter="$(which python)" <<< '{"ANSIBLE_MODULE_ARGS": {}}' + +# ensure exercising module code locally works +python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}' diff --git a/test/integration/targets/infra/test_test_infra.yml b/test/integration/targets/infra/test_test_infra.yml new file mode 100644 index 0000000000..706f9b8fca --- /dev/null +++ b/test/integration/targets/infra/test_test_infra.yml @@ -0,0 +1,25 @@ +- 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) diff --git a/test/integration/targets/test_core/aliases b/test/integration/targets/test_core/aliases new file mode 100644 index 0000000000..041b0cc7bc --- /dev/null +++ b/test/integration/targets/test_core/aliases @@ -0,0 +1,2 @@ +shippable/posix/group5 +skip/python2.6 # tests are controller only, and we no longer support Python 2.6 on the controller diff --git a/test/integration/targets/test_core/tasks/main.yml b/test/integration/targets/test_core/tasks/main.yml new file mode 100644 index 0000000000..739675066c --- /dev/null +++ b/test/integration/targets/test_core/tasks/main.yml @@ -0,0 +1,35 @@ +- name: Assert truthy tests work + assert: + that: + - '"string" is truthy' + - '"" is not truthy' + - True is truthy + - False is not truthy + - true is truthy + - false is not truthy + - 1 is truthy + - 0 is not truthy + - '[""] is truthy' + - '[] is not truthy' + - '"on" is truthy(convert_bool=True)' + - '"off" is not truthy(convert_bool=True)' + - '{} is not truthy' + - '{"key": "value"} is truthy' + +- name: Assert falsy tests work + assert: + that: + - '"string" is not falsy' + - '"" is falsy' + - True is not falsy + - False is falsy + - true is not falsy + - false is falsy + - 1 is not falsy + - 0 is falsy + - '[""] is not falsy' + - '[] is falsy' + - '"on" is not falsy(convert_bool=True)' + - '"off" is falsy(convert_bool=True)' + - '{} is falsy' + - '{"key": "value"} is not falsy' diff --git a/test/integration/targets/test_infra/aliases b/test/integration/targets/test_infra/aliases deleted file mode 100644 index d342950a28..0000000000 --- a/test/integration/targets/test_infra/aliases +++ /dev/null @@ -1,3 +0,0 @@ -shippable/posix/group3 -needs/file/hacking/test-module.py -needs/file/lib/ansible/modules/system/ping.py diff --git a/test/integration/targets/test_infra/inventory.local b/test/integration/targets/test_infra/inventory.local deleted file mode 100644 index 2baa1f88fb..0000000000 --- a/test/integration/targets/test_infra/inventory.local +++ /dev/null @@ -1,2 +0,0 @@ -testhost ansible_connection=local - diff --git a/test/integration/targets/test_infra/library/test.py b/test/integration/targets/test_infra/library/test.py deleted file mode 100644 index 9386057517..0000000000 --- a/test/integration/targets/test_infra/library/test.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from ansible.module_utils.basic import AnsibleModule - - -def main(): - module = AnsibleModule( - argument_spec=dict(), - ) - result = { - 'selinux_special_fs': module._selinux_special_fs, - 'tmpdir': module._tmpdir, - 'keep_remote_files': module._keep_remote_files, - 'version': module.ansible_version, - } - module.exit_json(**result) - - -if __name__ == '__main__': - main() diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh deleted file mode 100755 index 7996a43140..0000000000 --- a/test/integration/targets/test_infra/runme.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 - -set -e - -PING_MODULE_PATH="../../../../lib/ansible/modules/system/ping.py" - -# ensure test-module.py script works without passing Python interpreter path -../../../../hacking/test-module.py -m "$PING_MODULE_PATH" - -# ensure test-module.py script works well -../../../../hacking/test-module.py -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)" - -# ensure module.ansible_version is defined when using test-module.py -../../../../hacking/test-module.py -m library/test.py -I ansible_python_interpreter="$(which python)" <<< '{"ANSIBLE_MODULE_ARGS": {}}' - -# ensure exercising module code locally works -python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}' diff --git a/test/integration/targets/test_infra/test_test_infra.yml b/test/integration/targets/test_infra/test_test_infra.yml deleted file mode 100644 index 706f9b8fca..0000000000 --- a/test/integration/targets/test_infra/test_test_infra.yml +++ /dev/null @@ -1,25 +0,0 @@ -- 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) diff --git a/test/integration/targets/tests/aliases b/test/integration/targets/tests/aliases deleted file mode 100644 index 041b0cc7bc..0000000000 --- a/test/integration/targets/tests/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/posix/group5 -skip/python2.6 # tests are controller only, and we no longer support Python 2.6 on the controller diff --git a/test/integration/targets/tests/tasks/main.yml b/test/integration/targets/tests/tasks/main.yml deleted file mode 100644 index 739675066c..0000000000 --- a/test/integration/targets/tests/tasks/main.yml +++ /dev/null @@ -1,35 +0,0 @@ -- name: Assert truthy tests work - assert: - that: - - '"string" is truthy' - - '"" is not truthy' - - True is truthy - - False is not truthy - - true is truthy - - false is not truthy - - 1 is truthy - - 0 is not truthy - - '[""] is truthy' - - '[] is not truthy' - - '"on" is truthy(convert_bool=True)' - - '"off" is not truthy(convert_bool=True)' - - '{} is not truthy' - - '{"key": "value"} is truthy' - -- name: Assert falsy tests work - assert: - that: - - '"string" is not falsy' - - '"" is falsy' - - True is not falsy - - False is falsy - - true is not falsy - - false is falsy - - 1 is not falsy - - 0 is falsy - - '[""] is not falsy' - - '[] is falsy' - - '"on" is not falsy(convert_bool=True)' - - '"off" is falsy(convert_bool=True)' - - '{} is falsy' - - '{"key": "value"} is not falsy' diff --git a/test/integration/targets/vars_prompt/aliases b/test/integration/targets/vars_prompt/aliases deleted file mode 100644 index 4317d11262..0000000000 --- a/test/integration/targets/vars_prompt/aliases +++ /dev/null @@ -1,3 +0,0 @@ -setup/always/setup_passlib -setup/always/setup_pexpect -shippable/posix/group4 diff --git a/test/integration/targets/vars_prompt/runme.sh b/test/integration/targets/vars_prompt/runme.sh deleted file mode 100755 index af5557940e..0000000000 --- a/test/integration/targets/vars_prompt/runme.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -# Interactively test vars_prompt -python test-vars_prompt.py -i ../../inventory "$@" diff --git a/test/integration/targets/vars_prompt/test-vars_prompt.py b/test/integration/targets/vars_prompt/test-vars_prompt.py deleted file mode 100644 index 6c805fdd90..0000000000 --- a/test/integration/targets/vars_prompt/test-vars_prompt.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python - -import os -import pexpect -import sys - -from ansible.module_utils.six import PY2 - -if PY2: - log_buffer = sys.stdout -else: - log_buffer = sys.stdout.buffer - -env_vars = { - 'ANSIBLE_ROLES_PATH': './roles', - 'ANSIBLE_NOCOLOR': 'True', - 'ANSIBLE_RETRY_FILES_ENABLED': 'False', -} - - -def run_test(playbook, test_spec, args=None, timeout=10, env=None): - - if not env: - env = os.environ.copy() - env.update(env_vars) - - if not args: - args = sys.argv[1:] - - vars_prompt_test = pexpect.spawn( - 'ansible-playbook', - args=[playbook] + args, - timeout=timeout, - env=env, - ) - - vars_prompt_test.logfile = log_buffer - for item in test_spec[0]: - vars_prompt_test.expect(item[0]) - if item[1]: - vars_prompt_test.send(item[1]) - vars_prompt_test.expect(test_spec[1]) - vars_prompt_test.expect(pexpect.EOF) - vars_prompt_test.close() - - -# These are the tests to run. Each test is a playbook and a test_spec. -# -# The test_spec is a list with two elements. -# -# The first element is a list of two element tuples. The first is the regexp to look -# for in the output, the second is the line to send. -# -# The last element is the last string of text to look for in the output. -# -tests = [ - # Basic vars_prompt - {'playbook': 'vars_prompt-1.yml', - 'test_spec': [ - [('input:', 'some input\r')], - '"input": "some input"']}, - - # Custom prompt - {'playbook': 'vars_prompt-2.yml', - 'test_spec': [ - [('Enter some input:', 'some more input\r')], - '"input": "some more input"']}, - - # Test confirm, both correct and incorrect - {'playbook': 'vars_prompt-3.yml', - 'test_spec': [ - [('input:', 'confirm me\r'), - ('confirm input:', 'confirm me\r')], - '"input": "confirm me"']}, - - {'playbook': 'vars_prompt-3.yml', - 'test_spec': [ - [('input:', 'confirm me\r'), - ('confirm input:', 'incorrect\r'), - (r'\*\*\*\*\* VALUES ENTERED DO NOT MATCH \*\*\*\*', ''), - ('input:', 'confirm me\r'), - ('confirm input:', 'confirm me\r')], - '"input": "confirm me"']}, - - # Test private - {'playbook': 'vars_prompt-4.yml', - 'test_spec': [ - [('not_secret', 'this is displayed\r'), - ('this is displayed', '')], - '"not_secret": "this is displayed"']}, - - # Test hashing - {'playbook': 'vars_prompt-5.yml', - 'test_spec': [ - [('password', 'Scenic-Improving-Payphone\r'), - ('confirm password', 'Scenic-Improving-Payphone\r')], - r'"password": "\$6\$']}, - - # Test variables in prompt field - # https://github.com/ansible/ansible/issues/32723 - {'playbook': 'vars_prompt-6.yml', - 'test_spec': [ - [('prompt from variable:', 'input\r')], - '']}, - - # Test play vars coming from vars_prompt - # https://github.com/ansible/ansible/issues/37984 - {'playbook': 'vars_prompt-7.yml', - 'test_spec': [ - [('prompting for host:', 'testhost\r')], - r'testhost.*ok=1']}, - - # Test play unsafe toggle - {'playbook': 'unsafe.yml', - 'test_spec': [ - [('prompting for variable:', '{{whole}}\r')], - r'testhost.*ok=2']}, - - # Test unsupported keys - {'playbook': 'unsupported.yml', - 'test_spec': [ - [], - "Invalid vars_prompt data structure, found unsupported key 'when'"]}, -] - -for t in tests: - run_test(playbook=t['playbook'], test_spec=t['test_spec']) diff --git a/test/integration/targets/vars_prompt/unsafe.yml b/test/integration/targets/vars_prompt/unsafe.yml deleted file mode 100644 index 348ce152d6..0000000000 --- a/test/integration/targets/vars_prompt/unsafe.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: Test vars_prompt unsafe - hosts: testhost - become: no - gather_facts: no - vars: - whole: INVALID - vars_prompt: - - name: input - prompt: prompting for variable - unsafe: true - - tasks: - - name: - assert: - that: - - input != whole - - input != 'INVALID' - - - debug: - var: input diff --git a/test/integration/targets/vars_prompt/unsupported.yml b/test/integration/targets/vars_prompt/unsupported.yml deleted file mode 100644 index eab02fd64f..0000000000 --- a/test/integration/targets/vars_prompt/unsupported.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Test vars_prompt unsupported key - hosts: testhost - become: no - gather_facts: no - vars_prompt: - - name: input - prompt: prompting for variable - # Unsupported key for vars_prompt - when: foo is defined - - tasks: - - name: - assert: - that: - - input is not defined - - - debug: - var: input diff --git a/test/integration/targets/vars_prompt/vars_prompt-1.yml b/test/integration/targets/vars_prompt/vars_prompt-1.yml deleted file mode 100644 index 727c60e7fa..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-1.yml +++ /dev/null @@ -1,15 +0,0 @@ -- name: Basic vars_prompt test - hosts: testhost - become: no - gather_facts: no - - vars_prompt: - - name: input - - tasks: - - assert: - that: - - input == 'some input' - - - debug: - var: input diff --git a/test/integration/targets/vars_prompt/vars_prompt-2.yml b/test/integration/targets/vars_prompt/vars_prompt-2.yml deleted file mode 100644 index d8f20db801..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-2.yml +++ /dev/null @@ -1,16 +0,0 @@ -- name: Test vars_prompt custom prompt - hosts: testhost - become: no - gather_facts: no - - vars_prompt: - - name: input - prompt: "Enter some input" - - tasks: - - assert: - that: - - input == 'some more input' - - - debug: - var: input diff --git a/test/integration/targets/vars_prompt/vars_prompt-3.yml b/test/integration/targets/vars_prompt/vars_prompt-3.yml deleted file mode 100644 index f8148182b8..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-3.yml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Test vars_prompt confirm - hosts: testhost - become: no - gather_facts: no - - vars_prompt: - - name: input - confirm: yes - - tasks: - - name: - assert: - that: - - input == 'confirm me' - - - debug: - var: input diff --git a/test/integration/targets/vars_prompt/vars_prompt-4.yml b/test/integration/targets/vars_prompt/vars_prompt-4.yml deleted file mode 100644 index d33cc90215..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-4.yml +++ /dev/null @@ -1,16 +0,0 @@ -- name: Test vars_prompt not private - hosts: testhost - become: no - gather_facts: no - - vars_prompt: - - name: not_secret - private: no - - tasks: - - assert: - that: - - not_secret == 'this is displayed' - - - debug: - var: not_secret diff --git a/test/integration/targets/vars_prompt/vars_prompt-5.yml b/test/integration/targets/vars_prompt/vars_prompt-5.yml deleted file mode 100644 index 62c8ad8efa..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-5.yml +++ /dev/null @@ -1,14 +0,0 @@ -- name: Test vars_prompt hashing - hosts: testhost - become: no - gather_facts: no - - vars_prompt: - - name: password - confirm: yes - encrypt: sha512_crypt - salt: 'jESIyad4F08hP3Ta' - - tasks: - - debug: - var: password diff --git a/test/integration/targets/vars_prompt/vars_prompt-6.yml b/test/integration/targets/vars_prompt/vars_prompt-6.yml deleted file mode 100644 index ea3fe6209c..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-6.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: Test vars_prompt custom variables in prompt - hosts: testhost - become: no - gather_facts: no - - vars: - prompt_var: prompt from variable - - vars_prompt: - - name: input - prompt: "{{ prompt_var }}" - - tasks: - - name: - assert: - that: - - input == 'input' - - - debug: - var: input diff --git a/test/integration/targets/vars_prompt/vars_prompt-7.yml b/test/integration/targets/vars_prompt/vars_prompt-7.yml deleted file mode 100644 index a6b086d0d7..0000000000 --- a/test/integration/targets/vars_prompt/vars_prompt-7.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: Test vars_prompt play vars - hosts: "{{ target_hosts }}" - become: no - gather_facts: no - - vars_prompt: - - name: target_hosts - prompt: prompting for host - private: no - - tasks: - - ping: diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index c3b62ef6f4..abe067b72d 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -331,15 +331,15 @@ test/integration/targets/template/files/foo.dos.txt line-endings test/integration/targets/template/role_filter/filter_plugins/myplugin.py future-import-boilerplate test/integration/targets/template/role_filter/filter_plugins/myplugin.py metaclass-boilerplate test/integration/targets/template/templates/encoding_1252.j2 no-smart-quotes -test/integration/targets/test_infra/library/test.py future-import-boilerplate -test/integration/targets/test_infra/library/test.py metaclass-boilerplate +test/integration/targets/infra/library/test.py future-import-boilerplate +test/integration/targets/infra/library/test.py metaclass-boilerplate test/integration/targets/unicode/unicode.yml no-smart-quotes test/integration/targets/uri/files/testserver.py future-import-boilerplate test/integration/targets/uri/files/testserver.py metaclass-boilerplate test/integration/targets/var_precedence/ansible-var-precedence-check.py future-import-boilerplate test/integration/targets/var_precedence/ansible-var-precedence-check.py metaclass-boilerplate -test/integration/targets/vars_prompt/test-vars_prompt.py future-import-boilerplate -test/integration/targets/vars_prompt/test-vars_prompt.py metaclass-boilerplate +test/integration/targets/builtin_vars_prompt/test-vars_prompt.py future-import-boilerplate +test/integration/targets/builtin_vars_prompt/test-vars_prompt.py metaclass-boilerplate test/integration/targets/vault/test-vault-client.py future-import-boilerplate test/integration/targets/vault/test-vault-client.py metaclass-boilerplate test/integration/targets/wait_for/files/testserver.py future-import-boilerplate -- cgit v1.2.1