Readd zypper tests (#33203)

* Readd zypper tests

The tests were reenabled in #33034, but some tests were removed.
Readd the tests in a mostly distro-version-independent way.

* Remove with_items and use native yaml
* Dynamically determine test URL
This commit is contained in:
Robin Roth 2018-01-03 21:20:43 +01:00 committed by Matt Clay
parent 1183029591
commit 1572df6802

View file

@ -1,6 +1,18 @@
- name: get hello package version
shell: zypper --xml se -svx hello | grep 'name="hello"' | sed 's/.*edition="\([^ ]*\)".*/\1/'
register: hello_version
- name: set URL of test package
set_fact:
hello_package_url: http://download.opensuse.org/distribution/leap/{{ ansible_distribution_version }}/repo/oss/suse/x86_64/hello-{{hello_version.stdout}}.x86_64.rpm
- debug: var=hello_package_url
# UNINSTALL # UNINSTALL
- name: uninstall hello - name: uninstall hello
zypper: name=hello state=removed zypper:
name: hello
state: removed
register: zypper_result register: zypper_result
- name: check hello with rpm - name: check hello with rpm
@ -19,7 +31,9 @@
# UNINSTALL AGAIN # UNINSTALL AGAIN
- name: uninstall hello again - name: uninstall hello again
zypper: name=hello state=removed zypper:
name: hello
state: removed
register: zypper_result register: zypper_result
- name: verify no change on re-uninstall - name: verify no change on re-uninstall
@ -29,7 +43,9 @@
# INSTALL # INSTALL
- name: install hello - name: install hello
zypper: name=hello state=present zypper:
name: hello
state: present
register: zypper_result register: zypper_result
- name: check hello with rpm - name: check hello with rpm
@ -49,7 +65,9 @@
# INSTALL AGAIN # INSTALL AGAIN
- name: install hello again - name: install hello again
zypper: name=hello state=present zypper:
name: hello
state: present
register: zypper_result register: zypper_result
- name: verify no change on second install - name: verify no change on second install
@ -117,7 +135,9 @@
# INSTALL nonexistent package # INSTALL nonexistent package
- name: install hello from url - name: install hello from url
zypper: name=doesnotexist state=present zypper:
name: doesnotexist
state: present
register: zypper_result register: zypper_result
ignore_errors: yes ignore_errors: yes
@ -140,8 +160,8 @@
- name: install broken rpm - name: install broken rpm
zypper: zypper:
name="{{output_dir | expanduser}}/zypper1/broken.rpm" name: "{{output_dir | expanduser}}/zypper1/broken.rpm"
state=present state: present
register: zypper_result register: zypper_result
ignore_errors: yes ignore_errors: yes
@ -230,25 +250,31 @@
register: zypper_res1 register: zypper_res1
- name: install and remove again, leave out plus - name: install and remove again, leave out plus
zypper: name={{item}} state=present zypper:
with_items: name:
- metamail - metamail
- -hello - -hello
state: present
register: zypper_res1a register: zypper_res1a
- name: in and rm swapped - name: in and rm swapped
zypper: name={{item}} state=present zypper:
with_items: name:
- -metamail - -metamail
- hello - hello
state: present
register: zypper_res1b register: zypper_res1b
- name: install metamail - name: install metamail
zypper: name=metamail state=absent zypper:
name: metamail
state: absent
register: zypper_res2 register: zypper_res2
- name: remove hello - name: remove hello
zypper: name=hello state=present zypper:
name: hello
state: present
register: zypper_res3 register: zypper_res3
- name: verify simultaneous install/remove worked - name: verify simultaneous install/remove worked
@ -263,10 +289,11 @@
- name: install and remove with state=absent - name: install and remove with state=absent
zypper: name={{item}} state=absent zypper:
with_items: name:
- metamail - metamail
- +hello - +hello
state: absent
register: zypper_res register: zypper_res
ignore_errors: yes ignore_errors: yes
@ -274,10 +301,13 @@
assert: assert:
that: that:
- zypper_res is failed - zypper_res is failed
- zypper_res.results[0].msg == "Can not combine '+' prefix with state=remove/absent." - zypper_res.msg == "Can not combine '+' prefix with state=remove/absent."
- name: try rm patch - name: try rm patch
zypper: name=openSUSE-2016-128 type=patch state=absent zypper:
name: openSUSE-2016-128
type: patch
state: absent
ignore_errors: yes ignore_errors: yes
register: zypper_patch register: zypper_patch
- assert: - assert:
@ -286,7 +316,9 @@
- zypper_patch.msg.startswith('Can not remove patches.') - zypper_patch.msg.startswith('Can not remove patches.')
- name: try rm URL - name: try rm URL
zypper: name=http://download.opensuse.org/repositories/openSUSE:/Leap:/{{ ansible_distribution_version }}/standard/x86_64/hello-2.9-6.2.x86_64.rpm state=absent zypper:
name: "{{ hello_package_url }}"
state: absent
ignore_errors: yes ignore_errors: yes
register: zypper_rm register: zypper_rm
- assert: - assert:
@ -294,6 +326,54 @@
- zypper_rm is failed - zypper_rm is failed
- zypper_rm.msg.startswith('Can not remove via URL.') - zypper_rm.msg.startswith('Can not remove via URL.')
- name: remove pattern update_test
zypper:
name: update_test
type: pattern
state: absent
- name: install pattern update_test
zypper:
name: update_test
type: pattern
state: present
register: zypper_install_pattern1
- name: install pattern update_test again
zypper:
name: update_test
type: pattern
state: present
register: zypper_install_pattern2
- assert:
that:
- zypper_install_pattern1 is changed
- zypper_install_pattern2 is not changed
- name: remove hello
zypper:
name: hello
state: absent
- name: install via URL
zypper:
state: present
name: "{{ hello_package_url }}"
register: zypperin1
- name: test install
zypper:
name: hello
state: present
register: zypperin2
- assert:
that:
- zypperin1 is succeeded
- zypperin1 is changed
- zypperin2 is not changed
# check for https://github.com/ansible/ansible/issues/20139 # check for https://github.com/ansible/ansible/issues/20139
- name: run updatecache - name: run updatecache
zypper: zypper: