[gnome-build-meta/sthursfield/james/openqa-master: 3/3] Add CI stage to test x86 iso images in openqa
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-build-meta/sthursfield/james/openqa-master: 3/3] Add CI stage to test x86 iso images in openqa
- Date: Thu, 12 Aug 2021 11:05:43 +0000 (UTC)
commit 7da1ded6c4918a88099c3be8280f1b540dcfba22
Author: James Thomas <james thomas codethink co uk>
Date: Wed Jul 28 09:52:20 2021 +0100
Add CI stage to test x86 iso images in openqa
This is expected to run on 'master' branch as an optional, manual job.
Please use it on any MR that might trigger a regression in the VM
images, and wherever else it might be useful.
Documentation at
https://gitlab.gnome.org/GNOME/gnome-build-meta/-/wikis/openqa/OpenQA-for-GNOME-developers
.gitlab-ci.yml | 69 ++++++++++++++++++++++++++++++++++++++++-
openqa/README.md | 6 ++++
openqa/tests/gnome_install.pm | 2 +-
openqa/utils/setup_worker.sh | 35 +++++++++++++++++++++
openqa/utils/start_job.sh | 22 +++++++++++++
openqa/utils/teardown_worker.sh | 10 ++++++
openqa/utils/wait_for_job.sh | 29 +++++++++++++++++
7 files changed, 171 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6d100589..d10f9c20 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,12 +7,16 @@ variables:
BST_NO_PUSH: "bst $BST_STRICT --config .gitlab-ci/buildstream-nopush.conf --log-file logs/build.log
--colors"
BST: "bst $BST_STRICT --config .gitlab-ci/buildstream.conf --log-file logs/build.log --colors"
FLATPAK_BRANCH: master
+ OPENQA_HOST: https://openqa.gnome.org
+ OPENQA_NEEDLES_GIT: https://gitlab.gnome.org/gnome/openqa-needles
+ OPENQA_NEEDLES_SHA: master
stages:
- track
- build
- deploy-config
- deploy
+- test
- reports
default:
@@ -398,6 +402,69 @@ cve_report:
rules:
- if: $CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^gnome-\d\d$/
+
+test-iso-installer-x86_64:
+ stage: test
+ image:
+ # Source repo: https://github.com/os-autoinst/openQA
+ # name: registry.opensuse.org/devel/openqa/containers15.2/openqa_worker:latest
+ # 2021-07-29: The 'latest' tag leads to
@sha256:4469f2f4d1a93caaddcb3efb10471d2045f7ff230c5455b4ad9aa99efe90a8d7
+ # This doesn't contain qemu-img and breaks during testing with error: "no kvm-img/qemu-img found"
+ #
+ # For now, using a version built locally, from openQA.git commit ceabc2be82e1f1c6c3c51bf017c1b79494ace869
+ name: quay.io/ssssam/openqa_worker
+ entrypoint: [ "/bin/bash", "-c" ]
+ when: manual
+ variables:
+ IMAGE: iso/image.bst
+ # CI needs to be set so OPENQA_TEST_TIMEOUT_SCALE_CI has an effect.
+ CI: 1
+ OPENQA_TEST_TIMEOUT_SCALE_CI: 4
+ needs:
+ - job: 'iso-installer-x86_64'
+ artifacts: true
+ script:
+ - |
+ mkdir -p /data/factory/iso/
+ ln -s $(pwd)/image/installer.iso /data/factory/iso/installer.iso
+ - |
+ rm /etc/openqa/*
+ cat >/etc/openqa/client.conf <<EOF
+ [openqa.gnome.org]
+ key = $OPENQA_API_KEY
+ secret = $OPENQA_API_SECRET
+ EOF
+ - |
+ worker_class=qemu_x86_64-${CI_JOB_ID}
+ openqa/utils/setup_worker.sh ${worker_class} > /tmp/machine_id
+ /run_openqa_worker.sh &> worker.log &
+ - |
+ openqa/utils/start_job.sh ${worker_class} master > /tmp/job_id
+ echo "Test job has been started, visit $OPENQA_HOST/tests/$(cat /tmp/job_id) to see the progress"
+ - openqa/utils/wait_for_job.sh $(cat /tmp/job_id) > /tmp/exit_code
+ - exit $(cat /tmp/exit_code)
+ after_script:
+ - |
+ if [ -e /tmp/machine_id ]; then
+ echo "Cleaning up worker"
+ openqa/utils/teardown_worker.sh $(cat /tmp/machine_id)
+ rm /tmp/machine_id
+ fi
+ - if [ ! -e /tmp/exit_code ]; then
+ echo "Job creation failed, log below."
+ cat openqa.log
+ - fi
+ artifacts:
+ when: always
+ paths:
+ - openqa.log
+ - worker.log
+ expire_in: '1 week'
+ tags:
+ - x86_64
+ - gnome-build-meta
+
+
pages:
stage: 'reports'
needs:
@@ -409,4 +476,4 @@ pages:
paths:
- 'public'
rules:
- - if: $CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^gnome-\d\d$/
\ No newline at end of file
+ - if: $CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^gnome-\d\d$/
diff --git a/openqa/README.md b/openqa/README.md
new file mode 100644
index 00000000..a8a6ae78
--- /dev/null
+++ b/openqa/README.md
@@ -0,0 +1,6 @@
+# OpenQA testing for GNOME
+
+GNOME has an OpenQA instance here: <https://openqa.gnome.org/>
+
+Documentation can be found here:
+<https://gitlab.gnome.org/GNOME/gnome-build-meta/-/wikis/openqa/OpenQA-for-GNOME-developers>
diff --git a/openqa/tests/gnome_install.pm b/openqa/tests/gnome_install.pm
index d4694c32..d6c35476 100644
--- a/openqa/tests/gnome_install.pm
+++ b/openqa/tests/gnome_install.pm
@@ -14,7 +14,7 @@ sub run {
}
sub test_flags {
- return { fatal => 0 };
+ return { fatal => 1 };
}
1;
diff --git a/openqa/utils/setup_worker.sh b/openqa/utils/setup_worker.sh
new file mode 100755
index 00000000..1678c66c
--- /dev/null
+++ b/openqa/utils/setup_worker.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Prepare a local OpenQA worker and register it with $OPENQA_HOST.
+#
+# On success, write the machine ID returned by server to stdout.
+
+set -eu
+
+# Unique identifier for this machine, so we can tell the server to schedule
+# tests here.
+worker_class=$1
+
+# Config for local OpenQA worker instance.
+cat >/etc/openqa/workers.ini <<EOF
+[global]
+WORKER_CLASS=$worker_class
+BACKEND = qemu
+HOST = $OPENQA_HOST
+EOF
+
+# Register local worker as a new machine on OpenQA server.
+openqa-cli api --apikey $OPENQA_API_KEY --apisecret $OPENQA_API_SECRET \
+ --host $OPENQA_HOST \
+ -X POST machines/ \
+ name=gitlab-runner-$worker_class \
+ backend=qemu \
+ settings[ARCH]=x86_64 \
+ settings[PART_TABLE_TYPE]=gpt \
+ settings[QEMUCPU]=host \
+ settings[QEMUCPUS]=2 \
+ settings[QEMURAM]=2560 \
+ settings[QEMUVGA]=virtio \
+ settings[UEFI]=1 \
+ settings[UEFI_PFLASH_CODE]=/usr/share/qemu/ovmf-x86_64-code.bin \
+ settings[WORKER_CLASS]=$worker_class | tee --append openqa.log | jq -e .id > /tmp/machine_id
diff --git a/openqa/utils/start_job.sh b/openqa/utils/start_job.sh
new file mode 100755
index 00000000..05c72293
--- /dev/null
+++ b/openqa/utils/start_job.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Start job on $OPENQA_HOST.
+#
+# On success, write the job ID returned by server to stdout.
+
+set -eu
+
+worker_class=$1
+version=$2
+
+openqa-cli api --apikey $OPENQA_API_KEY --apisecret $OPENQA_API_SECRET \
+ --host $OPENQA_HOST \
+ -X POST isos \
+ ISO=installer.iso \
+ DISTRI=gnomeos \
+ VERSION=$version \
+ FLAVOR=iso \
+ ARCH=x86_64 \
+ WORKER_CLASS=$worker_class \
+ CASEDIR=$(pwd)/openqa \
+ NEEDLES_DIR=$OPENQA_NEEDLES_GIT#$OPENQA_NEEDLES_SHA | tee --append openqa.log | jq -e .ids[0]
diff --git a/openqa/utils/teardown_worker.sh b/openqa/utils/teardown_worker.sh
new file mode 100755
index 00000000..93003323
--- /dev/null
+++ b/openqa/utils/teardown_worker.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# Delete machine on $OPENQA_HOST.
+
+set -eu
+
+machine_id=$1
+
+openqa-cli api --apikey $OPENQA_API_KEY --apisecret $OPENQA_API_SECRET \
+ --host $OPENQA_HOST -X DELETE machines/${machine_id} | tee --append openqa.log
diff --git a/openqa/utils/wait_for_job.sh b/openqa/utils/wait_for_job.sh
new file mode 100755
index 00000000..476096b7
--- /dev/null
+++ b/openqa/utils/wait_for_job.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Block until a job on $OPENQA_HOST completes.
+#
+# Write a status to stdout on completion: 1 if job fails, 0 if job passes.
+
+set -eu
+
+job_id=$1
+
+job_check() {
+ openqa-cli api --apikey $OPENQA_API_KEY \
+ --apisecret $OPENQA_API_KEY \
+ --host $OPENQA_HOST \
+ jobs/${job_id}
+}
+
+state=$(job_check | jq .job.state)
+while [ "$state" != "\"done\"" ]; do sleep 10 && state=$(job_check | jq .job.state); done
+echo >&2 "Tests finished"
+
+result=$(job_check | tee --append openqa.log | jq .job.result)
+if [ "$result" != "\"passed\"" ]; then
+ echo >&2 "Test job ${job_id} *FAILED*"
+ echo 1
+else
+ echo >&2 "Test job ${job_id} *PASSED*"
+ echo 0
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]