diff --git a/Sanity/simple-sanity-test/main.fmf b/Sanity/simple-sanity-test/main.fmf new file mode 100644 index 0000000..6885b6d --- /dev/null +++ b/Sanity/simple-sanity-test/main.fmf @@ -0,0 +1,25 @@ +summary: simple-sanity-test +description: 'Testing sending an email.' +enabled: true +tag: + - Tier1 +tier: '1' +adjust: + - enabled: false + when: distro < rhel-7 + continue: false +contact: František Hrdina +component: + - postfix +test: ./runtest.sh +framework: beakerlib +recommend: + - postfix + - mailx + - hostname + - s-nail +duration: 5m +extra-nitrate: TC#0615231 +extra-summary: /CoreOS/postfix/Sanity/simple-sanity-test +extra-task: /CoreOS/postfix/Sanity/simple-sanity-test +id: 63b88c7e-0933-4fb8-b369-8a14281a3726 diff --git a/Sanity/simple-sanity-test/runtest.sh b/Sanity/simple-sanity-test/runtest.sh new file mode 100755 index 0000000..a3f1d88 --- /dev/null +++ b/Sanity/simple-sanity-test/runtest.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/postfix/Sanity/simple-sanity-test +# Description: Testing sending an email. +# Author: František Hrdina +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2023 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="postfix" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlFileBackup "/etc/postfix" + rlFileBackup "/var/spool/mail" + + HOSTNAME=$(hostname) + DOMAIN=$(hostname -d) + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + echo "myhostname = $HOSTNAME" >> /etc/postfix/main.cf + echo "mydomain = $DOMAIN" >> /etc/postfix/main.cf + echo "mynetworks = 192.168.2.0/24" >> /etc/postfix/main.cf + echo "myorigin = \$mydomain" >> /etc/postfix/main.cf + echo "relayhost = \$mydomain" >> /etc/postfix/main.cf + + rlRun "systemctl enable --now postfix" + rlRun "postfix check" 0 "Checking configuration" + rlPhaseEnd + + rlPhaseStartTest + rlRun "echo \"This is a test message\" | mail -s SUBJECT root@$HOSTNAME" + sleep 10s + rlAssertGrep "This is a test message" "/var/spool/mail/root" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlFileRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd