bind/Sanity/json-support/runtest.sh
Petr Sklenar 3bf810abc7 Adding test
2022-01-04 20:01:53 +01:00

65 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/bind/Sanity/json-support
# Description: Test for BZ#1899257 ([RFE] Request for libjson support to be added to)
# Author: Petr Mensik <pemensik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2021 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="bind"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
TESTDIR="`pwd`"
rlRun "pushd $TmpDir"
rlFileBackup /etc/named.conf
STATSURL='http://localhost:853/json'
cat >> /etc/named.conf <<NAMEDCONF
# Enable statistics channel
statistics-channels {
inet 127.0.0.1 port 853 allow { localhost; };
};
NAMEDCONF
rlRun "named-checkconf" 0 "Check configuration is valid"
rlRun "rlServiceStart named"
rlPhaseEnd
rlPhaseStartTest
rlRun "rndc reconfig"
rlRun "dig @localhost" 0-255 "Run query, may fail"
rlRun "python3 \"$TESTDIR/readstats.py\" $STATSURL" 0 "Check JSON statistics"
[ "$DEBUG" = y ] && PS1="test-debug $PS1" bash -i
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rlFileRestore"
rlRun "rlServiceRestore"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd