Skip to content

Commit bac1766

Browse files
committed
Add TMT test structure and basic smoke test
- Add tests/.fmf/version to mark the FMF root for TMT. - Add tests/core.fmf: smoke test (tagged 'smoke') for TMT gating. - Add tests/tmt-main.fmf: TMT plan to discover and run smoke tests. - Add .github/workflows/tmt-tests.yml: GitHub Actions workflow to run TMT tests.
1 parent 70344cc commit bac1766

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

.fmf/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

.github/workflows/tmt-tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: TMT Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
inputs:
12+
plan_filter:
13+
description: |
14+
Test plan filter name, ie: tag:smoke.
15+
If provided, only tests matching this filter will be run, otherwise all tests will be run.
16+
required: false
17+
default: ''
18+
19+
jobs:
20+
tmt-tests:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Install dependencies
28+
run: |
29+
set -x -e -o pipefail
30+
sudo apt-get update
31+
sudo apt-get install -y podman libblkid-dev rsync
32+
pip install --user tmt
33+
34+
- name: Run TMT tests
35+
run: |
36+
set -x -e -o pipefail
37+
if [ "$ACT" = "true" ]; then
38+
echo "Running locally using ACT"
39+
TMT_PROVISION_OPTS="--how local --feeling-safe"
40+
else
41+
TMT_PROVISION_OPTS="--how container"
42+
fi
43+
if [ -n "${{ github.event.inputs.plan_filter }}" ]; then
44+
PLAN_FILTER_PARAM="plan --filter '${{ github.event.inputs.plan_filter }}'"
45+
fi
46+
eval "tmt run --all --debug -vvvv provision $TMT_PROVISION_OPTS $PLAN_FILTER_PARAM"

tests/core/core.fmf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
summary: check for presence of main files from the package
2+
tag:
3+
- smoke
4+
test: |
5+
set -e
6+
test -f /usr/lib/console-login-helper-messages/libutil.sh
7+
test -f /usr/share/doc/console-login-helper-messages/README.md

tests/tmt/plans/main.fmf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
discover:
2+
how: fmf
3+
filter: "tag: smoke"
4+
execute:
5+
how: tmt
6+
7+
# This prepare is used to control when console-login-helper-messages is installed using
8+
# the distribution package or when it is built from source in the test environment
9+
prepare:
10+
- name: Set CLHM_BIN_DIR when built from source
11+
when: use_built_from_src is defined and use_built_from_src == true
12+
how: shell
13+
script: |
14+
set -x -e -o pipefail
15+
echo "Preparing the test environment"
16+
CLHM_BIN_NAME="gensnippet_if"
17+
PARENT_DIR=$(dirname "${TMT_TREE}")
18+
CLHM_BIN_FULL_PATH=$(find "${PARENT_DIR}" -type f -name "${CLHM_BIN_NAME}")
19+
if [ -z "${CLHM_BIN_FULL_PATH}" ]; then
20+
echo "gensnippet_if file not found."
21+
exit 1
22+
fi
23+
CLHM_BIN_DIR=$(dirname "${CLHM_BIN_FULL_PATH}")
24+
echo "CLHM_BIN_DIR=${CLHM_BIN_DIR}" > /tmp/clhm_bin_dir
25+
- name: Install console-login-helper-messages package
26+
when: use_built_from_src is not defined or use_built_from_src == false
27+
how: install
28+
package: console-login-helper-messages
29+
- name: Set CLHM_BIN_DIR when installed package
30+
when: use_built_from_src is not defined or use_built_from_src == false
31+
how: shell
32+
script: |
33+
set -x -e -o pipefail
34+
echo "CLHM_BIN_DIR=/usr/libexec/console-login-helper-messages" > /tmp/clhm_bin_dir

tests/tmt/plans/smoke.fmf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
summary: Basic smoke test
2+
tag:
3+
- smoke
4+
discover:
5+
how: fmf
6+
filter: "tag: smoke"
7+
execute:
8+
how: tmt

0 commit comments

Comments
 (0)