summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYevhenii Shapovalov <yshapova@redhat.com>2017-12-11 18:15:11 +0200
committerYevhenii Shapovalov <yshapova@redhat.com>2017-12-11 18:15:11 +0200
commitdbe3315c065a8c66739cc5281ae4cb502bd519e9 (patch)
tree8a6e709a9c45188ccf131cdda191a2629f1cae83
parentbdc5ebdfa565a8522d857ab49dbaf0895e5a7f11 (diff)
downloadbind-add_tests.tar.gz
bind-add_tests.tar.xz
bind-add_tests.zip
add testsHEADadd_tests
-rw-r--r--tests/Master-server-not-chrooted/Makefile65
-rw-r--r--tests/Master-server-not-chrooted/PURPOSE6
-rw-r--r--tests/Master-server-not-chrooted/named.conf11
-rw-r--r--tests/Master-server-not-chrooted/runtest.sh109
-rw-r--r--tests/Master-server-not-chrooted/zonefile27
-rw-r--r--tests/tests.yml15
6 files changed, 233 insertions, 0 deletions
diff --git a/tests/Master-server-not-chrooted/Makefile b/tests/Master-server-not-chrooted/Makefile
new file mode 100644
index 0000000..891a9a3
--- /dev/null
+++ b/tests/Master-server-not-chrooted/Makefile
@@ -0,0 +1,65 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /CoreOS/bind/Sanity/Master-server-not-chrooted
+# Description: Set up master nameserver, test it.
+# Author: Martin Cermak <mcermak@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
+#
+# 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, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/CoreOS/bind/Sanity/Master-server-not-chrooted
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE named.conf zonefile
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ./runtest.sh
+
+build: $(BUILT_FILES)
+ chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Martin Cermak <mcermak@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: Set up master nameserver in chrooted env, test it." >> $(METADATA)
+ @echo "Type: Sanity" >> $(METADATA)
+ @echo "TestTime: 5m" >> $(METADATA)
+ @echo "RunFor: bind" >> $(METADATA)
+ @echo "Requires: bind bind-chroot redhat-lsb" >> $(METADATA)
+ @echo "Requires: bind-utils" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+ @echo "RhtsRequires: library(bind/bind-setup)" >> $(METADATA)
+
+ rhts-lint $(METADATA)
diff --git a/tests/Master-server-not-chrooted/PURPOSE b/tests/Master-server-not-chrooted/PURPOSE
new file mode 100644
index 0000000..92cb7bd
--- /dev/null
+++ b/tests/Master-server-not-chrooted/PURPOSE
@@ -0,0 +1,6 @@
+PURPOSE of /CoreOS/bind/Sanity/Master-server-not-chrooted
+Description: Set up master nameserver in chrooted env, test it.
+ This is a very basic sanity test for bind9.
+ The main purpose for me was to learn how
+ bind works :-)
+Author: Martin Cermak <mcermak@redhat.com>
diff --git a/tests/Master-server-not-chrooted/named.conf b/tests/Master-server-not-chrooted/named.conf
new file mode 100644
index 0000000..e477af9
--- /dev/null
+++ b/tests/Master-server-not-chrooted/named.conf
@@ -0,0 +1,11 @@
+options {
+ directory "/var/named";
+ allow-query { any; };
+};
+
+zone "<DOMAIN>" IN {
+ type master;
+ file "<DOMAIN>.zone";
+ allow-update { none; };
+};
+
diff --git a/tests/Master-server-not-chrooted/runtest.sh b/tests/Master-server-not-chrooted/runtest.sh
new file mode 100644
index 0000000..ec62a04
--- /dev/null
+++ b/tests/Master-server-not-chrooted/runtest.sh
@@ -0,0 +1,109 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/bind/Sanity/Master-server-not-chrooted
+# Description: Set up master nameserver, test it.
+# Author: Martin Cermak <mcermak@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
+#
+# 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, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include rhts environment
+#set -x
+. /usr/bin/rhts-environment.sh
+. /usr/lib/beakerlib/beakerlib.sh
+
+# Some heplful functions
+randomString () {
+ TEMPSTR=`date +%c%N | md5sum | awk '{print $1}'`
+ echo ${TEMPSTR:0:8}
+ unset TEMPSTR
+}
+
+randomIp () {
+ echo "192.168.1.`echo $[ $RANDOM / 256 + 1 ]`"
+}
+
+randomSerial () {
+ date +%N
+}
+
+# Variable declarations
+CONF="/etc/named.conf"
+IP1=`randomIp`
+IP2=`randomIp`
+IP3=`randomIp`
+IP4=`randomIp`
+IP5=`randomIp`
+SERIAL=`randomSerial`
+ORIGPWD=`pwd`
+
+# The test
+rlJournalStart
+ rlPhaseStartSetup
+ rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
+ rlRun "pushd $TmpDir"
+
+ rlRun "rlImport bind/bind-setup"
+
+ bsBindSetupStart "$ORIGPWD/named.conf" "off"
+
+ rlRun "TDOMAIN=`randomString`.cz"
+ rlRun "TZONEFILE=$ROOTDIR/var/named/$TDOMAIN.zone"
+
+ # set up /etc/named.conf
+ rlRun "sed -i \"s/<DOMAIN>/$TDOMAIN/g\" $CONF"
+
+ # set up zonefile
+ rlRun "cp $ORIGPWD/zonefile $TZONEFILE"
+ rlRun "chmod a+r $TZONEFILE"
+ rlRun "sed -i \"s/<DOMAIN>/$TDOMAIN/g\" $TZONEFILE"
+ rlRun "sed -i \"s/<IP1>/$IP1/g\" $TZONEFILE"
+ rlRun "sed -i \"s/<IP2>/$IP2/g\" $TZONEFILE"
+ rlRun "sed -i \"s/<IP3>/$IP3/g\" $TZONEFILE"
+ rlRun "sed -i \"s/<IP4>/$IP4/g\" $TZONEFILE"
+ rlRun "sed -i \"s/<IP5>/$IP5/g\" $TZONEFILE"
+ rlRun "sed -i \"s/<SERIAL>/$SERIAL/g\" $TZONEFILE"
+
+ bsBindSetupDone
+ rlPhaseEnd
+
+ rlPhaseStartTest
+ # perform tests
+ rlRun "dig @localhost $TDOMAIN | grep \"^$TDOMAIN\" | head -n 1 | grep \"$IP1\""
+ rlRun "dig @localhost server1.$TDOMAIN | grep \"^server1.$TDOMAIN\" | grep \"$IP2\""
+ rlRun "dig @localhost server2.$TDOMAIN | grep \"^server2.$TDOMAIN\" | grep \"$IP3\""
+ rlRun "dig @localhost dns1.$TDOMAIN | grep \"^dns1.$TDOMAIN\" | grep \"$IP4\""
+ rlRun "dig @localhost dns2.$TDOMAIN | grep \"^dns2.$TDOMAIN\" | grep \"$IP5\""
+ rlRun "dig @localhost ftp.$TDOMAIN | grep \"^ftp.$TDOMAIN\" | grep \"server1.$TDOMAIN\""
+ rlRun "dig @localhost mail.$TDOMAIN | grep \"^mail.$TDOMAIN\" | grep \"server1.$TDOMAIN\""
+ rlRun "dig @localhost mail2.$TDOMAIN | grep \"^mail2.$TDOMAIN\" | grep \"server2.$TDOMAIN\""
+ rlRun "dig @localhost www.$TDOMAIN | grep \"^www.$TDOMAIN\" | grep \"server2.$TDOMAIN\""
+
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ bsBindSetupCleanup
+ rlRun "popd"
+ rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
+ rlRun "rm -rf $TZONEFILE"
+ rlPhaseEnd
+rlJournalEnd
diff --git a/tests/Master-server-not-chrooted/zonefile b/tests/Master-server-not-chrooted/zonefile
new file mode 100644
index 0000000..198991e
--- /dev/null
+++ b/tests/Master-server-not-chrooted/zonefile
@@ -0,0 +1,27 @@
+$ORIGIN <DOMAIN>.
+$TTL 86400
+@ IN SOA dns1.<DOMAIN>. hostmaster.<DOMAIN>. (
+ <SERIAL> ; serial
+ 21600 ; refresh after 6 hours
+ 3600 ; retry after 1 hour
+ 604800 ; expire after 1 week
+ 86400 ) ; minimum TTL of 1 day
+
+ IN NS dns1.<DOMAIN>.
+ IN NS dns2.<DOMAIN>.
+
+ IN MX 10 mail.<DOMAIN>.
+ IN MX 20 mail2.<DOMAIN>.
+
+ IN A <IP1>
+
+server1 IN A <IP2>
+server2 IN A <IP3>
+dns1 IN A <IP4>
+dns2 IN A <IP5>
+
+ftp IN CNAME server1
+mail IN CNAME server1
+mail2 IN CNAME server2
+www IN CNAME server2
+
diff --git a/tests/tests.yml b/tests/tests.yml
new file mode 100644
index 0000000..d900539
--- /dev/null
+++ b/tests/tests.yml
@@ -0,0 +1,15 @@
+---
+# This first play always runs on the local staging system
+- hosts: localhost
+ roles:
+ - role: standard-test-rhts
+ use_beakerlib_libraries: yes
+ tags:
+ - classic
+ tests:
+ - Master-server-not-chrooted
+ required_packages:
+ - bind
+ - bind-chroot
+ - redhat-lsb
+ - bind-utils