From dbe3315c065a8c66739cc5281ae4cb502bd519e9 Mon Sep 17 00:00:00 2001 From: Yevhenii Shapovalov Date: Mon, 11 Dec 2017 18:15:11 +0200 Subject: add tests --- tests/Master-server-not-chrooted/Makefile | 65 +++++++++++++++++ tests/Master-server-not-chrooted/PURPOSE | 6 ++ tests/Master-server-not-chrooted/named.conf | 11 +++ tests/Master-server-not-chrooted/runtest.sh | 109 ++++++++++++++++++++++++++++ tests/Master-server-not-chrooted/zonefile | 27 +++++++ tests/tests.yml | 15 ++++ 6 files changed, 233 insertions(+) create mode 100644 tests/Master-server-not-chrooted/Makefile create mode 100644 tests/Master-server-not-chrooted/PURPOSE create mode 100644 tests/Master-server-not-chrooted/named.conf create mode 100644 tests/Master-server-not-chrooted/runtest.sh create mode 100644 tests/Master-server-not-chrooted/zonefile create mode 100644 tests/tests.yml 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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 " > $(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 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 "" IN { + type master; + file ".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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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//$TDOMAIN/g\" $CONF" + + # set up zonefile + rlRun "cp $ORIGPWD/zonefile $TZONEFILE" + rlRun "chmod a+r $TZONEFILE" + rlRun "sed -i \"s//$TDOMAIN/g\" $TZONEFILE" + rlRun "sed -i \"s//$IP1/g\" $TZONEFILE" + rlRun "sed -i \"s//$IP2/g\" $TZONEFILE" + rlRun "sed -i \"s//$IP3/g\" $TZONEFILE" + rlRun "sed -i \"s//$IP4/g\" $TZONEFILE" + rlRun "sed -i \"s//$IP5/g\" $TZONEFILE" + rlRun "sed -i \"s//$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 . +$TTL 86400 +@ IN SOA dns1.. hostmaster.. ( + ; 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.. + IN NS dns2.. + + IN MX 10 mail.. + IN MX 20 mail2.. + + IN A + +server1 IN A +server2 IN A +dns1 IN A +dns2 IN A + +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 -- cgit