test: move to koji-osbuild-tests package
This is similar to how other osbuild packages are testing: everything that's needed for testing is included in the tests package or a dependency of it. The test runner then runs every executable in /usr/libexec/tests/<packagename>. This gives a simple test API to projects depending on this package (notably osbuild-composer). The local development workflow described in HACKING.md is meant to continue to work. To ensure this, all relevant scripts gained a TEST_DATA variable, which defaults to `./test`, but is set from $1 to the installed path from integration.sh.
This commit is contained in:
parent
ade02b0c9a
commit
16f762c2ed
14 changed files with 132 additions and 64 deletions
|
|
@ -64,6 +64,50 @@ install -d %{buildroot}%{python3_sitelib}/koji_cli_plugins
|
|||
install -p -m 0644 plugins/cli/osbuild.py %{buildroot}%{python3_sitelib}/koji_cli_plugins/osbuild.py
|
||||
%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/koji_cli_plugins/osbuild.py
|
||||
|
||||
# Tests
|
||||
install -m 0755 -vd %{buildroot}/%{_libexecdir}/tests/%{name}
|
||||
install -m 0755 -vp test/integration.sh %{buildroot}/%{_libexecdir}/tests/%{name}/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_libexecdir}/%{name}-tests
|
||||
install -m 0755 -vp test/make-certs.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/build-container.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/run-koji-container.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/copy-creds.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/run-builder.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/make-tags.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_libexecdir}/%{name}-tests/integration
|
||||
install -m 0755 -vp test/integration/* %{buildroot}/%{_libexecdir}/%{name}-tests/integration/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_datadir}/%{name}-tests
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_datadir}/%{name}-tests/data
|
||||
install -m 0755 -vp test/data/* %{buildroot}/%{_datadir}/%{name}-tests/data/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_datadir}/%{name}-tests/container
|
||||
install -m 0755 -vp test/container/brew.repo %{buildroot}/%{_datadir}/%{name}-tests/container/
|
||||
install -m 0755 -vp test/container/rhel.repo %{buildroot}/%{_datadir}/%{name}-tests/container/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_datadir}/%{name}-tests/container/builder
|
||||
install -m 0755 -vp test/container/builder/Dockerfile.fedora %{buildroot}/%{_datadir}/%{name}-tests/container/builder/
|
||||
install -m 0755 -vp test/container/builder/Dockerfile.rhel %{buildroot}/%{_datadir}/%{name}-tests/container/builder/
|
||||
install -m 0755 -vp test/container/builder/kojid.conf %{buildroot}/%{_datadir}/%{name}-tests/container/builder/
|
||||
install -m 0755 -vp test/container/builder/osbuild-koji.conf %{buildroot}/%{_datadir}/%{name}-tests/container/builder/
|
||||
install -m 0755 -vp test/container/builder/osbuild.krb5.conf %{buildroot}/%{_datadir}/%{name}-tests/container/builder/
|
||||
install -m 0755 -vp test/container/builder/run-kojid.sh %{buildroot}/%{_datadir}/%{name}-tests/container/builder/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_datadir}/%{name}-tests/container/hub
|
||||
install -m 0755 -vp test/container/hub/Dockerfile.fedora %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
install -m 0755 -vp test/container/hub/Dockerfile.rhel %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
install -m 0755 -vp test/container/hub/hub.conf %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
install -m 0755 -vp test/container/hub/kojiweb.conf %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
install -m 0755 -vp test/container/hub/run-hub.sh %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
install -m 0755 -vp test/container/hub/ssl.conf %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
install -m 0755 -vp test/container/hub/web.conf %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
|
||||
install -m 0755 -vd %{buildroot}/%{_datadir}/%{name}-tests/container/hub/plugin
|
||||
install -m 0755 -vp test/container/hub/plugin/osbuild.py %{buildroot}/%{_datadir}/%{name}-tests/container/hub/
|
||||
|
||||
%files
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
|
|
@ -80,6 +124,32 @@ install -p -m 0644 plugins/cli/osbuild.py %{buildroot}%{python3_sitelib}/koji_cl
|
|||
%{python3_sitelib}/koji_cli_plugins/osbuild.py
|
||||
%{python3_sitelib}/koji_cli_plugins/__pycache__/osbuild.*
|
||||
|
||||
%package tests
|
||||
Summary: Integration tests for koji-osbuild
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: %{name}-cli
|
||||
Requires: container-selinux
|
||||
Requires: dnsmasq
|
||||
Requires: jq
|
||||
Requires: koji
|
||||
Requires: krb5-workstation
|
||||
Requires: openssl
|
||||
Requires: osbuild-composer >= 22
|
||||
Requires: podman
|
||||
|
||||
# See comment in test/integration.sh
|
||||
%if 0%{?fedora}
|
||||
Requires: podman-plugins
|
||||
%endif
|
||||
|
||||
%description tests
|
||||
Integration tests for koji-osbuild. To be run on a dedicated system.
|
||||
|
||||
%files tests
|
||||
%{_libexecdir}/tests/%{name}
|
||||
%{_libexecdir}/%{name}-tests
|
||||
%{_datadir}/%{name}-tests
|
||||
|
||||
|
||||
%changelog
|
||||
* @longdate@ osbuild <osbuilders@osbuild.org> - @version@-@reltag@
|
||||
|
|
|
|||
2
schutzbot/Jenkinsfile
vendored
2
schutzbot/Jenkinsfile
vendored
|
|
@ -158,7 +158,7 @@ void run_tests(test_type) {
|
|||
if (test_type == 'integration') {
|
||||
sh (
|
||||
label: "Integration tests",
|
||||
script: "test/integration.sh"
|
||||
script: "/usr/libexec/tests/koji-osbuild/integration.sh"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ gpgcheck=0
|
|||
priority=10
|
||||
EOF
|
||||
|
||||
# Install the Image Builder packages and the koji cli plugin.
|
||||
retry sudo dnf -y install osbuild-composer koji-osbuild-cli
|
||||
# Installing koji-osbuild-tests package
|
||||
retry sudo dnf -y install koji-osbuild-tests
|
||||
|
||||
# Start services.
|
||||
sudo systemctl enable --now osbuild-composer.socket
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
TEST_PATH=${1:-test}
|
||||
|
||||
# this script must be run as root
|
||||
if [ $UID != 0 ]; then
|
||||
echo This script must be run as root.
|
||||
|
|
@ -11,8 +13,8 @@ source /etc/os-release
|
|||
|
||||
podman build \
|
||||
-t koji.hub \
|
||||
-f test/container/hub/Dockerfile.${ID} .
|
||||
-f ${TEST_PATH}/container/hub/Dockerfile.${ID} $TEST_PATH
|
||||
|
||||
podman build -t \
|
||||
koji.builder \
|
||||
-f test/container/builder/Dockerfile.${ID} .
|
||||
-f ${TEST_PATH}/container/builder/Dockerfile.${ID} $TEST_PATH
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ RUN dnf -y upgrade \
|
|||
python3-requests \
|
||||
&& dnf clean all
|
||||
|
||||
COPY test/container/builder/kojid.conf /etc/kojid/kojid.conf
|
||||
COPY plugins/builder/osbuild.py /usr/lib/koji-builder-plugins/
|
||||
COPY test/container/builder/run-kojid.sh /app/run-kojid.sh
|
||||
COPY test/container/builder/osbuild.krb5.conf /etc/krb5.conf.d/
|
||||
COPY container/builder/kojid.conf /etc/kojid/kojid.conf
|
||||
COPY container/builder/run-kojid.sh /app/run-kojid.sh
|
||||
COPY container/builder/osbuild.krb5.conf /etc/krb5.conf.d/
|
||||
|
||||
ENTRYPOINT /app/run-kojid.sh
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
FROM registry.access.redhat.com/ubi8/ubi:latest
|
||||
|
||||
COPY test/container/rhel.repo /etc/yum.repos.d/
|
||||
COPY test/container/brew.repo /etc/yum.repos.d/
|
||||
COPY container/rhel.repo /etc/yum.repos.d/
|
||||
COPY container/brew.repo /etc/yum.repos.d/
|
||||
|
||||
RUN dnf -y upgrade \
|
||||
&& dnf -y \
|
||||
|
|
@ -14,9 +14,8 @@ RUN dnf -y upgrade \
|
|||
python3-requests \
|
||||
&& dnf clean all
|
||||
|
||||
COPY test/container/builder/kojid.conf /etc/kojid/kojid.conf
|
||||
COPY plugins/builder/osbuild.py /usr/lib/koji-builder-plugins/
|
||||
COPY test/container/builder/run-kojid.sh /app/run-kojid.sh
|
||||
COPY test/container/builder/osbuild.krb5.conf /etc/krb5.conf.d/
|
||||
COPY container/builder/kojid.conf /etc/kojid/kojid.conf
|
||||
COPY container/builder/run-kojid.sh /app/run-kojid.sh
|
||||
COPY container/builder/osbuild.krb5.conf /etc/krb5.conf.d/
|
||||
|
||||
ENTRYPOINT /app/run-kojid.sh
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
set -ux
|
||||
|
||||
if ls /share/rpms/*.rpm 1> /dev/null 2>&1; then
|
||||
echo "Using RPMs"
|
||||
rm /usr/lib/koji-builder-plugins/osbuild.py
|
||||
rpm -i /share/rpms/koji-osbuild-?-0.*.rpm \
|
||||
/share/rpms/koji-osbuild-builder-*.rpm
|
||||
echo "Using RPMs"
|
||||
rpm -i /share/rpms/koji-osbuild-?-0.*.rpm \
|
||||
/share/rpms/koji-osbuild-builder-*.rpm
|
||||
else
|
||||
echo "Using local plugin"
|
||||
cp /share/plugins/builder/osbuild.py /usr/lib/koji-builder-plugins/
|
||||
fi
|
||||
|
||||
KOJI="koji --server=http://org.osbuild.koji.koji/kojihub --user=kojiadmin --password=kojipass --authtype=password"
|
||||
|
|
|
|||
|
|
@ -9,12 +9,11 @@ RUN dnf -y upgrade \
|
|||
python3-jsonschema \
|
||||
&& dnf clean all
|
||||
|
||||
COPY test/container/hub/hub.conf /etc/koji-hub/hub.conf
|
||||
COPY test/container/hub/ssl.conf /etc/httpd/conf.d/ssl.conf
|
||||
COPY plugins/hub/osbuild.py /usr/lib/koji-hub-plugins/
|
||||
COPY test/container/hub/run-hub.sh /app/run-hub.sh
|
||||
COPY container/hub/hub.conf /etc/koji-hub/hub.conf
|
||||
COPY container/hub/ssl.conf /etc/httpd/conf.d/ssl.conf
|
||||
COPY container/hub/run-hub.sh /app/run-hub.sh
|
||||
|
||||
COPY test/container/hub/web.conf /etc/kojiweb/web.conf
|
||||
COPY test/container/hub/kojiweb.conf /etc/httpd/conf.d/kojiweb.conf
|
||||
COPY container/hub/web.conf /etc/kojiweb/web.conf
|
||||
COPY container/hub/kojiweb.conf /etc/httpd/conf.d/kojiweb.conf
|
||||
|
||||
ENTRYPOINT /app/run-hub.sh
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
FROM registry.access.redhat.com/ubi8/ubi:latest
|
||||
|
||||
COPY test/container/rhel.repo /etc/yum.repos.d/
|
||||
COPY test/container/brew.repo /etc/yum.repos.d/
|
||||
COPY container/rhel.repo /etc/yum.repos.d/
|
||||
COPY container/brew.repo /etc/yum.repos.d/
|
||||
|
||||
# koji db schema is in docs, remove nodocs from from dnf config
|
||||
RUN sed -i '/^tsflags=nodocs$/d' /etc/dnf/dnf.conf
|
||||
|
|
@ -18,12 +18,11 @@ RUN dnf -y upgrade \
|
|||
python3-jsonschema \
|
||||
&& dnf clean all
|
||||
|
||||
COPY test/container/hub/hub.conf /etc/koji-hub/hub.conf
|
||||
COPY test/container/hub/ssl.conf /etc/httpd/conf.d/ssl.conf
|
||||
COPY plugins/hub/osbuild.py /usr/lib/koji-hub-plugins/
|
||||
COPY test/container/hub/run-hub.sh /app/run-hub.sh
|
||||
COPY container/hub/hub.conf /etc/koji-hub/hub.conf
|
||||
COPY container/hub/ssl.conf /etc/httpd/conf.d/ssl.conf
|
||||
COPY container/hub/run-hub.sh /app/run-hub.sh
|
||||
|
||||
COPY test/container/hub/web.conf /etc/kojiweb/web.conf
|
||||
COPY test/container/hub/kojiweb.conf /etc/httpd/conf.d/kojiweb.conf
|
||||
COPY container/hub/web.conf /etc/kojiweb/web.conf
|
||||
COPY container/hub/kojiweb.conf /etc/httpd/conf.d/kojiweb.conf
|
||||
|
||||
ENTRYPOINT /app/run-hub.sh
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
set -eux
|
||||
|
||||
if ls /share/rpms/*.rpm 1> /dev/null 2>&1; then
|
||||
echo "Using RPMs"
|
||||
rm /usr/lib/koji-hub-plugins/osbuild.py
|
||||
rpm -i /share/rpms/koji-osbuild-?-0.*.rpm \
|
||||
/share/rpms/koji-osbuild-hub-*.rpm
|
||||
echo "Using RPMs"
|
||||
rpm -i /share/rpms/koji-osbuild-?-0.*.rpm \
|
||||
/share/rpms/koji-osbuild-hub-*.rpm
|
||||
else
|
||||
echo "Using local plugin"
|
||||
cp /share/plugins/hub/osbuild.py /usr/lib/koji-hub-plugins/
|
||||
fi
|
||||
|
||||
# Set DB credentials
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ if [ $UID != 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
TEST_DATA=${TEST_DATA:-test/data}
|
||||
TEST_PATH=${1:-test}
|
||||
TEST_DATA=${TEST_PATH}/data
|
||||
SHARE_DIR=${SHARE_DIR:-/tmp/osbuild-composer-koji-test}
|
||||
|
||||
mkdir -p "${SHARE_DIR}"
|
||||
|
|
|
|||
|
|
@ -15,18 +15,10 @@ if [[ $ID == rhel ]] && ! rpm -q epel-release; then
|
|||
sudo rpm -Uvh /tmp/epel.rpm
|
||||
fi
|
||||
|
||||
greenprint "Installing required packages"
|
||||
sudo dnf -y install \
|
||||
container-selinux \
|
||||
dnsmasq \
|
||||
jq \
|
||||
krb5-workstation \
|
||||
koji \
|
||||
koji-osbuild-cli \
|
||||
podman
|
||||
|
||||
# HACK: podman-plugins was only recently added to RHEL. Fetch it from the
|
||||
# internal RHEL 8.3.1 repository until that is released.
|
||||
# internal RHEL 8.3.1 repository until that is released. On Fedora,
|
||||
# podman-plugins is installed in the koji-osbuild-tests package. Please adjust
|
||||
# the spec file to do the same on RHEL before removing this block.
|
||||
greenprint "Install the podman dnsname plugin"
|
||||
if [[ $ID == rhel ]]; then
|
||||
sudo tee /etc/yum.repos.d/rhel-8-3-1.repo << EOF
|
||||
|
|
@ -38,8 +30,6 @@ gpgcheck = 1
|
|||
EOF
|
||||
|
||||
sudo dnf -y install '--disablerepo=*' --enablerepo=rhel-8-3-1 podman-plugins
|
||||
else
|
||||
sudo dnf -y install podman-plugins
|
||||
fi
|
||||
|
||||
greenprint "Fetching RPMs"
|
||||
|
|
@ -51,37 +41,40 @@ sudo dnf -y \
|
|||
"koji-osbuild*"
|
||||
|
||||
greenprint "Creating composer SSL certificates"
|
||||
sudo test/make-certs.sh
|
||||
sudo /usr/libexec/koji-osbuild-tests/make-certs.sh /usr/share/koji-osbuild-tests
|
||||
|
||||
greenprint "Starting osbuild-composer's socket"
|
||||
sudo systemctl enable --now osbuild-composer-api.socket
|
||||
|
||||
greenprint "Building containers"
|
||||
sudo test/build-container.sh
|
||||
sudo /usr/libexec/koji-osbuild-tests/build-container.sh /usr/share/koji-osbuild-tests
|
||||
|
||||
greenprint "Starting containers"
|
||||
sudo test/run-koji-container.sh start
|
||||
sudo /usr/libexec/koji-osbuild-tests/run-koji-container.sh start
|
||||
|
||||
greenprint "Print logs"
|
||||
sudo podman logs org.osbuild.koji.koji
|
||||
|
||||
greenprint "Copying credentials and certificates"
|
||||
sudo test/copy-creds.sh
|
||||
sudo /usr/libexec/koji-osbuild-tests/copy-creds.sh /usr/share/koji-osbuild-tests
|
||||
|
||||
greenprint "Testing Koji hub API access"
|
||||
koji --server=http://localhost:8080/kojihub --user=osbuild --password=osbuildpass --authtype=password hello
|
||||
|
||||
greenprint "Starting koji builder"
|
||||
sudo test/run-builder.sh start
|
||||
sudo /usr/libexec/koji-osbuild-tests/run-builder.sh start /usr/share/koji-osbuild-tests
|
||||
|
||||
greenprint "Creating Koji tag infrastructure"
|
||||
test/make-tags.sh
|
||||
/usr/libexec/koji-osbuild-tests/make-tags.sh
|
||||
|
||||
greenprint "Running integration tests"
|
||||
python3 -m unittest discover -v test/integration/
|
||||
python3 -m unittest discover -v /usr/libexec/koji-osbuild-tests/integration/
|
||||
|
||||
greenprint "Stopping koji builder"
|
||||
sudo test/run-builder.sh stop
|
||||
sudo /usr/libexec/koji-osbuild-tests/run-builder.sh stop /usr/share/koji-osbuild-tests
|
||||
|
||||
greenprint "Stopping containers"
|
||||
sudo test/run-koji-container.sh stop
|
||||
sudo /usr/libexec/koji-osbuild-tests/run-koji-container.sh stop
|
||||
|
||||
greenprint "Removing generated CA cert"
|
||||
sudo rm /etc/pki/ca-trust/source/anchors/osbuild-ca-crt.pem
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ if [ $UID != 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
TEST_DATA=${TEST_DATA:-test/data}
|
||||
TEST_PATH=${1:-test}
|
||||
TEST_DATA=${TEST_PATH}/data
|
||||
|
||||
CA_DIR="/etc/osbuild-composer"
|
||||
echo "Generating certificates"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
TEST_PATH=${2:-test}
|
||||
SHARE_DIR=${SHARE_DIR:-/tmp/osbuild-composer-koji-test}
|
||||
DATA_DIR=${DATA_DIR:-/var/tmp/osbuild-koji-data}
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ builder_start() {
|
|||
--name org.osbuild.koji.builder --network org.osbuild.koji \
|
||||
-v "${SHARE_DIR}:/share:z" \
|
||||
-v "${DATA_DIR}:/mnt:z" \
|
||||
-v "${PWD}/test/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \
|
||||
-v "${TEST_PATH}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf" \
|
||||
--hostname org.osbuild.koji.kojid \
|
||||
--add-host=composer:${GATEWAY_IP} \
|
||||
koji.builder
|
||||
|
|
@ -40,9 +41,9 @@ builder_stop() {
|
|||
}
|
||||
|
||||
# check arguments
|
||||
if [[ $# -ne 1 || ( "$1" != "start" && "$1" != "stop" && "$1" != "fg") ]]; then
|
||||
if [[ $# -lt 1 || ( "$1" != "start" && "$1" != "stop" && "$1" != "fg") ]]; then
|
||||
cat <<DOC
|
||||
usage: $0 start|stop|fg
|
||||
usage: $0 start|stop|fg [TEST_PATH]
|
||||
|
||||
start - starts the builder container (background)
|
||||
fg - start the builder container in the foreground
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue