Add tmt testcase for CI

This commit is contained in:
Parag Nemade 2024-08-30 18:53:31 +05:30
parent 7a51916e3b
commit 4a46401831
No known key found for this signature in database
GPG Key ID: 71932951EB71E972
6 changed files with 54 additions and 18 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

5
plans/iso-codes.fmf Normal file
View File

@ -0,0 +1,5 @@
summary: Basic smoke test
discover:
how: fmf
execute:
how: tmt

7
tests/main.fmf Normal file
View File

@ -0,0 +1,7 @@
test: ./runtests.sh
duration: 10m
framework: beakerlib
require:
- iso-codes
- python3-jsonschema
- rpm-build

2
tests/smoke/runtest.sh → tests/run_test.sh Normal file → Executable file
View File

@ -3,8 +3,6 @@
# If one of the commands below returns non-zero then exit immediately
set -e
cd ../source
echo "Let's check the upstream data files timestamp"
ls data/iso*.json -l
echo "Validating json data files written with correct syntax"

41
tests/runtests.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh || exit 1
NAME=iso-codes
rlJournalStart
rlPhaseStartSetup
rlAssertRpm ${NAME}
rlShowPackageVersion ${NAME}
rlRun -t -l "VERSION=$(rpm -q ${NAME} --queryformat='%{version}')" 0 "Get VERSION"
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlFetchSrcForInstalled "${NAME}"
rlRun "rpm --define '_topdir $tmp' -i *src.rpm"
rlRun -t -l "mkdir BUILD" 0 "Creating BUILD directory"
rlRun -t -l "rpmbuild --noclean --nodeps --define '_topdir $tmp' -bp $tmp/SPECS/*spec"
if [ -d BUILD/${NAME}-${VERSION}-build ]; then
rlRun -t -l "pushd BUILD/${NAME}-${VERSION}-build/${NAME}-${VERSION}"
else
rlRun -t -l "pushd BUILD/${NAME}-v${VERSION}"
fi
rlPhaseEnd
rlPhaseStartTest
rlRun "set -o pipefail"
rlRun "ls data/iso*.json -l"
rlRun "python3 bin/validate_json_data.py"
rlRun "retval=$?"
rlRun "echo Test return value is $retval"
rlRun "ls data/iso*.json -l"
rlRun "retval2=$?"
rlRun "echo $retval2"
rlRun "popd" 0
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd

View File

@ -1,16 +0,0 @@
---
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-source
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-basic
tests:
- smoke
required_packages:
- python3-jsonschema