Fix apt and dpkg_selections tests (#84900)

* Fix apt and dpkg_selections tests

The tests now support aarch64.
They also have reduced dependencies on URLs hosted on third-party servers.

* Skip tests on unsupported platforms

* Use same package version for both tests

* Fix multi-arch support for Ubuntu 22.04
pull/84912/head
Matt Clay 8 months ago committed by GitHub
parent 87422526f5
commit b3d21e3ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,2 +1 @@
apt_foreign_arch: i386 hello_old_version: 2.10-2ubuntu2
hello_old_version: 2.6-1

@ -1,3 +1,19 @@
- name: get the default arch
command: dpkg --print-architecture
register: default_arch
- name: select a foreign arch for {{ default_arch.stdout }}
# When adding a new arch, pick a foreign arch hosted on the same repository mirror as the default arch. For example:
# - archive.ubuntu.com hosts both amd64 and i386
# - ports.ubuntu.com hosts both arm64 and armhf
include_vars: "{{ item }}"
with_first_found:
- "arch/{{ default_arch.stdout }}.yml"
- name: show the arch selected for multi-arch testing
debug:
msg: Using {{ apt_foreign_arch }} as the foreign arch for {{ default_arch.stdout }}
# verify that apt is handling multi-arch systems properly # verify that apt is handling multi-arch systems properly
- name: load version specific vars - name: load version specific vars

@ -1,13 +1,3 @@
- name: use Debian mirror
set_fact:
distro_mirror: http://ftp.debian.org/debian
when: ansible_distribution == 'Debian'
- name: use Ubuntu mirror
set_fact:
distro_mirror: http://archive.ubuntu.com/ubuntu
when: ansible_distribution == 'Ubuntu'
# UNINSTALL 'python3-apt' # UNINSTALL 'python3-apt'
# The `apt` module has the smarts to auto-install `python3-apt`. To test, we # The `apt` module has the smarts to auto-install `python3-apt`. To test, we
# will first uninstall `python3-apt`. # will first uninstall `python3-apt`.
@ -287,7 +277,7 @@
apt: pkg=hello state=absent purge=yes apt: pkg=hello state=absent purge=yes
- name: install deb file from URL - name: install deb file from URL
apt: deb="{{ distro_mirror }}/pool/main/h/hello/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb" apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/apt/hello_{{ hello_old_version }}_{{ hello_architecture.stdout }}.deb"
register: apt_url register: apt_url
- name: verify installation of hello - name: verify installation of hello
@ -468,7 +458,7 @@
# https://github.com/ansible/ansible/issues/65325 # https://github.com/ansible/ansible/issues/65325
- name: Download and install old version of hello (to test allow_change_held_packages option) - name: Download and install old version of hello (to test allow_change_held_packages option)
apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/dpkg_selections/hello_{{ hello_old_version }}_amd64.deb" apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/apt/hello_{{ hello_old_version }}_{{ hello_architecture.stdout }}.deb"
notify: notify:
- remove package hello - remove package hello

@ -15,14 +15,16 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: skip test on unsupported platforms
meta: end_play
when: ansible_distribution not in ('Ubuntu', 'Debian')
- block: - block:
- import_tasks: 'apt.yml' - import_tasks: 'apt.yml'
- import_tasks: 'url-with-deps.yml' - import_tasks: 'url-with-deps.yml'
- import_tasks: 'apt-multiarch.yml' - import_tasks: 'apt-multiarch.yml'
when:
- ansible_userspace_architecture != apt_foreign_arch
- import_tasks: 'apt-builddep.yml' - import_tasks: 'apt-builddep.yml'
@ -36,9 +38,6 @@
name: "{{ repodir }}" name: "{{ repodir }}"
state: absent state: absent
when:
- ansible_distribution in ('Ubuntu', 'Debian')
always: always:
- name: Check if the target is managed by ansible-test - name: Check if the target is managed by ansible-test
stat: stat:

@ -1 +1 @@
hello_old_version: 2.6-1 hello_old_version: 2.10-2ubuntu2

@ -1,5 +1,9 @@
- name: get the default arch
command: dpkg --print-architecture
register: default_arch
- name: download and install old version of hello - name: download and install old version of hello
apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/dpkg_selections/hello_{{ hello_old_version }}_amd64.deb" apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/dpkg_selections/hello_{{ hello_old_version }}_{{ default_arch.stdout }}.deb"
- name: freeze version for hello - name: freeze version for hello
dpkg_selections: dpkg_selections:

@ -1,3 +1,6 @@
--- ---
- name: skip test on unsupported platforms
meta: end_play
when: ansible_distribution not in ('Ubuntu', 'Debian')
- include_tasks: file='dpkg_selections.yaml' - include_tasks: file='dpkg_selections.yaml'
when: ansible_distribution in ('Ubuntu', 'Debian')

@ -69,8 +69,8 @@
lineinfile: lineinfile:
path: /etc/apt/sources.list path: /etc/apt/sources.list
backrefs: True backrefs: True
regexp: ^#\s*deb-src http://archive\.ubuntu\.com/ubuntu/ (\w*){{ item }} universe$ regexp: ^#\s*deb-src (http://.*\.ubuntu\.com/ubuntu.*/) (\w*){{ item }} universe$
line: deb-src http://archive.ubuntu.com/ubuntu \1{{ item }} universe line: deb-src \1 \2{{ item }} universe
state: present state: present
with_items: with_items:
- '' - ''

Loading…
Cancel
Save