test/koji: move the koji test to schutzbot

The Koji test in Github actions was always a bit quick and dirty solution.
I think it's much nicer solution to run it on Schutzbot.

Therefore, this commit moves the koji_test.go to a new osbuild-koji-tests
executable. This new test isn't run in the base test suite as one would
anticipate but inside the koji.sh test. This is needed because
osbuild-koji-tests requires a running koji instance. This might change
in the future but I think it works for now.
This commit is contained in:
Ondřej Budai 2020-11-02 10:47:24 +01:00
parent 2dc0ecec73
commit 073f9dc79a
8 changed files with 19 additions and 78 deletions

7
.github/krb5.conf vendored
View file

@ -1,7 +0,0 @@
include /etc/krb5.conf
[realms]
LOCAL = {
kdc = localhost
admin_server = localhost
}

View file

@ -53,44 +53,6 @@ jobs:
- name: Send coverage to codecov.io
run: bash <(curl -s https://codecov.io/bash)
koji:
name: "麹 Koji test"
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
# We need python for koji client.
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Check out code into the Go module directory
uses: actions/checkout@v2
# Koji from pip is missing its config file.
# To fix this, the default Fedora 32 config is included in the repo
# and installed here. See the last line of the script.
- name: Install koji client
run: |
sudo apt-get install -y libkrb5-dev krb5-config
python -m pip install --upgrade pip
pip install koji
sudo cp .github/koji.conf /etc/koji.conf
- name: Run unit tests
run: |
sudo tools/run-koji-container.sh start
koji --server=http://localhost:8080/kojihub --user kojiadmin --password kojipass --authtype=password make-task image
env KRB5_CONFIG=../../../.github/krb5.conf go test -v -race -covermode atomic -coverprofile=coverage.txt -tags koji_test ./internal/upload/koji
sudo tools/run-koji-container.sh stop
- name: Send coverage to codecov.io
run: bash <(curl -s https://codecov.io/bash)
shellcheck:
name: "🐚 Shellcheck"
runs-on: ubuntu-latest

View file

@ -119,6 +119,7 @@ build:
go test -c -tags=integration -o bin/osbuild-dnf-json-tests ./cmd/osbuild-dnf-json-tests/main_test.go
go test -c -tags=integration -o bin/osbuild-image-tests ./cmd/osbuild-image-tests/
go test -c -tags=integration -o bin/osbuild-auth-tests ./cmd/osbuild-auth-tests/
go test -c -tags=integration -o bin/osbuild-koji-tests ./cmd/osbuild-koji-tests/
.PHONY: install
install:

View file

@ -1,6 +1,11 @@
//+build koji_test
// This command contains some tests for the koji integration. It's a bit
// different from the other cmd/*-tests executables because it cannot be
// currently run as a "base test". Instead, it's run as a part of the
// koji.sh test because it needs a working Koji instance to pass.
package koji_test
// +build integration
package main
import (
"crypto/rand"
@ -191,7 +196,7 @@ func TestKojiImport(t *testing.T) {
cmd := exec.Command(
"koji",
"--server", server,
"-c", "../../../.github/koji.conf",
"-c", "/usr/share/tests/osbuild-composer/koji/koji.conf",
"--keytab", credentials.KeyTab,
"--principal", credentials.Principal,
"list-builds",

View file

@ -1,28 +0,0 @@
## How to run the Koji test
Firstly, you need to start the koji container:
```
sudo ./tools/run-koji-container.sh start
```
This command starts a kojihub instance available at
http://localhost:8080/kojihub . You can test that it started successfully
by running:
```
koji --server=http://localhost:8080/kojihub --user=osbuild --password=osbuildpass --authtype=password hello
```
Now, you can run the koji test using:
```
go test -v -tags koji_test ./internal/upload/koji
```
The test is run on each PR in the Github CI. See `.github/workflows/tests.yml`
for more details.
To stop and remove the koji container, use the following command:
```
sudo ./tools/koji/run-koji-container.sh stop
```

View file

@ -137,6 +137,7 @@ go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-dnf-json
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-weldr-tests %{goipath}/internal/client/
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-image-tests %{goipath}/cmd/osbuild-image-tests
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-auth-tests %{goipath}/cmd/osbuild-auth-tests
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-koji-tests %{goipath}/cmd/osbuild-koji-tests
go build -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/cloud-cleaner %{goipath}/cmd/cloud-cleaner
%endif
@ -175,6 +176,7 @@ install -m 0755 -vp _bin/osbuild-weldr-tests %{buildroot}%{_l
install -m 0755 -vp _bin/osbuild-dnf-json-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp _bin/osbuild-image-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp _bin/osbuild-auth-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp _bin/osbuild-koji-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp _bin/cloud-cleaner %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp tools/provision.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
install -m 0755 -vp tools/image-info %{buildroot}%{_libexecdir}/osbuild-composer-test/
@ -220,6 +222,9 @@ install -m 0755 -vd %{buildroot}%{_d
install -m 0644 -vp test/data/keyring/id_rsa.pub %{buildroot}%{_datadir}/tests/osbuild-composer/keyring/
install -m 0600 -vp test/data/keyring/id_rsa %{buildroot}%{_datadir}/tests/osbuild-composer/keyring/
install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer/koji
install -m 0644 -vp test/data/koji/* %{buildroot}%{_datadir}/tests/osbuild-composer/koji/
%if 0%{?rhel}
install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer/vendor
install -m 0644 -vp test/data/vendor/87-podman-bridge.conflist %{buildroot}%{_datadir}/tests/osbuild-composer/vendor/

View file

@ -69,6 +69,9 @@ greenprint "Show Koji task"
koji --server=http://localhost:8080/kojihub taskinfo 1
koji --server=http://localhost:8080/kojihub buildinfo 1
greenprint "Run the integration test"
sudo /usr/libexec/osbuild-composer-test/osbuild-koji-tests
greenprint "Stopping containers"
sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh stop

View file

@ -1,5 +1,5 @@
; Koji installed from pip is missing the default config.
; This one is taken from Fedora 32 and installed in Github Actions.
; Koji default config file taken from Fedora 32 with added custom
; serverca value.
[koji]
;configuration for koji cli tool