tests: clean up remaining reg tests

Delete some that are impossible to detect, fix up the remainder to
detect the condition they describe.
pull/192/head
David Wilson 7 years ago
parent aeeba54d96
commit b882b78d35

@ -13,6 +13,7 @@ import sys
def main(): def main():
module = AnsibleModule(argument_spec={}) module = AnsibleModule(argument_spec={})
module.exit_json( module.exit_json(
env=dict(os.environ),
cwd=os.getcwd(), cwd=os.getcwd(),
python_path=sys.path, python_path=sys.path,
pid=os.getpid(), pid=os.getpid(),

@ -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()

@ -1,11 +1,9 @@
- import_playbook: issue_109__target_has_old_ansible_installed.yml - import_playbook: issue_109__target_has_old_ansible_installed.yml
- import_playbook: issue_113.yml - import_playbook: issue_113__duplicate_module_imports.yml
- import_playbook: issue_118.yml - import_playbook: issue_118__script_not_marked_exec.yml
- import_playbook: issue_122.yml - import_playbook: issue_122__environment_difference.yml
- import_playbook: issue_131.yml - import_playbook: issue_140__thread_pileup.yml
- import_playbook: issue_140.yml
- import_playbook: issue_152__local_action_wrong_interpreter.yml - import_playbook: issue_152__local_action_wrong_interpreter.yml
- import_playbook: issue_152__virtualenv_python_fails.yml - import_playbook: issue_152__virtualenv_python_fails.yml
- import_playbook: issue_154.yml - import_playbook: issue_154__module_state_leaks.yml
- import_playbook: issue_174.yml - import_playbook: issue_177__copy_module_failing.yml
- import_playbook: issue_177.yml

@ -1,17 +1,15 @@
# issue #109: ensure that any 'ansible' module or package on the remote machine # issue #109: ensure that any 'ansible' module or package on the remote machine
# does not conflict with operation. # 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 gather_facts: true
become: true become: true
become_user: mitogen__user1 become_user: mitogen__user1
tasks: tasks:
- name: regression/issue_109__target_has_old_ansible_installed.yml
assert:
that: true
# Copy the naughty 'ansible' into place. # Copy the naughty 'ansible' into place.
- copy: - copy:
dest: "{{ansible_user_dir}}/ansible.py" dest: "{{ansible_user_dir}}/ansible.py"
src: ansible.py src: ansible.py

@ -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

@ -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'

@ -1,9 +1,8 @@
# issue #118 repro: chmod +x not happening during script upload # issue #118 repro: chmod +x not happening during script upload
#
- name: saytrue - name: regression/issue_118__script_not_marked_exec.yml
hosts: all hosts: all
become: True become: True
tasks: tasks:
- name: run script saytrue
script: scripts/issue_118_saytrue - script: scripts/issue_118_saytrue

@ -1,5 +0,0 @@
- hosts: all
tasks:
- script: scripts/print_env.sh
register: env
- debug: msg={{env}}

@ -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}}

@ -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"

@ -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'

@ -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'

@ -1,19 +1,31 @@
# issue #152 (b): local connections were not receiving # 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: - name: regression/issue_152__local_action_wrong_interpreter.yml
# - Ensure system Python does not have boto3 installed. hosts: all
# - Run /path/to/venv/ansible-playbook ... with the virtualenv deactivated. connection: local
# Observe success. any_errors_fatal: true
# - Run ansible-playbook ... with the virtualenv activated. Observe success.
- hosts: all
tasks: tasks:
- name: regression/issue_152__local_action_wrong_interpreter.yml
connection: local
become: true
shell: pip uninstall boto3
ignore_errors: true
- cloudformation_facts: - copy:
connection: local 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

@ -1,19 +1,21 @@
- hosts: all - name: regression/issue_152__virtualenv_python_fails.yml
any_errors_fatal: true
hosts: all
tasks: tasks:
- name: Make virtualenv
pip:
virtualenv: /tmp/issue_151_virtualenv
name: psycopg2
- name: Use virtualenv for the Python interpeter # Can't use pip module because you can't fricking just create a virtualenv,
set_fact: ansible_python_interpreter=/tmp/issue_151_virtualenv/bin/python # must call it directly.
- shell: virtualenv /tmp/issue_152_virtualenv
- name: Ensure the app DB user exists - custom_python_detect_environment:
postgresql_user: vars:
db: postgres ansible_python_interpreter: /tmp/issue_152_virtualenv/bin/python
login_host: localhost register: out
login_user: "{{ansible_user_id}}"
login_password: "x"
name: fakeuser
state: present
- assert:
that:
- out.sys_executable == "/tmp/issue_152_virtualenv/bin/python"
- file:
path: /tmp/issue_152_virtualenv
state: absent

@ -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 }}'

@ -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

@ -1,5 +0,0 @@
- hosts: all
tasks:
- name: add nginx ppa
become: yes
apt_repository: repo='ppa:nginx/stable' update_cache=yes

@ -1,7 +0,0 @@
- hosts: all
tasks:
- name: copy repo configs
copy: src=/etc/{{ item }} dest=/tmp/{{item}} mode=0644
with_items:
- passwd
- hosts

@ -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
Loading…
Cancel
Save