From c7528ef1d5e68220dfc939ed06a934467b23cf03 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Tue, 4 Nov 2025 19:07:53 +0000 Subject: [PATCH] Update TMT configuration Resolves: RHEL-111712 Signed-off-by: Bryn M. Reeves --- plans/main.fmf | 11 ++++++---- tests/help/main.fmf | 2 ++ tests/help/test.sh | 8 +++++++ tests/upstream/main.fmf | 6 ++---- tests/upstream/prepare-host-environment.sh | 11 ++++++++++ tests/upstream/run-unit-tests.sh | 25 ++++++++++++++++++++++ tests/version/main.fmf | 2 ++ tests/version/test.sh | 6 ++++++ 8 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 tests/help/main.fmf create mode 100755 tests/help/test.sh create mode 100755 tests/upstream/prepare-host-environment.sh create mode 100755 tests/upstream/run-unit-tests.sh create mode 100644 tests/version/main.fmf create mode 100755 tests/version/test.sh diff --git a/plans/main.fmf b/plans/main.fmf index 5142d0a..22ce2f3 100644 --- a/plans/main.fmf +++ b/plans/main.fmf @@ -1,3 +1,4 @@ +summary: Run snapm unit tests from dist-git sources discover: how: fmf dist-git-source: true @@ -14,16 +15,18 @@ prepare: - lvm2 - python3-boom - python3-pytest + - boom-boot + - rpmdevtools - name: Enable Stratisd how: shell script: | systemctl enable --now stratisd - - name: Create boom OsProfile - how: shell - script: | - boom profile create --from-host --uname-pattern el10 - name: Enable CRB how: shell script: | dnf install -y "dnf-command(config-manager)" ; dnf config-manager --set-enabled crb || true + - name: Create boom OsProfile + how: shell + script: | + boom profile create --from-host diff --git a/tests/help/main.fmf b/tests/help/main.fmf new file mode 100644 index 0000000..bd50be1 --- /dev/null +++ b/tests/help/main.fmf @@ -0,0 +1,2 @@ +summary: Test snapm --help output +test: ./test.sh diff --git a/tests/help/test.sh b/tests/help/test.sh new file mode 100755 index 0000000..1e7770f --- /dev/null +++ b/tests/help/test.sh @@ -0,0 +1,8 @@ +#!/bin/sh -eux + +echo $TMT_SOURCE_DIR +ls $TMT_SOURCE_DIR +tmp=$(mktemp) +snapm --help > "$tmp" +grep 'Snapshot Manager' "$tmp" +rm "$tmp" diff --git a/tests/upstream/main.fmf b/tests/upstream/main.fmf index 8aeea9d..e1c137e 100644 --- a/tests/upstream/main.fmf +++ b/tests/upstream/main.fmf @@ -1,8 +1,6 @@ summary: Run snapm upstream test suite -test: | - pytest -v --log-level=debug -path: snapm-0.4.3/ +test: ./prepare-host-environment.sh; ./run-unit-tests.sh require: - python3-pytest - python3-devel -duration: 25m +duration: 90m diff --git a/tests/upstream/prepare-host-environment.sh b/tests/upstream/prepare-host-environment.sh new file mode 100755 index 0000000..ff0c6cd --- /dev/null +++ b/tests/upstream/prepare-host-environment.sh @@ -0,0 +1,11 @@ +#!/usr/bin/bash +# Prepare the host environment for running the snapm tests. +# This includes installing missing dependencies and tools. + +set -euxo pipefail + +# Move to the checked out git repo with the test plans +# this should be the root of the dist-git repo +cd "${TMT_TREE}" + +sudo dnf builddep -y snapm.spec diff --git a/tests/upstream/run-unit-tests.sh b/tests/upstream/run-unit-tests.sh new file mode 100755 index 0000000..7b3e7c0 --- /dev/null +++ b/tests/upstream/run-unit-tests.sh @@ -0,0 +1,25 @@ +#!/usr/bin/bash +# Execute snapm unit tests from a checked out dist-git repo + +set -euxo pipefail + +source /etc/os-release + +# Move to the directory with sources +cd ${TMT_SOURCE_DIR} + +# Extract the Source0 basename without extension +SRC_DIR=$(spectool --source 0 snapm.spec | sed 's/.\+\(snapm-[0-9.]\+\)\.tar\.gz/\1/') + +# Move to the extracted sources directory (patches are applied by default) +cd "${SRC_DIR}" + +# Configure snapm +cp -r etc/snapm/ /etc +cp systemd/*.service systemd/*.timer /usr/lib/systemd/system +cp systemd/tmpfiles.d/snapm.conf /usr/lib/tmpfiles.d +systemctl daemon-reload +systemd-tmpfiles --create /usr/lib/tmpfiles.d/snapm.conf + +# Run tests +sudo pytest -v --log-level=debug tests/ diff --git a/tests/version/main.fmf b/tests/version/main.fmf new file mode 100644 index 0000000..e437edf --- /dev/null +++ b/tests/version/main.fmf @@ -0,0 +1,2 @@ +summary: Test snapm --version output +test: ./test.sh diff --git a/tests/version/test.sh b/tests/version/test.sh new file mode 100755 index 0000000..8ce65b9 --- /dev/null +++ b/tests/version/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh -eux + +tmp=$(mktemp) +snapm --version > "$tmp" +grep '0.5.1' "$tmp" +rm "$tmp"