cda9d1
#!/bin/bash
cda9d1
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
cda9d1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cda9d1
#
cda9d1
#   runtest.sh of /CoreOS/tests/Sanity/Master-server-chrooted
cda9d1
#   Description: Run basic empty named-chroot service and try to resolve localhost on it
cda9d1
#   Author: Petr Mensik <pemensik@redhat.com>
cda9d1
#
cda9d1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cda9d1
#
cda9d1
#   Copyright (c) 2018 Red Hat, Inc.
cda9d1
#
cda9d1
#   This program is free software: you can redistribute it and/or
cda9d1
#   modify it under the terms of the GNU General Public License as
cda9d1
#   published by the Free Software Foundation, either version 2 of
cda9d1
#   the License, or (at your option) any later version.
cda9d1
#
cda9d1
#   This program is distributed in the hope that it will be
cda9d1
#   useful, but WITHOUT ANY WARRANTY; without even the implied
cda9d1
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
cda9d1
#   PURPOSE.  See the GNU General Public License for more details.
cda9d1
#
cda9d1
#   You should have received a copy of the GNU General Public License
cda9d1
#   along with this program. If not, see http://www.gnu.org/licenses/.
cda9d1
#
cda9d1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cda9d1
cda9d1
# Include Beaker environment
cda9d1
. /usr/bin/rhts-environment.sh || exit 1
cda9d1
. /usr/share/beakerlib/beakerlib.sh || exit 1
cda9d1
cda9d1
PACKAGE="bind"
cda9d1
cda9d1
test_service()
cda9d1
{
cda9d1
    local SERVICE="$1"
be8074
    local PACKAGE="$2"
cda9d1
	rlRun "rlServiceStart $SERVICE"
cda9d1
	rlRun "dig @localhost localhost | grep '^localhost'"
cda9d1
	rlRun "dig @localhost -x 127.0.0.1 | grep 'PTR[[:space:]]\+localhost.$'" 0 "Reverse address works"
be8074
	rlRun "rpm -V $PACKAGE" 0 "Checking $SERVICE package when running"
cda9d1
	rlRun "rlServiceRestore $SERVICE"
be8074
	rlRun "rpm -V $PACKAGE" 0 "Checking $SERVICE package when stopped"
cda9d1
}
cda9d1
cda9d1
rlJournalStart
cda9d1
    rlPhaseStartSetup
cda9d1
        rlAssertRpm bind
cda9d1
	rlAssertRpm bind-utils
cda9d1
	rlAssertRpm bind-chroot
cda9d1
    rlPhaseEnd
cda9d1
cda9d1
    rlPhaseStartTest "Testing named"
be8074
	test_service named bind
cda9d1
    rlPhaseEnd
cda9d1
cda9d1
    rlPhaseStartTest "Testing named-chroot"
be8074
	test_service named-chroot bind-chroot
cda9d1
    rlPhaseEnd
cda9d1
cda9d1
    rlPhaseStartTest "Testing named-sdb-chroot"
cda9d1
	    if rpm -q bind-sdb-chroot; then
be8074
		test_service named-sdb-chroot bind-sdb-chroot
cda9d1
	    else
cda9d1
		rlLog "bind-sdb-chroot not installed, skipping it"
cda9d1
	    fi
cda9d1
    rlPhaseEnd
cda9d1
cda9d1
    rlPhaseStartCleanup
cda9d1
	# noop
cda9d1
    rlPhaseEnd
cda9d1
rlJournalPrintText
cda9d1
rlJournalEnd