test: create a compose via koji

Try testing a compose via the koji, which involves creating using
the koji command line plugin to make the XMLRPC call to koji hub,
where the osbuild koji hub plugin verifies the parameters and then
creates the task. The osbuild koji plugin for the builder is then
picking up the task, and uses composer's koji API to request a
compose. Once this is successful it will be imported by composer
into koji via the 'CGImport' method.
The `koji osbuild-image` command waits for all this and reports
whether the task was successful or not via its exit code (and
on stdout).

This uses a fleet of containers: a database one, a kerberos kdc
one, another one for the koju hub and finally one for the koji
builder. The pre-build RPMs are used to install the plugins.

NB: On RHEL we need to manually install the `dnsname` podman
plugin, since it is missing, but required so that containers
can address each other by hostnames.
See [schutzbot/vendor/README.md](schutzbot/vendor/README.md)
This commit is contained in:
Christian Kellner 2020-09-10 18:57:12 +02:00 committed by Tom Gundersen
parent 3fdf66a61c
commit b292458771
4 changed files with 151 additions and 1 deletions

View file

@ -1,3 +1,103 @@
#!/bin/bash
set -euxo pipefail
echo "IT IS ALIVE!"
function greenprint {
echo -e "\033[1;32m${1}\033[0m"
}
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
greenprint "Disable SELinux"
sudo setenforce 0
if [[ $ID == rhel ]] && ! rpm -q epel-release; then
greenprint "📦 Setting up EPEL repository"
curl -Ls --retry 5 --output /tmp/epel.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo rpm -Uvh /tmp/epel.rpm
fi
greenprint "Installing required packages"
sudo dnf -y install \
dnsmasq \
jq \
krb5-workstation \
koji \
koji-osbuild-cli \
podman
if [[ $ID == rhel ]]; then
greenprint "Tweaking podman, maybe."
sudo cp schutzbot/vendor/87-podman-bridge.conflist /etc/cni/net.d/
sudo cp schutzbot/vendor/dnsname /usr/libexec/cni/
fi
greenprint "Fetching RPMs"
sudo mkdir -p /tmp/osbuild-composer-koji-test/rpms
sudo dnf -y \
--downloadonly \
--downloaddir=/tmp/osbuild-composer-koji-test/rpms \
download \
"koji-osbuild*"
greenprint "Building containers"
sudo podman build -t koji.hub -f container/hub/Dockerfile .
sudo podman build -t koji.builder -f container/builder/Dockerfile .
greenprint "Starting containers"
sudo ./run-koji-container.sh start
greenprint "Print logs"
sudo podman logs org.osbuild.koji.koji
greenprint "Adding kerberos config"
sudo cp \
/tmp/osbuild-composer-koji-test/client.keytab \
/etc/krb5.keytab
sudo cp \
osbuild-local.conf \
/etc/krb5.conf.d/local
greenprint "Initializing Kerberos"
kinit osbuild-krb@LOCAL -k
sudo -u _osbuild-composer kinit osbuild-krb@LOCAL -k
sudo kinit osbuild-krb@LOCAL -k
greenprint "Adding generated CA cert"
sudo cp \
/tmp/osbuild-composer-koji-test/ca-crt.pem \
/etc/pki/ca-trust/source/anchors/koji-ca-crt.pem
sudo update-ca-trust
greenprint "Testing Koji"
koji --server=http://localhost/kojihub --user=osbuild --password=osbuildpass --authtype=password hello
koji --server=http://localhost/kojihub hello
sudo -u _osbuild-composer koji --server=http://localhost/kojihub hello
greenprint "Starting koji builder"
sudo ./run-builder.sh start
greenprint "Creating Koji tag infrastructure"
./make-tags.sh
greenprint "Creating a compose"
koji --server=http://localhost/kojihub \
--user=kojiadmin \
--password=kojipass \
--authtype=password \
osbuild-image Fedora-Cloud 32 fedora-32 f32-candidate x86_64 \
--repo 'http://download.fedoraproject.org/pub/fedora/linux/releases/32/Everything/$arch/os/'
greenprint "Stopping koji builder"
sudo ./run-builder.sh stop
greenprint "Stopping containers"
sudo ./run-koji-container.sh stop
greenprint "Removing generated CA cert"
sudo rm \
/etc/pki/ca-trust/source/anchors/koji-ca-crt.pem
sudo update-ca-trust