From aeeba54d964655ea45ba781154eca858c607353e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 00:24:58 +0100 Subject: [PATCH 1/7] 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 From b882b78d354234e83dce33eb7ab7e316461f0f14 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 15:20:44 +0100 Subject: [PATCH 2/7] tests: clean up remaining reg tests Delete some that are impossible to detect, fix up the remainder to detect the condition they describe. --- .../custom_python_detect_environment.py | 1 + .../modules/custom_python_leaky_class_vars.py | 25 +++++++++ tests/ansible/regression/all.yml | 14 ++--- ..._109__target_has_old_ansible_installed.yml | 8 +-- tests/ansible/regression/issue_113.yml | 17 ------ .../issue_113__duplicate_module_imports.yml | 24 ++++++++ ... => issue_118__script_not_marked_exec.yml} | 9 ++- tests/ansible/regression/issue_122.yml | 5 -- .../issue_122__environment_difference.yml | 14 +++++ tests/ansible/regression/issue_131.yml | 56 ------------------- tests/ansible/regression/issue_140.yml | 24 -------- .../regression/issue_140__thread_pileup.yml | 29 ++++++++++ ...ue_152__local_action_wrong_interpreter.yml | 42 +++++++++----- .../issue_152__virtualenv_python_fails.yml | 32 ++++++----- tests/ansible/regression/issue_154.yml | 22 -------- .../issue_154__module_state_leaks.yml | 18 ++++++ tests/ansible/regression/issue_174.yml | 5 -- tests/ansible/regression/issue_177.yml | 7 --- .../issue_177__copy_module_failing.yml | 19 +++++++ 19 files changed, 187 insertions(+), 184 deletions(-) create mode 100644 tests/ansible/lib/modules/custom_python_leaky_class_vars.py delete mode 100644 tests/ansible/regression/issue_113.yml create mode 100644 tests/ansible/regression/issue_113__duplicate_module_imports.yml rename tests/ansible/regression/{issue_118.yml => issue_118__script_not_marked_exec.yml} (51%) delete mode 100644 tests/ansible/regression/issue_122.yml create mode 100644 tests/ansible/regression/issue_122__environment_difference.yml delete mode 100644 tests/ansible/regression/issue_131.yml delete mode 100644 tests/ansible/regression/issue_140.yml create mode 100644 tests/ansible/regression/issue_140__thread_pileup.yml delete mode 100644 tests/ansible/regression/issue_154.yml create mode 100644 tests/ansible/regression/issue_154__module_state_leaks.yml delete mode 100644 tests/ansible/regression/issue_174.yml delete mode 100644 tests/ansible/regression/issue_177.yml create mode 100644 tests/ansible/regression/issue_177__copy_module_failing.yml diff --git a/tests/ansible/lib/modules/custom_python_detect_environment.py b/tests/ansible/lib/modules/custom_python_detect_environment.py index d1136817..4387fd9e 100644 --- a/tests/ansible/lib/modules/custom_python_detect_environment.py +++ b/tests/ansible/lib/modules/custom_python_detect_environment.py @@ -13,6 +13,7 @@ import sys def main(): module = AnsibleModule(argument_spec={}) module.exit_json( + env=dict(os.environ), cwd=os.getcwd(), python_path=sys.path, pid=os.getpid(), diff --git a/tests/ansible/lib/modules/custom_python_leaky_class_vars.py b/tests/ansible/lib/modules/custom_python_leaky_class_vars.py new file mode 100644 index 00000000..1d342329 --- /dev/null +++ b/tests/ansible/lib/modules/custom_python_leaky_class_vars.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +# I am an Ansible new-style Python module. I leak state from each invocation +# into a class variable and a global variable. + +from ansible.module_utils.basic import AnsibleModule + + +leak1 = [] + + +class MyClass: + leak2 = [] + + +def main(): + module = AnsibleModule(argument_spec={'name': {'type': 'str'}}) + leak1.append(module.params['name']) + MyClass.leak2.append(module.params['name']) + module.exit_json( + leak1=leak1, + leak2=MyClass.leak2, + ) + +if __name__ == '__main__': + main() diff --git a/tests/ansible/regression/all.yml b/tests/ansible/regression/all.yml index d449958e..ecb9638c 100644 --- a/tests/ansible/regression/all.yml +++ b/tests/ansible/regression/all.yml @@ -1,11 +1,9 @@ - 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_113__duplicate_module_imports.yml +- import_playbook: issue_118__script_not_marked_exec.yml +- import_playbook: issue_122__environment_difference.yml +- import_playbook: issue_140__thread_pileup.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 +- import_playbook: issue_154__module_state_leaks.yml +- import_playbook: issue_177__copy_module_failing.yml 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 index acf1521f..3a00f6e1 100644 --- a/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml +++ b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml @@ -1,17 +1,15 @@ # issue #109: ensure that any 'ansible' module or package on the remote machine # does not conflict with operation. -- hosts: all +- name: regression/issue_109__target_has_old_ansible_installed.yml + hosts: all + any_errors_fatal: true 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 diff --git a/tests/ansible/regression/issue_113.yml b/tests/ansible/regression/issue_113.yml deleted file mode 100644 index d213ba02..00000000 --- a/tests/ansible/regression/issue_113.yml +++ /dev/null @@ -1,17 +0,0 @@ -- hosts: all - tasks: - - - name: Get auth token - uri: - url: "https://httpbin.org/post" - method: POST - body: "client_id=admin-cli&username=admin&\ - password=keycloak_admin_password&grant_type=password" - return_content: true - validate_certs: false - register: r_token - no_log: false - run_once: true - - - assert: - that: r_token.status == 200 diff --git a/tests/ansible/regression/issue_113__duplicate_module_imports.yml b/tests/ansible/regression/issue_113__duplicate_module_imports.yml new file mode 100644 index 00000000..0d3a7e18 --- /dev/null +++ b/tests/ansible/regression/issue_113__duplicate_module_imports.yml @@ -0,0 +1,24 @@ +# issue #113: ensure CookieJar duplicate import issue does not reappear simply +# by exercisizng the uri package. + +- name: regression/issue_113__duplicate_module_imports.yml + any_errors_fatal: true + hosts: all + tasks: + + - name: Get auth token + uri: + url: "http://127.0.0.1:14321/post" + method: POST + body: "client_id=admin-cli&username=admin&\ + password=keycloak_admin_password&grant_type=password" + return_content: true + validate_certs: false + register: out + ignore_errors: true + + - assert: + that: + - out.status == -1 + - out.url == 'http://127.0.0.1:14321/post' + diff --git a/tests/ansible/regression/issue_118.yml b/tests/ansible/regression/issue_118__script_not_marked_exec.yml similarity index 51% rename from tests/ansible/regression/issue_118.yml rename to tests/ansible/regression/issue_118__script_not_marked_exec.yml index 5b920db0..376addf0 100644 --- a/tests/ansible/regression/issue_118.yml +++ b/tests/ansible/regression/issue_118__script_not_marked_exec.yml @@ -1,9 +1,8 @@ # issue #118 repro: chmod +x not happening during script upload -# -- name: saytrue + +- name: regression/issue_118__script_not_marked_exec.yml hosts: all become: True - tasks: - - name: run script saytrue - script: scripts/issue_118_saytrue + + - script: scripts/issue_118_saytrue diff --git a/tests/ansible/regression/issue_122.yml b/tests/ansible/regression/issue_122.yml deleted file mode 100644 index d72ecf96..00000000 --- a/tests/ansible/regression/issue_122.yml +++ /dev/null @@ -1,5 +0,0 @@ -- hosts: all - tasks: - - script: scripts/print_env.sh - register: env - - debug: msg={{env}} diff --git a/tests/ansible/regression/issue_122__environment_difference.yml b/tests/ansible/regression/issue_122__environment_difference.yml new file mode 100644 index 00000000..a7e791c7 --- /dev/null +++ b/tests/ansible/regression/issue_122__environment_difference.yml @@ -0,0 +1,14 @@ +# issue #122: still-undiagnosed environment difference between vanilla and +# Mitogen Ansible. + +# +# TODO: finish me. +# + +- name: regression/issue_122__environment_difference.yml + hosts: all + tasks: + + - script: scripts/print_env.sh + register: env + - debug: msg={{env}} diff --git a/tests/ansible/regression/issue_131.yml b/tests/ansible/regression/issue_131.yml deleted file mode 100644 index a271c46b..00000000 --- a/tests/ansible/regression/issue_131.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Hopeful reproduction for issue #131. -# Run lots of steps (rather than just one) so WorkerProcess and suchlike -# machinery is constantly recreated. - -- hosts: all - tasks: - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" - - shell: "true" diff --git a/tests/ansible/regression/issue_140.yml b/tests/ansible/regression/issue_140.yml deleted file mode 100644 index f9dc2d2b..00000000 --- a/tests/ansible/regression/issue_140.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Reproduction for issue #140. - -- hosts: all - tasks: - - name: Create file tree - connection: local - shell: > - mkdir filetree; - for i in `seq 1 1000` ; do echo $i > filetree/$i ; done - args: - creates: filetree - - - - name: Delete remote file tree - shell: rm -rf /tmp/filetree - - - - name: Trigger nasty process pileup - synchronize: - src: "{{ item.src }}" - dest: "/tmp/filetree" - with_filetree: - - filetree - when: item.state == 'file' diff --git a/tests/ansible/regression/issue_140__thread_pileup.yml b/tests/ansible/regression/issue_140__thread_pileup.yml new file mode 100644 index 00000000..f5fcd804 --- /dev/null +++ b/tests/ansible/regression/issue_140__thread_pileup.yml @@ -0,0 +1,29 @@ +# issue #140: with_filetree use caused unbounded (>500) thread growth in target +# interpreter. No easy hook to check thread count, but doing a 1000 item +# with_items should crash for other reasons (RAM, file descriptor count, ..) + +- name: regression/issue_140__thread_pileup.yml + hosts: all + any_errors_fatal: true + tasks: + + - name: Create file tree + connection: local + shell: > + mkdir filetree; + for i in `seq 1 1000` ; do echo $i > filetree/$i ; done + args: + creates: filetree + + + - name: Delete remote file tree + shell: rm -rf /tmp/filetree + + + - name: Trigger nasty process pileup + synchronize: + src: "{{ item.src }}" + dest: "/tmp/filetree" + with_filetree: + - filetree + when: item.state == 'file' diff --git a/tests/ansible/regression/issue_152__local_action_wrong_interpreter.yml b/tests/ansible/regression/issue_152__local_action_wrong_interpreter.yml index e4b0adbc..df200469 100644 --- a/tests/ansible/regression/issue_152__local_action_wrong_interpreter.yml +++ b/tests/ansible/regression/issue_152__local_action_wrong_interpreter.yml @@ -1,19 +1,31 @@ # issue #152 (b): local connections were not receiving -# ansible_python_interpreter treatment, breaking virtualenvs. +# ansible_python_interpreter treatment, breaking virtualenvs. Verify this is +# fixed by writing out a wrapper script that sets an environment variable we +# can test for. -# To test: -# - Ensure system Python does not have boto3 installed. -# - Run /path/to/venv/ansible-playbook ... with the virtualenv deactivated. -# Observe success. -# - Run ansible-playbook ... with the virtualenv activated. Observe success. - -- hosts: all +- name: regression/issue_152__local_action_wrong_interpreter.yml + hosts: all + connection: local + any_errors_fatal: true tasks: - - name: regression/issue_152__local_action_wrong_interpreter.yml - connection: local - become: true - shell: pip uninstall boto3 - ignore_errors: true - - cloudformation_facts: - connection: local + - copy: + dest: /tmp/issue_152_interpreter.sh + mode: u+x + content: | + #!/bin/bash + export CUSTOM_INTERPRETER=1 + exec python2.7 "$@" + + - custom_python_detect_environment: + vars: + ansible_python_interpreter: /tmp/issue_152_interpreter.sh + register: out + + - assert: + that: + - out.env.CUSTOM_INTERPRETER == "1" + + - file: + path: /tmp/issue_152_interpreter.sh + state: absent diff --git a/tests/ansible/regression/issue_152__virtualenv_python_fails.yml b/tests/ansible/regression/issue_152__virtualenv_python_fails.yml index e6c60c99..9e9a9beb 100644 --- a/tests/ansible/regression/issue_152__virtualenv_python_fails.yml +++ b/tests/ansible/regression/issue_152__virtualenv_python_fails.yml @@ -1,19 +1,21 @@ -- hosts: all +- name: regression/issue_152__virtualenv_python_fails.yml + any_errors_fatal: true + hosts: all tasks: - - name: Make virtualenv - pip: - virtualenv: /tmp/issue_151_virtualenv - name: psycopg2 - - name: Use virtualenv for the Python interpeter - set_fact: ansible_python_interpreter=/tmp/issue_151_virtualenv/bin/python + # Can't use pip module because you can't fricking just create a virtualenv, + # must call it directly. + - shell: virtualenv /tmp/issue_152_virtualenv - - name: Ensure the app DB user exists - postgresql_user: - db: postgres - login_host: localhost - login_user: "{{ansible_user_id}}" - login_password: "x" - name: fakeuser - state: present + - custom_python_detect_environment: + vars: + ansible_python_interpreter: /tmp/issue_152_virtualenv/bin/python + register: out + - assert: + that: + - out.sys_executable == "/tmp/issue_152_virtualenv/bin/python" + + - file: + path: /tmp/issue_152_virtualenv + state: absent diff --git a/tests/ansible/regression/issue_154.yml b/tests/ansible/regression/issue_154.yml deleted file mode 100644 index 28c476e7..00000000 --- a/tests/ansible/regression/issue_154.yml +++ /dev/null @@ -1,22 +0,0 @@ -- hosts: all - become: true - vars: - repo_baseurl: "http://myurl.com" - default_repos: - - repo: demo-repo1 - description: Base software packages - url: "{{repo_baseurl}}/repo1" - - repo: demo-repo2 - description: Misc packages - url: "{{repo_baseurl}}/repo2" - tasks: - - name: Create multiple yum repos - yum_repository: - name: '{{item.repo}}' - http_caching: packages - gpgcheck: no - description: '{{item.description}}' - state: present - baseurl: '{{item.url}}' - enabled: yes - with_items: '{{ default_repos }}' diff --git a/tests/ansible/regression/issue_154__module_state_leaks.yml b/tests/ansible/regression/issue_154__module_state_leaks.yml new file mode 100644 index 00000000..471d92de --- /dev/null +++ b/tests/ansible/regression/issue_154__module_state_leaks.yml @@ -0,0 +1,18 @@ +# issue #154: yum_repository module leaks state via a class variable, so it +# must be reinitialized or cleared out somehow on each invocation. + +- name: regression/issue_154__module_state_leaks.yml + any_errors_fatal: true + hosts: all + tasks: + + - custom_python_leaky_class_vars: + name: David + with_sequence: start=0 end=3 + register: out + + - assert: + that: + - out.results[item|int].leak1 == ["David"] + - out.results[item|int].leak2 == ["David"] + with_sequence: start=0 end=3 diff --git a/tests/ansible/regression/issue_174.yml b/tests/ansible/regression/issue_174.yml deleted file mode 100644 index c64cc70f..00000000 --- a/tests/ansible/regression/issue_174.yml +++ /dev/null @@ -1,5 +0,0 @@ -- hosts: all - tasks: - - name: add nginx ppa - become: yes - apt_repository: repo='ppa:nginx/stable' update_cache=yes diff --git a/tests/ansible/regression/issue_177.yml b/tests/ansible/regression/issue_177.yml deleted file mode 100644 index 5137b73d..00000000 --- a/tests/ansible/regression/issue_177.yml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: all - tasks: - - name: copy repo configs - copy: src=/etc/{{ item }} dest=/tmp/{{item}} mode=0644 - with_items: - - passwd - - hosts diff --git a/tests/ansible/regression/issue_177__copy_module_failing.yml b/tests/ansible/regression/issue_177__copy_module_failing.yml new file mode 100644 index 00000000..2b192d91 --- /dev/null +++ b/tests/ansible/regression/issue_177__copy_module_failing.yml @@ -0,0 +1,19 @@ +- name: regression/issue_177__copy_module_failing.yml + any_errors_fatal: true + hosts: all + tasks: + + - copy: + src: /etc/{{item}} + dest: /tmp/{{item}} + mode: 0644 + with_items: + - passwd + - hosts + + - file: + path: /tmp/{{item}} + state: absent + with_items: + - passwd + - hosts From d827bdb848a7a8795b7d01785f3f5579936234b3 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 15:30:31 +0100 Subject: [PATCH 3/7] tests: fixes to get regression/ running under vanilla Ansible --- .travis/ansible_tests.sh | 6 +++--- tests/ansible/lib/action/mitogen_shutdown_all.py | 5 +++++ .../ansible/lib/modules/custom_python_detect_environment.py | 1 + .../issue_109__target_has_old_ansible_installed.yml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis/ansible_tests.sh b/.travis/ansible_tests.sh index 0b207c2f..0d6df4ae 100755 --- a/.travis/ansible_tests.sh +++ b/.travis/ansible_tests.sh @@ -1,5 +1,5 @@ #!/bin/bash -ex -# Run tests/ansible/integration/all.yml under Ansible and Ansible-Mitogen +# Run tests/ansible/all.yml under Ansible and Ansible-Mitogen TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-`pwd`}" TMPDIR="/tmp/ansible-tests-$$" @@ -58,7 +58,7 @@ echo travis_fold:end:job_setup echo travis_fold:start:mitogen_linear /usr/bin/time ./mitogen_ansible_playbook.sh \ - integration/all.yml \ + all.yml \ -vvv \ -i "${TMPDIR}/hosts" echo travis_fold:end:mitogen_linear @@ -66,7 +66,7 @@ echo travis_fold:end:mitogen_linear echo travis_fold:start:vanilla_ansible /usr/bin/time ./run_ansible_playbook.sh \ - integration/all.yml \ + all.yml \ -vvv \ -i "${TMPDIR}/hosts" echo travis_fold:end:vanilla_ansible diff --git a/tests/ansible/lib/action/mitogen_shutdown_all.py b/tests/ansible/lib/action/mitogen_shutdown_all.py index 7375bc30..65be8b20 100644 --- a/tests/ansible/lib/action/mitogen_shutdown_all.py +++ b/tests/ansible/lib/action/mitogen_shutdown_all.py @@ -15,6 +15,11 @@ from ansible.plugins.action import ActionBase class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): + if not type(self._connection).__module__.startswith('ansible_mitogen'): + return { + 'changed': False + } + self._connection._connect() return { 'changed': True, diff --git a/tests/ansible/lib/modules/custom_python_detect_environment.py b/tests/ansible/lib/modules/custom_python_detect_environment.py index 4387fd9e..e289744f 100644 --- a/tests/ansible/lib/modules/custom_python_detect_environment.py +++ b/tests/ansible/lib/modules/custom_python_detect_environment.py @@ -13,6 +13,7 @@ import sys def main(): module = AnsibleModule(argument_spec={}) module.exit_json( + argv=sys.argv, env=dict(os.environ), cwd=os.getcwd(), python_path=sys.path, 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 index 3a00f6e1..7c2eef46 100644 --- a/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml +++ b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml @@ -24,7 +24,7 @@ - assert: that: - env.cwd == ansible_user_dir - - env.python_path.count("") == 1 + - (not env.mitogen_loaded) or (env.python_path.count("") == 1) # Run some new-style modules that 'from ansible.module_utils...' - stat: From ce260933d9e058205e940604aa1b608e21e925a8 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 15:43:54 +0100 Subject: [PATCH 4/7] tests: consistent play naming everywhere --- .../integration/action/low_level_execute_command.yml | 6 ++---- tests/ansible/integration/action/make_tmp_path.yml | 6 ++---- tests/ansible/integration/action/remote_file_exists.yml | 6 ++---- tests/ansible/integration/action/transfer_data.yml | 7 ++++--- tests/ansible/integration/become/sudo_flags_failure.yml | 6 ++---- tests/ansible/integration/become/sudo_nonexistent.yml | 6 ++---- tests/ansible/integration/become/sudo_nopassword.yml | 6 ++---- tests/ansible/integration/become/sudo_password.yml | 6 ++---- tests/ansible/integration/become/sudo_requiretty.yml | 6 ++---- .../integration/connection_loader/local_blemished.yml | 6 +++--- .../integration/connection_loader/paramiko_unblemished.yml | 6 +++--- .../integration/connection_loader/ssh_blemished.yml | 6 +++--- .../ansible/integration/context_service/lru_one_target.yml | 6 ++---- .../integration/playbook_semantics/become_flags.yml | 6 ++---- .../ansible/integration/playbook_semantics/delegate_to.yml | 3 ++- .../ansible/integration/playbook_semantics/environment.yml | 3 ++- .../ansible/integration/playbook_semantics/with_items.yml | 6 ++---- tests/ansible/integration/runner/async_job_timeout.yml | 4 ++-- tests/ansible/integration/runner/async_one_job.yml | 3 ++- .../integration/runner/async_two_simultaneous_jobs.yml | 4 +++- .../ansible/integration/runner/builtin_command_module.yml | 7 ++++--- .../integration/runner/custom_bash_old_style_module.yml | 7 ++++--- .../integration/runner/custom_bash_want_json_module.yml | 6 +++--- .../integration/runner/custom_binary_producing_json.yml | 6 +++--- .../integration/runner/custom_binary_producing_junk.yml | 6 +++--- .../integration/runner/custom_binary_single_null.yml | 6 +++--- .../integration/runner/custom_perl_json_args_module.yml | 6 +++--- .../integration/runner/custom_perl_want_json_module.yml | 6 +++--- .../integration/runner/custom_python_json_args_module.yml | 6 +++--- .../integration/runner/custom_python_new_style_module.yml | 6 +++--- .../integration/runner/custom_python_want_json_module.yml | 6 +++--- tests/ansible/integration/runner/forking_behaviour.yml | 5 ++--- tests/ansible/integration/runner/remote_tmp.yml | 6 +++--- 33 files changed, 86 insertions(+), 101 deletions(-) diff --git a/tests/ansible/integration/action/low_level_execute_command.yml b/tests/ansible/integration/action/low_level_execute_command.yml index 25e3c90f..d900f143 100644 --- a/tests/ansible/integration/action/low_level_execute_command.yml +++ b/tests/ansible/integration/action/low_level_execute_command.yml @@ -1,11 +1,9 @@ # Verify the behaviour of _low_level_execute_command(). -- hosts: all +- name: integration/action__low_level_execute_command.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/action__low_level_execute_command.yml - assert: - that: true # "echo -en" to test we actually hit bash shell too. - name: Run raw module without sudo diff --git a/tests/ansible/integration/action/make_tmp_path.yml b/tests/ansible/integration/action/make_tmp_path.yml index b992ae54..4384aa86 100644 --- a/tests/ansible/integration/action/make_tmp_path.yml +++ b/tests/ansible/integration/action/make_tmp_path.yml @@ -1,11 +1,9 @@ -- hosts: all +- name: integration/action/make_tmp_path.yml + hosts: all any_errors_fatal: true gather_facts: true tasks: - - name: integration/action/make_tmp_path.yml - assert: - that: true - action_passthrough: method: _make_tmp_path diff --git a/tests/ansible/integration/action/remote_file_exists.yml b/tests/ansible/integration/action/remote_file_exists.yml index a4d2459f..bfda9656 100644 --- a/tests/ansible/integration/action/remote_file_exists.yml +++ b/tests/ansible/integration/action/remote_file_exists.yml @@ -1,10 +1,8 @@ -- hosts: all +- name: integration/action/remote_file_exists.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/action/remote_file_exists.yml - assert: - that: true - file: path: /tmp/does-not-exist diff --git a/tests/ansible/integration/action/transfer_data.yml b/tests/ansible/integration/action/transfer_data.yml index ad4ffa56..8f7381e3 100644 --- a/tests/ansible/integration/action/transfer_data.yml +++ b/tests/ansible/integration/action/transfer_data.yml @@ -1,9 +1,10 @@ -- hosts: all +- name: integration/action/transfer_data.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/action/transfer_data.yml - file: + + - file: path: /tmp/transfer-data state: absent diff --git a/tests/ansible/integration/become/sudo_flags_failure.yml b/tests/ansible/integration/become/sudo_flags_failure.yml index 0392e728..0ced9ddb 100644 --- a/tests/ansible/integration/become/sudo_flags_failure.yml +++ b/tests/ansible/integration/become/sudo_flags_failure.yml @@ -1,9 +1,7 @@ -- hosts: all +- name: integration/become/sudo_flags_failure.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/become/sudo_flags_failure.yml - assert: - that: true - name: Verify behaviour for bad sudo flags. shell: whoami diff --git a/tests/ansible/integration/become/sudo_nonexistent.yml b/tests/ansible/integration/become/sudo_nonexistent.yml index affcebfe..25d2dc47 100644 --- a/tests/ansible/integration/become/sudo_nonexistent.yml +++ b/tests/ansible/integration/become/sudo_nonexistent.yml @@ -1,9 +1,7 @@ -- hosts: all +- name: integration/become/sudo_nonexistent.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/become/sudo_nonexistent.yml - assert: - that: true - name: Verify behaviour for non-existent accounts. shell: whoami diff --git a/tests/ansible/integration/become/sudo_nopassword.yml b/tests/ansible/integration/become/sudo_nopassword.yml index 5aa345d0..1d50715c 100644 --- a/tests/ansible/integration/become/sudo_nopassword.yml +++ b/tests/ansible/integration/become/sudo_nopassword.yml @@ -1,11 +1,9 @@ # Verify passwordless sudo behaviour in various cases. -- hosts: all +- name: integration/become/sudo_basic.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/become/sudo_basic.yml - assert: - that: true - name: Verify we aren't root shell: whoami diff --git a/tests/ansible/integration/become/sudo_password.yml b/tests/ansible/integration/become/sudo_password.yml index b1355233..2f6f00e6 100644 --- a/tests/ansible/integration/become/sudo_password.yml +++ b/tests/ansible/integration/become/sudo_password.yml @@ -1,11 +1,9 @@ # Verify passwordful sudo behaviour -- hosts: all +- name: integration/become/sudo_password.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/become/sudo_password.yml - assert: - that: true - name: Ensure sudo password absent but required. shell: whoami diff --git a/tests/ansible/integration/become/sudo_requiretty.yml b/tests/ansible/integration/become/sudo_requiretty.yml index 3073241a..a31d5712 100644 --- a/tests/ansible/integration/become/sudo_requiretty.yml +++ b/tests/ansible/integration/become/sudo_requiretty.yml @@ -1,11 +1,9 @@ # Verify requiretty support -- hosts: all +- name: integration/become/sudo_requiretty.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/become/sudo_requiretty.yml - assert: - that: true - name: Verify we can login to a non-passworded requiretty account shell: whoami diff --git a/tests/ansible/integration/connection_loader/local_blemished.yml b/tests/ansible/integration/connection_loader/local_blemished.yml index bb53cc48..72e28ec2 100644 --- a/tests/ansible/integration/connection_loader/local_blemished.yml +++ b/tests/ansible/integration/connection_loader/local_blemished.yml @@ -1,10 +1,10 @@ # Ensure 'local' connections are grabbed. -- hosts: all +- name: integration/connection_loader__local_blemished.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/connection_loader__local_blemished.yml - determine_strategy: + - determine_strategy: - custom_python_detect_environment: connection: local diff --git a/tests/ansible/integration/connection_loader/paramiko_unblemished.yml b/tests/ansible/integration/connection_loader/paramiko_unblemished.yml index 4959b672..c29c25d2 100644 --- a/tests/ansible/integration/connection_loader/paramiko_unblemished.yml +++ b/tests/ansible/integration/connection_loader/paramiko_unblemished.yml @@ -1,10 +1,10 @@ # Ensure paramiko connections aren't grabbed. -- hosts: all +- name: integration/connection_loader__paramiko_unblemished.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/connection_loader__paramiko_unblemished.yml - custom_python_detect_environment: + - custom_python_detect_environment: connection: paramiko register: out diff --git a/tests/ansible/integration/connection_loader/ssh_blemished.yml b/tests/ansible/integration/connection_loader/ssh_blemished.yml index e39a3469..4f47a72f 100644 --- a/tests/ansible/integration/connection_loader/ssh_blemished.yml +++ b/tests/ansible/integration/connection_loader/ssh_blemished.yml @@ -1,10 +1,10 @@ # Ensure 'ssh' connections are grabbed. -- hosts: all +- name: integration/connection_loader__ssh_blemished.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/connection_loader__ssh_blemished.yml - determine_strategy: + - determine_strategy: - custom_python_detect_environment: connection: ssh diff --git a/tests/ansible/integration/context_service/lru_one_target.yml b/tests/ansible/integration/context_service/lru_one_target.yml index 3abd7b48..54264598 100644 --- a/tests/ansible/integration/context_service/lru_one_target.yml +++ b/tests/ansible/integration/context_service/lru_one_target.yml @@ -1,15 +1,13 @@ # Verify a maximum number of contexts are possible on one machine. -- hosts: all +- name: integration/context_service/lru_one_target.yml + hosts: all any_errors_fatal: true vars: max_interps: "{{lookup('env', 'MITOGEN_MAX_INTERPRETERS')}}" ubound: "{{max_interps|int + 1}}" tasks: - - name: integration/context_service/lru_one_target.yml - assert: - that: true - name: Reset all connections mitogen_shutdown_all: diff --git a/tests/ansible/integration/playbook_semantics/become_flags.yml b/tests/ansible/integration/playbook_semantics/become_flags.yml index 5922b062..1f1cb15c 100644 --- a/tests/ansible/integration/playbook_semantics/become_flags.yml +++ b/tests/ansible/integration/playbook_semantics/become_flags.yml @@ -2,12 +2,10 @@ # Test sudo_flags respects -E. # -- hosts: all +- name: integration/playbook_semantics/become_flags.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/playbook_semantics/become_flags.yml - assert: - that: true - name: "without -E" become: true diff --git a/tests/ansible/integration/playbook_semantics/delegate_to.yml b/tests/ansible/integration/playbook_semantics/delegate_to.yml index beb8bdc3..16c4b5a0 100644 --- a/tests/ansible/integration/playbook_semantics/delegate_to.yml +++ b/tests/ansible/integration/playbook_semantics/delegate_to.yml @@ -1,4 +1,5 @@ -- hosts: all +- name: integration/playbook_semantics/delegate_to.yml + hosts: all any_errors_fatal: true tasks: # diff --git a/tests/ansible/integration/playbook_semantics/environment.yml b/tests/ansible/integration/playbook_semantics/environment.yml index 8d956d49..47437d9b 100644 --- a/tests/ansible/integration/playbook_semantics/environment.yml +++ b/tests/ansible/integration/playbook_semantics/environment.yml @@ -1,6 +1,7 @@ # Ensure environment: is preserved during call. -- hosts: all +- name: integration/playbook_semantics/environment.yml + hosts: all any_errors_fatal: true tasks: - shell: echo $SOME_ENV diff --git a/tests/ansible/integration/playbook_semantics/with_items.yml b/tests/ansible/integration/playbook_semantics/with_items.yml index 35c4b3c5..876f7e03 100644 --- a/tests/ansible/integration/playbook_semantics/with_items.yml +++ b/tests/ansible/integration/playbook_semantics/with_items.yml @@ -1,12 +1,10 @@ # Verify with_items that modifies the execution environment still executes in # the correct context. -- hosts: all +- name: integration/playbook_semantics/with_items.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/playbook_semantics/with_items.yml - assert: - that: true - name: Spin up a few interpreters shell: whoami diff --git a/tests/ansible/integration/runner/async_job_timeout.yml b/tests/ansible/integration/runner/async_job_timeout.yml index 47857733..868b676d 100644 --- a/tests/ansible/integration/runner/async_job_timeout.yml +++ b/tests/ansible/integration/runner/async_job_timeout.yml @@ -1,7 +1,7 @@ # Verify 'async: ' functions as desired. - -- hosts: all +- name: integration/runner/async_job_timeout.yml + hosts: all any_errors_fatal: true tasks: diff --git a/tests/ansible/integration/runner/async_one_job.yml b/tests/ansible/integration/runner/async_one_job.yml index b6156cca..6933f82b 100644 --- a/tests/ansible/integration/runner/async_one_job.yml +++ b/tests/ansible/integration/runner/async_one_job.yml @@ -1,7 +1,8 @@ # Verify behaviour of a single asynchronous task, and presence of all output # fields. -- hosts: all +- name: integration/runner/async_one_job.yml + hosts: all any_errors_fatal: true tasks: diff --git a/tests/ansible/integration/runner/async_two_simultaneous_jobs.yml b/tests/ansible/integration/runner/async_two_simultaneous_jobs.yml index 4bf244d7..679608c5 100644 --- a/tests/ansible/integration/runner/async_two_simultaneous_jobs.yml +++ b/tests/ansible/integration/runner/async_two_simultaneous_jobs.yml @@ -1,4 +1,6 @@ -- hosts: all + +- name: integration/runner/async_two_simultaneous_jobs.yml + hosts: all any_errors_fatal: true tasks: diff --git a/tests/ansible/integration/runner/builtin_command_module.yml b/tests/ansible/integration/runner/builtin_command_module.yml index ca94a604..8cfcc25c 100644 --- a/tests/ansible/integration/runner/builtin_command_module.yml +++ b/tests/ansible/integration/runner/builtin_command_module.yml @@ -1,9 +1,10 @@ -- hosts: all + +- name: integration/runner__builtin_command_module.yml + hosts: all any_errors_fatal: true gather_facts: true tasks: - - name: integration/runner__builtin_command_module.yml - command: hostname + - command: hostname with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_bash_old_style_module.yml b/tests/ansible/integration/runner/custom_bash_old_style_module.yml index 3aa9fe52..030049ca 100644 --- a/tests/ansible/integration/runner/custom_bash_old_style_module.yml +++ b/tests/ansible/integration/runner/custom_bash_old_style_module.yml @@ -1,8 +1,9 @@ -- hosts: all +- name: integration/runner__custom_bash_old_style_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_bash_old_style_module.yml - custom_bash_old_style_module: + + - custom_bash_old_style_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_bash_want_json_module.yml b/tests/ansible/integration/runner/custom_bash_want_json_module.yml index 85e83e3e..4700aac5 100644 --- a/tests/ansible/integration/runner/custom_bash_want_json_module.yml +++ b/tests/ansible/integration/runner/custom_bash_want_json_module.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_bash_want_json_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_bash_want_json_module.yml - custom_bash_want_json_module: + - custom_bash_want_json_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_binary_producing_json.yml b/tests/ansible/integration/runner/custom_binary_producing_json.yml index 559d89b1..951a203b 100644 --- a/tests/ansible/integration/runner/custom_binary_producing_json.yml +++ b/tests/ansible/integration/runner/custom_binary_producing_json.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_binary_producing_json.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_binary_producing_json.yml - custom_binary_producing_json: + - custom_binary_producing_json: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_binary_producing_junk.yml b/tests/ansible/integration/runner/custom_binary_producing_junk.yml index 7bb83de2..1d526947 100644 --- a/tests/ansible/integration/runner/custom_binary_producing_junk.yml +++ b/tests/ansible/integration/runner/custom_binary_producing_junk.yml @@ -1,7 +1,7 @@ -- hosts: all +- name: integration/runner__custom_binary_producing_junk.yml + hosts: all tasks: - - name: integration/runner__custom_binary_producing_junk.yml - custom_binary_producing_junk: + - custom_binary_producing_junk: foo: true with_sequence: start=1 end={{end|default(1)}} ignore_errors: true diff --git a/tests/ansible/integration/runner/custom_binary_single_null.yml b/tests/ansible/integration/runner/custom_binary_single_null.yml index 6cce33d2..fa5a86ca 100644 --- a/tests/ansible/integration/runner/custom_binary_single_null.yml +++ b/tests/ansible/integration/runner/custom_binary_single_null.yml @@ -1,7 +1,7 @@ -- hosts: all +- name: integration/runner__custom_binary_single_null.yml + hosts: all tasks: - - name: integration/runner__custom_binary_single_null.yml - custom_binary_single_null: + - custom_binary_single_null: foo: true with_sequence: start=1 end={{end|default(1)}} ignore_errors: true diff --git a/tests/ansible/integration/runner/custom_perl_json_args_module.yml b/tests/ansible/integration/runner/custom_perl_json_args_module.yml index 1777798a..7606ef3d 100644 --- a/tests/ansible/integration/runner/custom_perl_json_args_module.yml +++ b/tests/ansible/integration/runner/custom_perl_json_args_module.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_perl_json_args_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_perl_json_args_module.yml - custom_perl_json_args_module: + - custom_perl_json_args_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_perl_want_json_module.yml b/tests/ansible/integration/runner/custom_perl_want_json_module.yml index dfe0894c..7bc4e75f 100644 --- a/tests/ansible/integration/runner/custom_perl_want_json_module.yml +++ b/tests/ansible/integration/runner/custom_perl_want_json_module.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_perl_want_json_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_perl_want_json_module.yml - custom_perl_want_json_module: + - custom_perl_want_json_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_python_json_args_module.yml b/tests/ansible/integration/runner/custom_python_json_args_module.yml index 027280df..b72de0a2 100644 --- a/tests/ansible/integration/runner/custom_python_json_args_module.yml +++ b/tests/ansible/integration/runner/custom_python_json_args_module.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_python_json_args_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_python_json_args_module.yml - custom_python_json_args_module: + - custom_python_json_args_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_python_new_style_module.yml b/tests/ansible/integration/runner/custom_python_new_style_module.yml index fce315ea..47b8ec36 100644 --- a/tests/ansible/integration/runner/custom_python_new_style_module.yml +++ b/tests/ansible/integration/runner/custom_python_new_style_module.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_python_new_style_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_python_new_style_module.yml - custom_python_new_style_module: + - custom_python_new_style_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/custom_python_want_json_module.yml b/tests/ansible/integration/runner/custom_python_want_json_module.yml index 82dc2efd..c1009fb7 100644 --- a/tests/ansible/integration/runner/custom_python_want_json_module.yml +++ b/tests/ansible/integration/runner/custom_python_want_json_module.yml @@ -1,8 +1,8 @@ -- hosts: all +- name: integration/runner__custom_python_want_json_module.yml + hosts: all any_errors_fatal: true tasks: - - name: integration/runner__custom_python_want_json_module.yml - custom_python_want_json_module: + - custom_python_want_json_module: foo: true with_sequence: start=1 end={{end|default(1)}} register: out diff --git a/tests/ansible/integration/runner/forking_behaviour.yml b/tests/ansible/integration/runner/forking_behaviour.yml index 51318ff4..35ec3bfa 100644 --- a/tests/ansible/integration/runner/forking_behaviour.yml +++ b/tests/ansible/integration/runner/forking_behaviour.yml @@ -1,12 +1,11 @@ -- hosts: all +- name: integration/runner/forking_behaviour.yml + hosts: all any_errors_fatal: true tasks: # Verify non-async jobs run in-process. - - debug: msg={{is_mitogen}} - - name: get process ID. custom_python_detect_environment: register: sync_proc1 diff --git a/tests/ansible/integration/runner/remote_tmp.yml b/tests/ansible/integration/runner/remote_tmp.yml index dfa85ba4..19b33f0a 100644 --- a/tests/ansible/integration/runner/remote_tmp.yml +++ b/tests/ansible/integration/runner/remote_tmp.yml @@ -3,12 +3,12 @@ # when generating temporary paths created by the runner.py code executing # remotely. # -- hosts: all +- name: integration/runner__remote_tmp.yml + hosts: all any_errors_fatal: true gather_facts: true tasks: - - name: integration/runner__remote_tmp.yml - bash_return_paths: + - bash_return_paths: register: output - assert: From b91785c9a1cd1aa741d453eb65f26036f9472e3e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 15:57:35 +0100 Subject: [PATCH 5/7] tests: workaround for issue_109 --- .../regression/issue_109__target_has_old_ansible_installed.yml | 2 -- 1 file changed, 2 deletions(-) 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 index 7c2eef46..d13f25bb 100644 --- a/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml +++ b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml @@ -5,8 +5,6 @@ hosts: all any_errors_fatal: true gather_facts: true - become: true - become_user: mitogen__user1 tasks: # Copy the naughty 'ansible' into place. From 1e882a72c0ef58b0bbc0b6be7804e3a93261f5d7 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 16:05:16 +0100 Subject: [PATCH 6/7] tests: install virtualenv in the Docker images. --- tests/build_docker_images.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/build_docker_images.py b/tests/build_docker_images.py index 262a8a46..758d0a9c 100755 --- a/tests/build_docker_images.py +++ b/tests/build_docker_images.py @@ -16,15 +16,16 @@ FROM debian:stable RUN apt-get update RUN \ apt-get install -y python2.7 openssh-server sudo rsync git strace \ - libjson-perl && \ - apt-get clean + libjson-perl python-virtualenv && \ + apt-get clean && \ + rm -rf /var/cache/apt """ CENTOS_DOCKERFILE = r""" FROM centos:7 RUN yum clean all && \ yum -y install -y python2.7 openssh-server sudo rsync git strace sudo \ - perl-JSON && \ + perl-JSON python-virtualenv && \ yum clean all && \ groupadd sudo && \ ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key From bdc76c8231433de7193f70be7f27867fba329a41 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 18 Apr 2018 16:43:27 +0100 Subject: [PATCH 7/7] parent: do not attempt to reap child twice. --- mitogen/parent.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 03373bbc..95cbbc14 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -483,14 +483,29 @@ class Stream(mitogen.core.Stream): ) ) - def on_disconnect(self, broker): + _reaped = False + + def _reap_child(self): + """ + Reap the child process during disconnection. + """ + if self._reaped: + # on_disconnect() may be invoked more than once, for example, if + # there is still a pending message to be sent after the first + # on_disconnect() call. + return + pid, status = os.waitpid(self.pid, os.WNOHANG) if pid: LOG.debug('%r: child process exit status was %d', self, status) else: LOG.debug('%r: child process still alive, sending SIGTERM', self) os.kill(self.pid, signal.SIGTERM) - pid, status = os.waitpid(self.pid, 0) + os.waitpid(self.pid, 0) + self._reaped = True + + def on_disconnect(self, broker): + self._reap_child() super(Stream, self).on_disconnect(broker) # Minimised, gzipped, base64'd and passed to 'python -c'. It forks, dups