From 2232ce92b59447144a90d79ffc9cce1cb321448d Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Mar 03 2020 08:56:43 +0000 Subject: run-tests-yml: check built packages are used in the test system - Display installation status for built packages - If one of the package part of the built packages is installed to an old version on the test system then try to update it and fails if it does not pass (check-installed.sh) --- diff --git a/roles/run-tests-yml/files/check-installed.sh b/roles/run-tests-yml/files/check-installed.sh new file mode 100755 index 0000000..a5ca876 --- /dev/null +++ b/roles/run-tests-yml/files/check-installed.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# https://pagure.io/fedora-zuul-jobs/issue/40 + +# PSEUDO CODE +#for rpm in scratchbuild: +# if rpm.arch == 'src': +# continue +# if package_is_installed(rpm.name): +# if not exactly_this_built_is_installed(rpm): +# try: +# reinstall_exactly_this_rpm(rpm) +# except ReinstallationFailed: +# die_horribly() + +for package in $(repoquery -q --disablerepo=* --enablerepo=zuul-built --all --qf='%{name}' | egrep -v '.src$'); do + echo "" + echo "=== package $package ===" + if rpm -q $package; then + echo "== is built $package version installed ==" + if ! rpm -q $(repoquery -q --disablerepo=* --enablerepo=zuul-built --all --qf='%{name}-%{version}' $package); then + if ! dnf --disablerepo=* --enablerepo=zuul-built update -y $package; then + echo "ERROR: Unable to update $package to the built version" + exit 1 + fi + fi + else + continue + fi +done diff --git a/roles/run-tests-yml/tasks/main.yaml b/roles/run-tests-yml/tasks/main.yaml index 7bd583f..a1cda42 100644 --- a/roles/run-tests-yml/tasks/main.yaml +++ b/roles/run-tests-yml/tasks/main.yaml @@ -7,7 +7,10 @@ - name: Install Ansible yum: - name: ansible + name: + - ansible + - dnf-utils + - findutils state: latest use_backend: "dnf" become: yes @@ -30,7 +33,24 @@ become: yes shell: > dnf list --installed > - {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/artifacts/installed-packages.list + tests/artifacts/installed-packages.list + args: + chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + +- name: List tested package rpm install status + become: yes + shell: > + repoquery --disablerepo=* + --enablerepo=zuul-built + --all | egrep -v '.src$' | xargs rpm -q | tee -a + tests/artifacts/tested-installed-packages.list + args: + chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + +- name: Run check-installed script + become: true + script: + cmd: files/check-installed.sh - name: Check a STI results.yml file exists in the artifacts stat: