From 53cb1b952e93aa8bccfa28126de4540bd58b3a40 Mon Sep 17 00:00:00 2001 From: Thomas Lavocat Date: Fri, 10 Dec 2021 15:25:07 +0100 Subject: [PATCH] Tests: generation works with dnf-json.socket down Test that the test cases generation will properly start the dnf-json.socket when needed. --- .gitlab-ci.yml | 20 ++++++++++++++++++ osbuild-composer.spec | 1 + test/cases/generation.sh | 44 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100755 test/cases/generation.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37f9c65e1..d17ff25ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/osbuild-composer.spec b/osbuild-composer.spec index 0ed4b71cf..2e33b1d8e 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -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/ diff --git a/test/cases/generation.sh b/test/cases/generation.sh new file mode 100755 index 000000000..380536c6f --- /dev/null +++ b/test/cases/generation.sh @@ -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"