add tests
This commit is contained in:
parent
bdc5ebdfa5
commit
dbe3315c06
65
tests/Master-server-not-chrooted/Makefile
Normal file
65
tests/Master-server-not-chrooted/Makefile
Normal file
@ -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)
|
6
tests/Master-server-not-chrooted/PURPOSE
Normal file
6
tests/Master-server-not-chrooted/PURPOSE
Normal file
@ -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>
|
11
tests/Master-server-not-chrooted/named.conf
Normal file
11
tests/Master-server-not-chrooted/named.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
options {
|
||||||
|
directory "/var/named";
|
||||||
|
allow-query { any; };
|
||||||
|
};
|
||||||
|
|
||||||
|
zone "<DOMAIN>" IN {
|
||||||
|
type master;
|
||||||
|
file "<DOMAIN>.zone";
|
||||||
|
allow-update { none; };
|
||||||
|
};
|
||||||
|
|
109
tests/Master-server-not-chrooted/runtest.sh
Normal file
109
tests/Master-server-not-chrooted/runtest.sh
Normal file
@ -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
|
27
tests/Master-server-not-chrooted/zonefile
Normal file
27
tests/Master-server-not-chrooted/zonefile
Normal file
@ -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
|
||||||
|
|
15
tests/tests.yml
Normal file
15
tests/tests.yml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user