Adding simple-sanity-test

This commit is contained in:
Frantisek Hrdina 2023-04-20 14:36:57 +02:00
commit a79b5acad0
2 changed files with 91 additions and 0 deletions

View file

@ -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 <fhrdina@redhat.com>
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

View file

@ -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 <fhrdina@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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