Tests: generation works with dnf-json.socket down

Test that the test cases generation will properly start the
dnf-json.socket when needed.
This commit is contained in:
Thomas Lavocat 2021-12-10 15:25:07 +01:00 committed by Thomas Lavocat
parent e6a6ed01ea
commit 53cb1b952e
3 changed files with 65 additions and 0 deletions

View file

@ -206,6 +206,26 @@ Regression:
- "*.repo"
when: always
Test Case Generation:
stage: test
extends: .terraform
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
script:
- schutzbot/deploy.sh
- /usr/libexec/tests/osbuild-composer/generation.sh
interruptible: true
parallel:
matrix:
- RUNNER:
- aws/fedora-34-x86_64
INTERNAL_NETWORK: ["true"]
artifacts:
paths:
- journal-log.gpg
- "*.repo"
when: always
OSTree:
stage: test
extends: .terraform/openstack

View file

@ -238,6 +238,7 @@ install -m 0755 -vp tools/run-koji-container.sh %{buildroot}%{_l
install -m 0755 -vp tools/koji-compose.py %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp tools/libvirt_test.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp tools/set-env-variables.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp tools/test-case-generators/generate-test-cases %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vd %{buildroot}%{_libexecdir}/tests/osbuild-composer
install -m 0755 -vp test/cases/* %{buildroot}%{_libexecdir}/tests/osbuild-composer/

44
test/cases/generation.sh Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/bash
set -euxo pipefail
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh
# Get OS data
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# install requirements
sudo dnf -q -y install make \
git \
go \
ranger \
openssl \
rpm-build \
aws \
qemu \
setools-console \
setroubleshoot \
container-selinux \
lvm2
# stop dnf-json socket
sudo systemctl stop osbuild-dnf-json.socket
# test the test cases generation
WORKDIR=$(mktemp -d -p /var/tmp)
OSBUILD_LABEL=$(matchpathcon -n "$(which osbuild)")
chcon "$OSBUILD_LABEL" tools/image-info
# test the test case generation when dnf-json socket is stopped
sudo ./tools/test-case-generators/generate-test-cases\
--output test/data/manifests\
--arch x86_64\
--distro rhel-8\
--image-type qcow2\
--store "$WORKDIR"