From 37897686ef7a64d7d7b5c2541e32097625eb1333 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Thu, 2 Sep 2021 15:56:59 +0200 Subject: [PATCH 1/3] Port dirinstall gating test from RHEL (sti -> tmt). This pull request enables tests in the Fedora CI using `tmt` which also allows to easily execute and debug tests from your laptop: Run tests directly on your localhost: sudo dnf install -y tmt tmt run --all provision --how local Run tests in a virtual machine: sudo dnf install -y tmt-provision-virtual tmt run Check the documentation to learn more about the tool: https://docs.fedoraproject.org/en-US/ci/tmt/ --- .fmf/version | 1 + plans/dirinstall.fmf | 18 ++++++++++++++++++ plans/dirinstall.sh | 37 +++++++++++++++++++++++++++++++++++++ plans/ks.dirinstall.cfg | 12 ++++++++++++ plans/repositories | 4 ++++ plans/show_logs.sh | 21 +++++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 .fmf/version create mode 100644 plans/dirinstall.fmf create mode 100755 plans/dirinstall.sh create mode 100644 plans/ks.dirinstall.cfg create mode 100644 plans/repositories create mode 100755 plans/show_logs.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/plans/dirinstall.fmf b/plans/dirinstall.fmf new file mode 100644 index 0000000..73038fd --- /dev/null +++ b/plans/dirinstall.fmf @@ -0,0 +1,18 @@ +summary: Integration test - dirinstall on regular system +provision: + standard-inventory-qcow2: + qemu: + m: 2G +prepare: + how: install + package: + - anaconda + # gnome-kiosk is required for "vnc" mode + - gnome-kiosk +execute: + script: + - ANACONDA_UI_MODE=text plans/dirinstall.sh + - plans/show_logs.sh + - ANACONDA_UI_MODE=vnc plans/dirinstall.sh + - plans/show_logs.sh + - journalctl -a diff --git a/plans/dirinstall.sh b/plans/dirinstall.sh new file mode 100755 index 0000000..fcc0bc9 --- /dev/null +++ b/plans/dirinstall.sh @@ -0,0 +1,37 @@ +#!/bin/sh -eux + + +# Prepare test work directory + +WORK_DIR=$(mktemp -d /var/tmp/dirinstall.XXXXXX) + + +# Create kickstart + +KICKSTART_PATH=${WORK_DIR}/ks.cfg +source plans/repositories +TEST_KICKSTART=plans/ks.dirinstall.cfg + +# Dump URLs of installation repositories found in local repositories whose names are configured in 'repositories' file +echo "url --metalink=$(dnf repoinfo $BASE_REPO | grep ^Repo-metalink | cut -d: -f2- | sed 's/^ *//')" > ${KICKSTART_PATH} +for repo in $REPOS; do + echo "repo --name=$repo --metalink=$(dnf repoinfo $repo | grep ^Repo-metalink | cut -d: -f2- | sed 's/^ *//')" >> ${KICKSTART_PATH} +done + +cat ${TEST_KICKSTART} >> ${KICKSTART_PATH} + +# Log the kickstart +cat ${KICKSTART_PATH} + + +# Run dirinstall + +INSTALL_DIR=${WORK_DIR}/install_dir +mkdir ${INSTALL_DIR} + +anaconda --dirinstall ${INSTALL_DIR} --kickstart ${KICKSTART_PATH} --${ANACONDA_UI_MODE} --noninteractive 2>&1 + + +# Remove test work directory + +rm -rf ${WORK_DIR} diff --git a/plans/ks.dirinstall.cfg b/plans/ks.dirinstall.cfg new file mode 100644 index 0000000..9b54293 --- /dev/null +++ b/plans/ks.dirinstall.cfg @@ -0,0 +1,12 @@ +# The repository configuration (url, repo) needs to be added here. +# It varies by the product and version we are running on / testing + +lang en_US.UTF-8 +keyboard --vckeymap=us --xlayouts='us' +rootpw --plaintext redhat +timezone --utc Europe/Prague + +shutdown + +%packages +%end diff --git a/plans/repositories b/plans/repositories new file mode 100644 index 0000000..9fee07a --- /dev/null +++ b/plans/repositories @@ -0,0 +1,4 @@ +# Names of local repositories whose urls will be used for installation +# Repositories for "Fedora X" release: +BASE_REPO="fedora" +REPOS="fedora-modular" diff --git a/plans/show_logs.sh b/plans/show_logs.sh new file mode 100755 index 0000000..486ed25 --- /dev/null +++ b/plans/show_logs.sh @@ -0,0 +1,21 @@ +#!/bin/sh -x + +ls /tmp + +LOG_DIR=/tmp + +cd ${LOG_DIR} +KS_SCRIPT_LOGS=$(ls ks-script-*.log) +cd - + +ANACONDA_LOGS="anaconda.log storage.log packaging.log program.log dbus.log dnf.librepo.log ${KS_SCRIPT_LOGS}" + +for log in ${ANACONDA_LOGS} ; do + LOG_PATH=${LOG_DIR}/${log} + if [ -f ${LOG_PATH} ]; then + echo "----------------------- Dumping log file $LOG_PATH:" + cat $LOG_PATH + # clear for the following test + rm $LOG_PATH + fi +done From 462ee504e461e2932d52062c19cbc53edde56daa Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Mon, 6 Sep 2021 16:15:31 +0200 Subject: [PATCH 2/3] Disable vnc test. It used to be broken / very instable. Moreover, dirinstall with vnc seems to be broken in a new way currently. --- plans/dirinstall.fmf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plans/dirinstall.fmf b/plans/dirinstall.fmf index 73038fd..395ae8a 100644 --- a/plans/dirinstall.fmf +++ b/plans/dirinstall.fmf @@ -8,11 +8,11 @@ prepare: package: - anaconda # gnome-kiosk is required for "vnc" mode - - gnome-kiosk +# - gnome-kiosk execute: script: - ANACONDA_UI_MODE=text plans/dirinstall.sh - plans/show_logs.sh - - ANACONDA_UI_MODE=vnc plans/dirinstall.sh - - plans/show_logs.sh +# - ANACONDA_UI_MODE=vnc plans/dirinstall.sh +# - plans/show_logs.sh - journalctl -a From d819f572431c024a4cc0414b1599488da4491e3b Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Wed, 8 Sep 2021 15:14:54 +0200 Subject: [PATCH 3/3] Store tmt tests in tests directory --- plans/dirinstall.fmf | 18 --------------- plans/integration.fmf | 12 ++++++++++ tests/dirinstall/dirinstall.fmf | 22 +++++++++++++++++++ {plans => tests/dirinstall}/dirinstall.sh | 9 ++++++-- {plans => tests/dirinstall}/ks.dirinstall.cfg | 0 {plans => tests/dirinstall}/repositories | 0 {plans => tests/dirinstall}/show_logs.sh | 0 7 files changed, 41 insertions(+), 20 deletions(-) delete mode 100644 plans/dirinstall.fmf create mode 100644 plans/integration.fmf create mode 100644 tests/dirinstall/dirinstall.fmf rename {plans => tests/dirinstall}/dirinstall.sh (87%) rename {plans => tests/dirinstall}/ks.dirinstall.cfg (100%) rename {plans => tests/dirinstall}/repositories (100%) rename {plans => tests/dirinstall}/show_logs.sh (100%) diff --git a/plans/dirinstall.fmf b/plans/dirinstall.fmf deleted file mode 100644 index 395ae8a..0000000 --- a/plans/dirinstall.fmf +++ /dev/null @@ -1,18 +0,0 @@ -summary: Integration test - dirinstall on regular system -provision: - standard-inventory-qcow2: - qemu: - m: 2G -prepare: - how: install - package: - - anaconda - # gnome-kiosk is required for "vnc" mode -# - gnome-kiosk -execute: - script: - - ANACONDA_UI_MODE=text plans/dirinstall.sh - - plans/show_logs.sh -# - ANACONDA_UI_MODE=vnc plans/dirinstall.sh -# - plans/show_logs.sh - - journalctl -a diff --git a/plans/integration.fmf b/plans/integration.fmf new file mode 100644 index 0000000..b2e3dbe --- /dev/null +++ b/plans/integration.fmf @@ -0,0 +1,12 @@ +summary: Integration tests for anaconda + +discover: + how: fmf + filter: 'tag: integration' + +execute: + how: tmt + +finish: + how: shell + script: command -v journalctl && journalctl -a || true diff --git a/tests/dirinstall/dirinstall.fmf b/tests/dirinstall/dirinstall.fmf new file mode 100644 index 0000000..e49bfe1 --- /dev/null +++ b/tests/dirinstall/dirinstall.fmf @@ -0,0 +1,22 @@ +summary: Dirinstall test on regular os +contact: Radek Vykydal +path: /tests/dirinstall +test: ./dirinstall.sh +duration: 1h +tag: [integration] + +/text: + summary: Dirinstall test on regular os - text UI + require: + - anaconda + environment: + ANACONDA_UI_MODE: text + +/vnc: + summary: Dirinstall test on regular os - vnc UI + enabled: false + require: + - anaconda + - gnome-kiosk + environment: + ANACONDA_UI_MODE: vnc diff --git a/plans/dirinstall.sh b/tests/dirinstall/dirinstall.sh similarity index 87% rename from plans/dirinstall.sh rename to tests/dirinstall/dirinstall.sh index fcc0bc9..9bbae66 100755 --- a/plans/dirinstall.sh +++ b/tests/dirinstall/dirinstall.sh @@ -9,8 +9,8 @@ WORK_DIR=$(mktemp -d /var/tmp/dirinstall.XXXXXX) # Create kickstart KICKSTART_PATH=${WORK_DIR}/ks.cfg -source plans/repositories -TEST_KICKSTART=plans/ks.dirinstall.cfg +source ./repositories +TEST_KICKSTART=./ks.dirinstall.cfg # Dump URLs of installation repositories found in local repositories whose names are configured in 'repositories' file echo "url --metalink=$(dnf repoinfo $BASE_REPO | grep ^Repo-metalink | cut -d: -f2- | sed 's/^ *//')" > ${KICKSTART_PATH} @@ -35,3 +35,8 @@ anaconda --dirinstall ${INSTALL_DIR} --kickstart ${KICKSTART_PATH} --${ANACONDA_ # Remove test work directory rm -rf ${WORK_DIR} + + +# Show and remove the logs for this anaconda run + +./show_logs.sh diff --git a/plans/ks.dirinstall.cfg b/tests/dirinstall/ks.dirinstall.cfg similarity index 100% rename from plans/ks.dirinstall.cfg rename to tests/dirinstall/ks.dirinstall.cfg diff --git a/plans/repositories b/tests/dirinstall/repositories similarity index 100% rename from plans/repositories rename to tests/dirinstall/repositories diff --git a/plans/show_logs.sh b/tests/dirinstall/show_logs.sh similarity index 100% rename from plans/show_logs.sh rename to tests/dirinstall/show_logs.sh