Clean up integration tests. (#17991)

This commit is contained in:
Matt Clay 2016-10-12 19:33:12 -07:00 committed by GitHub
parent 65ea24f4bb
commit 410b96d716
7 changed files with 182 additions and 179 deletions

View file

@ -4,18 +4,16 @@
# In destructive because it creates and removes a user
- { role: test_become, tags: test_become}
- { role: test_service, tags: [test_service, needs_privileged] }
# Current pip unconditionally uses md5. We can re-enable if pip switches
# to a different hash or allows us to not check md5
- { role: test_pip, tags: test_pip, when: ansible_fips != True }
- { role: test_pip, tags: test_pip }
- { role: test_gem, tags: test_gem }
- { role: test_yum, tags: test_yum, when: ansible_python.version.major == '2' }
- { role: test_yum, tags: test_yum }
- { role: test_apt, tags: test_apt }
- { role: test_apt_repository, tags: [test_apt_repository, test_apt_key] }
- { role: test_postgresql, tags: [test_postgresql, test_postgresql_db, test_postgresql_privs, test_postgresql_user, needs_privileged] }
- { role: test_mysql_db, tags: test_mysql_db}
- { role: test_mysql_user, tags: test_mysql_user}
- { role: test_mysql_variables, tags: test_mysql_variables}
- { role: test_docker, tags: test_docker, when: ansible_distribution != "Fedora" }
- { role: test_docker, tags: test_docker }
- { role: test_zypper, tags: test_zypper}
- { role: test_zypper_repository, tags: test_zypper_repository}
- { role: test_uri, tags: test_uri }

View file

@ -65,7 +65,7 @@
assert:
that:
- "copy_result.md5sum == 'c47397529fe81ab62ba3f85e9f4c71f2'"
when: ansible_fips != True
when: ansible_fips|bool != True
- name: check the stat results of the file
stat: path={{output_file}}
@ -87,7 +87,7 @@
assert:
that:
- "stat_results.stat.md5 == 'c47397529fe81ab62ba3f85e9f4c71f2'"
when: ansible_fips != True
when: ansible_fips|bool != True
- name: overwrite the file via same means
copy: src=foo.txt dest={{output_file}}

View file

@ -1,5 +1,5 @@
- include: docker-setup-rht.yml
when: ansible_distribution in ['Fedora']
#- include: docker-setup-rht.yml
# when: ansible_distribution in ['Fedora']
#- include: docker-setup-rht.yml
# Packages on RHEL and CentOS 7 are broken, broken, broken. Revisit when
# they've got that sorted out
@ -10,14 +10,14 @@
#- include: docker-setup-debian.yml
# when: ansible_distribution in ['Ubuntu']
- include: docker-tests.yml
#- include: docker-tests.yml
# Add other distributions as the proper packages become available
when: ansible_distribution in ['Fedora']
# when: ansible_distribution in ['Fedora']
#- include: docker-tests.yml
# when: ansible_distribution in ['RedHat', 'CentOS'] and ansible_lsb.major_release|int == 6
- include: registry-tests.yml
#- include: registry-tests.yml
# Add other distributions as the proper packages become available
when: ansible_distribution in ['Fedora']
# when: ansible_distribution in ['Fedora']

View file

@ -1,164 +1,5 @@
# test code for the pip module
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# FIXME: replace the python test package
# first some tests installed system-wide
# verify things were not installed to start with
- name: ensure a package is not installed (precondition setup)
pip: name={{ pip_test_package }} state=absent
# verify that a package that is uninstalled being set to absent
# results in an unchanged state and that the test package is not
# installed
- name: ensure a package is not installed
pip: name={{ pip_test_package }} state=absent
register: uninstall_result
- name: removing an unremoved package should return unchanged
assert:
that:
- "not uninstall_result.changed"
- shell: "{{ ansible_python.executable }} -c 'import {{ pip_test_package }}'"
register: absent_result
ignore_errors: True
- name: verify {{ pip_test_package }} is not present
assert:
that:
- "absent_result.rc != 0"
# now we're going to install the test package knowing it is uninstalled
# and check that installation was ok
- name: ensure a package is installed
pip: name={{ pip_test_package }} state=present
register: install_result
- name: verify we recorded a change
assert:
that:
- "install_result.changed == True"
- shell: "{{ ansible_python.executable }} -c 'import {{ pip_test_package }}'"
register: installed_result
# now remove it to test uninstallation of a package we are sure is installed
- name: now uninstall so we can see that a change occurred
pip: name={{ pip_test_package }} state=absent
register: absent2
- name: assert a change occurred on uninstallation
assert:
that:
- "absent2.changed"
# put the test package back
- name: now put it back in case someone wanted it (like us!)
pip: name={{ pip_test_package }} state=present
# Test virtualenv installations
- name: make sure the test env doesn't exist
file: state=absent name={{ output_dir }}/pipenv
- name: create a requirement file with an vcs url
copy: dest={{ output_dir }}/pipreq.txt
content="-e git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
- name: install the requirement file in a virtualenv
pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv
register: req_installed
- name: check that a change occurred
assert:
that:
- "req_installed.changed"
- name: repeat installation to check status didn't change
pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv
register: req_installed
- name: check that a change didn't occurr this time (bug ansible#1705)
assert:
that:
- "not req_installed.changed"
- name: install the same module from url
pip: name="git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
virtualenv={{ output_dir }}/pipenv
register: url_installed
- name: check that a change didn't occurr (bug ansible-modules-core#1645)
assert:
that:
- "not url_installed.changed"
# Test pip package in check mode doesn't always report changed.
# Special case for pip
- name: check for pip package
pip: name=pip virtualenv={{ output_dir }}/pipenv state=present
- name: check for pip package in check_mode
pip: name=pip virtualenv={{ output_dir }}/pipenv state=present
check_mode: True
register: pip_check_mode
- name: make sure pip in check_mode doesn't report changed
assert:
that:
- "not pip_check_mode.changed"
# Special case for setuptools
- name: check for setuptools package
pip: name=setuptools virtualenv={{ output_dir }}/pipenv state=present
- name: check for setuptools package in check_mode
pip: name=setuptools virtualenv={{ output_dir }}/pipenv state=present
check_mode: True
register: setuptools_check_mode
- name: make sure setuptools in check_mode doesn't report changed
assert:
that:
- "not setuptools_check_mode.changed"
# Normal case
- name: check for q package
pip: name=q virtualenv={{ output_dir }}/pipenv state=present
- name: check for q package in check_mode
pip: name=q virtualenv={{ output_dir }}/pipenv state=present
check_mode: True
register: q_check_mode
- name: make sure q in check_mode doesn't report changed
assert:
that:
- "not q_check_mode.changed"
# Current pip unconditionally uses md5.
# We can re-enable if pip switches to a different hash or allows us to not check md5.
- include: 'pip.yml'
when: ansible_fips|bool != True

View file

@ -0,0 +1,164 @@
# test code for the pip module
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# FIXME: replace the python test package
# first some tests installed system-wide
# verify things were not installed to start with
- name: ensure a package is not installed (precondition setup)
pip: name={{ pip_test_package }} state=absent
# verify that a package that is uninstalled being set to absent
# results in an unchanged state and that the test package is not
# installed
- name: ensure a package is not installed
pip: name={{ pip_test_package }} state=absent
register: uninstall_result
- name: removing an unremoved package should return unchanged
assert:
that:
- "not uninstall_result.changed"
- shell: "{{ ansible_python.executable }} -c 'import {{ pip_test_package }}'"
register: absent_result
ignore_errors: True
- name: verify {{ pip_test_package }} is not present
assert:
that:
- "absent_result.rc != 0"
# now we're going to install the test package knowing it is uninstalled
# and check that installation was ok
- name: ensure a package is installed
pip: name={{ pip_test_package }} state=present
register: install_result
- name: verify we recorded a change
assert:
that:
- "install_result.changed == True"
- shell: "{{ ansible_python.executable }} -c 'import {{ pip_test_package }}'"
register: installed_result
# now remove it to test uninstallation of a package we are sure is installed
- name: now uninstall so we can see that a change occurred
pip: name={{ pip_test_package }} state=absent
register: absent2
- name: assert a change occurred on uninstallation
assert:
that:
- "absent2.changed"
# put the test package back
- name: now put it back in case someone wanted it (like us!)
pip: name={{ pip_test_package }} state=present
# Test virtualenv installations
- name: make sure the test env doesn't exist
file: state=absent name={{ output_dir }}/pipenv
- name: create a requirement file with an vcs url
copy: dest={{ output_dir }}/pipreq.txt
content="-e git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
- name: install the requirement file in a virtualenv
pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv
register: req_installed
- name: check that a change occurred
assert:
that:
- "req_installed.changed"
- name: repeat installation to check status didn't change
pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv
register: req_installed
- name: check that a change didn't occurr this time (bug ansible#1705)
assert:
that:
- "not req_installed.changed"
- name: install the same module from url
pip: name="git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
virtualenv={{ output_dir }}/pipenv
register: url_installed
- name: check that a change didn't occurr (bug ansible-modules-core#1645)
assert:
that:
- "not url_installed.changed"
# Test pip package in check mode doesn't always report changed.
# Special case for pip
- name: check for pip package
pip: name=pip virtualenv={{ output_dir }}/pipenv state=present
- name: check for pip package in check_mode
pip: name=pip virtualenv={{ output_dir }}/pipenv state=present
check_mode: True
register: pip_check_mode
- name: make sure pip in check_mode doesn't report changed
assert:
that:
- "not pip_check_mode.changed"
# Special case for setuptools
- name: check for setuptools package
pip: name=setuptools virtualenv={{ output_dir }}/pipenv state=present
- name: check for setuptools package in check_mode
pip: name=setuptools virtualenv={{ output_dir }}/pipenv state=present
check_mode: True
register: setuptools_check_mode
- name: make sure setuptools in check_mode doesn't report changed
assert:
that:
- "not setuptools_check_mode.changed"
# Normal case
- name: check for q package
pip: name=q virtualenv={{ output_dir }}/pipenv state=present
- name: check for q package in check_mode
pip: name=q virtualenv={{ output_dir }}/pipenv state=present
check_mode: True
register: q_check_mode
- name: make sure q in check_mode doesn't report changed
assert:
that:
- "not q_check_mode.changed"

View file

@ -66,7 +66,7 @@
- assert:
that:
- "stat_result.stat.md5 == '5eb63bbbe01eeed093cb22bb8f5acdc3'"
when: ansible_fips != True
when: ansible_fips|bool != True
- name: make a symlink
file:
@ -166,5 +166,5 @@
- assert:
that:
- "stat_result.stat.md5 == '5eb63bbbe01eeed093cb22bb8f5acdc3'"
when: ansible_fips != True
when: ansible_fips|bool != True

View file

@ -19,5 +19,5 @@
# Note: We install the yum package onto Fedora so that this will work on dnf systems
# We want to test that for people who don't want to upgrade their systems.
- include: 'yum.yml'
when: ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
when: ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora'] and ansible_python.version.major == 2