From aeeba54d964655ea45ba781154eca858c607353e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 00:24:58 +0100 Subject: [PATCH] tests: better regression test for issue #109 --- .../custom_python_detect_environment.py | 2 ++ tests/ansible/regression/all.yml | 6 ++-- tests/ansible/regression/files/ansible.py | 3 ++ tests/ansible/regression/issue_109.yml | 5 --- ..._109__target_has_old_ansible_installed.yml | 33 +++++++++++++++++++ .../regression/roles/issue_109/tasks/main.yml | 9 ----- .../issue_109_add_ssh_key/tasks/main.yml | 4 --- .../issue_109_gather_facts/tasks/main.yml | 4 --- .../regression/scripts/issue_118_saytrue | 2 +- 9 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 tests/ansible/regression/files/ansible.py delete mode 100644 tests/ansible/regression/issue_109.yml create mode 100644 tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml delete mode 100644 tests/ansible/regression/roles/issue_109/tasks/main.yml delete mode 100644 tests/ansible/regression/roles/issue_109_add_ssh_key/tasks/main.yml delete mode 100644 tests/ansible/regression/roles/issue_109_gather_facts/tasks/main.yml diff --git a/tests/ansible/lib/modules/custom_python_detect_environment.py b/tests/ansible/lib/modules/custom_python_detect_environment.py index 5493fdc1..d1136817 100644 --- a/tests/ansible/lib/modules/custom_python_detect_environment.py +++ b/tests/ansible/lib/modules/custom_python_detect_environment.py @@ -13,6 +13,8 @@ import sys def main(): module = AnsibleModule(argument_spec={}) module.exit_json( + cwd=os.getcwd(), + python_path=sys.path, pid=os.getpid(), ppid=os.getppid(), uid=os.getuid(), diff --git a/tests/ansible/regression/all.yml b/tests/ansible/regression/all.yml index c601f919..d449958e 100644 --- a/tests/ansible/regression/all.yml +++ b/tests/ansible/regression/all.yml @@ -1,11 +1,11 @@ -- import_playbook: issue_109.yml +- import_playbook: issue_109__target_has_old_ansible_installed.yml - import_playbook: issue_113.yml - import_playbook: issue_118.yml - import_playbook: issue_122.yml - import_playbook: issue_131.yml - import_playbook: issue_140.yml -- import_playbook: issue_152.yml -- import_playbook: issue_152b.yml +- import_playbook: issue_152__local_action_wrong_interpreter.yml +- import_playbook: issue_152__virtualenv_python_fails.yml - import_playbook: issue_154.yml - import_playbook: issue_174.yml - import_playbook: issue_177.yml diff --git a/tests/ansible/regression/files/ansible.py b/tests/ansible/regression/files/ansible.py new file mode 100644 index 00000000..03470e3c --- /dev/null +++ b/tests/ansible/regression/files/ansible.py @@ -0,0 +1,3 @@ +# I am a dummy ansible.py, that would cause 'import ansible' to fail to trigger +# the Mitogen module loader prior to issue #109. I don't need to contain +# anything, I just need to exist on PYTHONPATH. diff --git a/tests/ansible/regression/issue_109.yml b/tests/ansible/regression/issue_109.yml deleted file mode 100644 index b47a225f..00000000 --- a/tests/ansible/regression/issue_109.yml +++ /dev/null @@ -1,5 +0,0 @@ -# Reproduction for issue #109. - -- hosts: all - roles: - - issue_109 diff --git a/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml new file mode 100644 index 00000000..acf1521f --- /dev/null +++ b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml @@ -0,0 +1,33 @@ +# issue #109: ensure that any 'ansible' module or package on the remote machine +# does not conflict with operation. + +- hosts: all + gather_facts: true + become: true + become_user: mitogen__user1 + tasks: + - name: regression/issue_109__target_has_old_ansible_installed.yml + assert: + that: true + + # Copy the naughty 'ansible' into place. + + - copy: + dest: "{{ansible_user_dir}}/ansible.py" + src: ansible.py + + # Restart the connection. + - mitogen_shutdown_all: + + - custom_python_detect_environment: + register: env + + # Verify interpreter config would actually trigger the bug. + - assert: + that: + - env.cwd == ansible_user_dir + - env.python_path.count("") == 1 + + # Run some new-style modules that 'from ansible.module_utils...' + - stat: + path: / diff --git a/tests/ansible/regression/roles/issue_109/tasks/main.yml b/tests/ansible/regression/roles/issue_109/tasks/main.yml deleted file mode 100644 index 6cb994ae..00000000 --- a/tests/ansible/regression/roles/issue_109/tasks/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- name: Decrypt SSH-Keys - include_role: - name: issue_109_add_ssh_key - -- name: Gather Facts - include_role: - name: issue_109_gather_facts diff --git a/tests/ansible/regression/roles/issue_109_add_ssh_key/tasks/main.yml b/tests/ansible/regression/roles/issue_109_add_ssh_key/tasks/main.yml deleted file mode 100644 index 69736565..00000000 --- a/tests/ansible/regression/roles/issue_109_add_ssh_key/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: Stub - debug: msg= diff --git a/tests/ansible/regression/roles/issue_109_gather_facts/tasks/main.yml b/tests/ansible/regression/roles/issue_109_gather_facts/tasks/main.yml deleted file mode 100644 index 6d4d0d9f..00000000 --- a/tests/ansible/regression/roles/issue_109_gather_facts/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: Gather facts - action: setup diff --git a/tests/ansible/regression/scripts/issue_118_saytrue b/tests/ansible/regression/scripts/issue_118_saytrue index 01118e0f..7ff5d883 100644 --- a/tests/ansible/regression/scripts/issue_118_saytrue +++ b/tests/ansible/regression/scripts/issue_118_saytrue @@ -1,2 +1,2 @@ #!/bin/bash -/bin/true +command true