From 786139b96104c04f3818b363bf1e24541332ddc3 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 21 Jun 2022 12:03:18 +0200 Subject: [PATCH] Add tests using tmt --- .fmf/version | 1 + .gitignore | 1 + plans/lookup.fmf | 7 +++++++ plans/smoke.fmf | 5 +++++ tests/smoke/main.fmf | 4 ++++ tests/smoke/test.sh | 25 +++++++++++++++++++++++++ 6 files changed, 43 insertions(+) create mode 100644 .fmf/version create mode 100644 plans/lookup.fmf create mode 100644 plans/smoke.fmf create mode 100644 tests/smoke/main.fmf create mode 100755 tests/smoke/test.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/.gitignore b/.gitignore index 2eb5ee8..8f62a61 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /puppet-*/ /.build*.log results_puppet/ +/tests/*/log.txt diff --git a/plans/lookup.fmf b/plans/lookup.fmf new file mode 100644 index 0000000..1a53fc5 --- /dev/null +++ b/plans/lookup.fmf @@ -0,0 +1,7 @@ +summary: Run puppet lookup +prepare: + how: install + package: puppet +execute: + how: tmt + script: puppet lookup --explain foo diff --git a/plans/smoke.fmf b/plans/smoke.fmf new file mode 100644 index 0000000..c1627f9 --- /dev/null +++ b/plans/smoke.fmf @@ -0,0 +1,5 @@ +summary: Basic smoke test +discover: + how: fmf +execute: + how: tmt diff --git a/tests/smoke/main.fmf b/tests/smoke/main.fmf new file mode 100644 index 0000000..ca3245b --- /dev/null +++ b/tests/smoke/main.fmf @@ -0,0 +1,4 @@ +summary: Basic smoke testing +require: puppet +test: ./test.sh +framework: beakerlib diff --git a/tests/smoke/test.sh b/tests/smoke/test.sh new file mode 100755 index 0000000..1037517 --- /dev/null +++ b/tests/smoke/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + rlRun "set -o pipefail" + rlAssertRpm puppet + rlPhaseEnd + + rlPhaseStartTest + rlRun -s "puppet --help" 0 "Check help message" + rlAssertNotGrep "warning" $rlRun_LOG -i + + rlRun "echo \"file { '${tmp}/applied-file': ensure => file, content => 'Hello World' }\" | puppet apply" 0 "Apply manifest" + rlAssertGrep "Hello World" "applied-file" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd