From 073f9dc79a6b08ed9648726787669ef86d373d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Mon, 2 Nov 2020 10:47:24 +0100 Subject: [PATCH] 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. --- .github/krb5.conf | 7 ---- .github/workflows/tests.yml | 38 ------------------- Makefile | 1 + .../osbuild-koji-tests/main_test.go | 11 ++++-- internal/upload/koji/README.md | 28 -------------- osbuild-composer.spec | 5 +++ test/cases/koji.sh | 3 ++ {.github => test/data/koji}/koji.conf | 4 +- 8 files changed, 19 insertions(+), 78 deletions(-) delete mode 100644 .github/krb5.conf rename internal/upload/koji/koji_test.go => cmd/osbuild-koji-tests/main_test.go (93%) delete mode 100644 internal/upload/koji/README.md rename {.github => test/data/koji}/koji.conf (93%) diff --git a/.github/krb5.conf b/.github/krb5.conf deleted file mode 100644 index ffafcfcf3..000000000 --- a/.github/krb5.conf +++ /dev/null @@ -1,7 +0,0 @@ -include /etc/krb5.conf - -[realms] - LOCAL = { - kdc = localhost - admin_server = localhost - } diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0af90077c..491442b32 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/Makefile b/Makefile index 51ef68879..93da3474c 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/internal/upload/koji/koji_test.go b/cmd/osbuild-koji-tests/main_test.go similarity index 93% rename from internal/upload/koji/koji_test.go rename to cmd/osbuild-koji-tests/main_test.go index 38e4de656..d759d3c13 100644 --- a/internal/upload/koji/koji_test.go +++ b/cmd/osbuild-koji-tests/main_test.go @@ -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", diff --git a/internal/upload/koji/README.md b/internal/upload/koji/README.md deleted file mode 100644 index 045effebd..000000000 --- a/internal/upload/koji/README.md +++ /dev/null @@ -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 -``` diff --git a/osbuild-composer.spec b/osbuild-composer.spec index 1668efd1f..e9dd74085 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -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/ diff --git a/test/cases/koji.sh b/test/cases/koji.sh index 3b0d94879..d53127d25 100755 --- a/test/cases/koji.sh +++ b/test/cases/koji.sh @@ -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 diff --git a/.github/koji.conf b/test/data/koji/koji.conf similarity index 93% rename from .github/koji.conf rename to test/data/koji/koji.conf index 52e5e39de..fa3cf6d01 100644 --- a/.github/koji.conf +++ b/test/data/koji/koji.conf @@ -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