Skip to content

Commit

Permalink
Add a simple system test (smoke test).
Browse files Browse the repository at this point in the history
  • Loading branch information
yesthattom committed May 25, 2009
1 parent ab2f28a commit fbddf5a
Show file tree
Hide file tree
Showing 56 changed files with 7,576 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ dist: MANIFEST
push:
scp $(distdir).tgz www.everythingsysadmin.com:/home/web/data/everythingsysadmin.com/mt/hostdb/releases/$(distdir).tgz
#ssh www.everythingsysadmin.com "cd /home/web/data/everythingsysadmin.com/mt/hostdb/releases && mv -n new $(distdir).tgz"

test:
cd tests/test1/out && make -f ../Makefile clean all compare

3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ examples:
New features:
-- mkzones now has "-o" option to specify output directory (Thanks Tim Bell and Geoff Crompton of Trinity College, The University of Melbourne)
-- bin/checkrootcache now uses "wget" instead of "ftp". (Thanks Geoff Crompton of Trinity College, The University of Melbourne)

-- zoneinfo.txt now has a "TTL" command to set the default TTL for a zone. (Thanks Geoff Crompton of Trinity College, The University of Melbourne)
-- Added smoke-test: "make test" runs a simple configuration and compares it to a "known good".

TODO / Wishlist:

Expand Down
160 changes: 160 additions & 0 deletions tests/test1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@

all: named.local localhost.zone EXTERNAL.named.root INTERNAL.named.root gennamedconf genzones gendhcpdconf

reload: reload-local reload-remote

clean: rootcache-clean gennamedconf-clean gendhcpdconf-clean push-clean

monthly: rootcache


#
# General the zone files:
#
gennamedconf: INTERNAL.named.conf EXTERNAL.named.conf SLAVE.named.conf

gennamedconf-clean:
rm -f INTERNAL.named.conf EXTERNAL.named.conf SLAVE.named.conf

INTERNAL.named.conf: ../zoneconf.txt
catif ../INTERNAL.named.conf-head >$@
mknamedconf INTERNAL <../zoneconf.txt >>$@
catif ../INTERNAL.named.conf-tail >>$@

EXTERNAL.named.conf: ../zoneconf.txt
catif ../EXTERNAL.named.conf-head >$@
mknamedconf EXTERNAL <../zoneconf.txt >>$@
catif ../EXTERNAL.named.conf-tail >>$@

SLAVE.named.conf: ../zoneconf.txt
catif ../SLAVE.named.conf-head >$@
mknamedconf SLAVE <../zoneconf.txt >>$@
catif ../SLAVE.named.conf-tail >>$@

#
# Generate zones
#
genzones: newserial ../zoneconf.txt ../hostdb.txt
mkzones -z ../zoneconf.txt <../hostdb.txt


newserial:
#echo `date +%Y%m%d%H%M` - 198503989334 | bc >serial
echo 123456789012 >serial

# Note: We subtract a constant from the above date string to
# bring it down to something that will fit in a 32-bit int.
# I don't go for the yyymmddc serial number format that a lot of
# people use. Why clue people in to when things changed last?
# For a lot of fun, subtract a constant that makes it look
# like the last update was in 1988.

named.local: ../named.local
cp ../named.local named.local

localhost.zone: ../localhost.zone
cp ../localhost.zone localhost.zone


# ROOTCACHE STUFF:
#
rootcache:
@echo NOTE NOTE NOTE:
@echo This will fail when the EXTERNAL.named.root file needs to be updated.
# checkrootcache

rootcache-clean:
rm -f EXTERNAL.named.root.new

EXTERNAL.named.root:
checkrootcache

# Use this if you use the same named.root inside and out:
INTERNAL.named.root: EXTERNAL.named.root
cp EXTERNAL.named.root $@

## Use this if you use a different named.root on the inside.
# 1. Create the named.root that you want in ../INTERNAL.named.root.
# 2. This recipe will copy it from there.
#INTERNAL.named.root:
# cp ../INTERNAL.named.root $@


#
# DHCP-related stuff
#

gendhcpdconf: dhcpd.conf dhcpnetinfo.txt

gendhcpdconf-clean:
rm -f dhcpd.conf

# Generate the new DHCPd configurtion:
dhcpd.conf: ../dhcpd.conf-head ../hostdb.txt ../dhcpd.conf-tail
( cat ../dhcpd.conf-head ; \
mkzones -d < ../hostdb.txt ; \
catif ../dhcpd.conf-tail ) >$@

dhcpnetinfo.txt: ../dhcpnetinfo.txt-head ../hostdb.txt ../dhcpnetinfo.txt-tail
( cat ../dhcpnetinfo.txt-head ; \
mkzones -d -n < ../hostdb.txt ; \
catif ../dhcpnetinfo.txt-tail ) >$@

#
# Things related to destinations.mk
#
# Update MS/MP (if needed) from the "out" files:
syncup: destinations.mk
mkdir -p MS MP DS
make -f destinations.mk syncup

# Diff the "out" files against the MS/MP files:
diff: destinations.mk
mkdir -p MS MP DS
make -f destinations.mk diff

push: all push-local push-remote reloadif

push-clean:
rm -f destinations.mk MP/* MS/* DS/*

push-local: destinations.mk
mkdir -p MS MP DS
make -f destinations.mk push-local

push-remote: destinations.mk
mkdir -p MS MP DS
make -f destinations.mk push-remote

destinations.mk: ../destinations.txt ../hostdb.txt
mkdestinations <../destinations.txt >destinations.mk

#
# Reload named
#
reload: reload-local reload-remote

reload-local:
make -f destinations.mk reload-local

reload-remote:
make -f destinations.mk reload-remote

# Reload only IF needed:
reloadif: reloadif-local reloadif-remote

reloadif-local:
make -f destinations.mk reloadif-local

reloadif-remote:
make -f destinations.mk reloadif-remote

#
# compare
#
compare:
( diff -r ../out ../out.good )

compare-reset:
rm -rf ../out.good
cp -R ../out ../out.good
54 changes: 54 additions & 0 deletions tests/test1/destinations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

#
# External zones:
# Note: as a safety measure, the examples write to /tmp
#

EXTERNAL.example.com -> \
/tmp/var/named/example.com.zone

EXTERNAL.10.10.10.in-addr.arpa -> \
/tmp/var/named/EXTERNAL.10.10.10.in-addr.arpa.zone

EXTERNAL.99.99.99.99.in-addr.arpa -> \
/tmp/var/named/EXTERNAL.99.99.99.in-addr.arpa.zone
# externalhost.example.com:/tmp/var/named/EXTERNAL.99.99.99.99.in-addr.arpa

#
# Internal zones:
# Note: as a safety measure, the examples write to /tmp

INTERNAL.example.com -> \
/tmp/var/named/example.com.zone

INTERNAL.10.10.10.in-addr.arpa -> \
/tmp/var/named/INTERNAL.10.10.10.in-addr.arpa.zone

INTERNAL.99.99.99.99.in-addr.arpa -> \
/tmp/var/named/INTERNAL.99.99.99.in-addr.arpa.zone
# internalhost.example.com:/tmp/var/named/INTERNAL.99.99.99.99.in-addr.arpa

localhost.zone named.local \
-> \
/tmp/var/named/.
# internalhost.example.com:/tmp/var/named/.

INTERNAL.named.root -> \
/tmp/var/named/named.ca
# internalhost.example.com:/var/named/named.ca

#
# DHCP stuff for Mac OS X Server DHCP servers
# This file isn't used in /var/named but by having this
# rule it causes the "RELOAD local" command to run.
dhcpnetinfo.txt -> /var/named/dhcpnetinfo.txt

#
# What command should be run if a file was pushed to this server?
# (Note: Some effort was made to have them execute in this order.)
#

RELOAD local cd /etc && make hostdb
RELOAD internalhost.example.com kill -1 `cat /var/run/named.pid`
RELOAD externalhost.example.com sudo rndc reload

Empty file added tests/test1/dhcpd.conf-head
Empty file.
Empty file added tests/test1/dhcpd.conf-tail
Empty file.
1 change: 1 addition & 0 deletions tests/test1/dhcpnetinfo.txt-head
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this is a comment
1 change: 1 addition & 0 deletions tests/test1/dhcpnetinfo.txt-tail
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this is the tail comment
41 changes: 41 additions & 0 deletions tests/test1/hostdb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# hostdb.txt -- list of all hosts in the organization
#
# Template for "DHCP_POOL" hosts
DHCP_POOL_TEMPLATE dhcp-$a-$b-$c-$d.example.com
#
# Note: genrange can be used to generate templates for new subnets.
#
10.1.1.0 main-net.example.com
10.1.1.1 router-main.example.com ISROUTER=router.example.com
#10.1.1.2 UNUSED0A010102.example.com
#10.1.1.3 UNUSED0A010103.example.com
10.1.1.4 server4.example.com
10.1.1.5 server5.example.com
#10.1.1.6 UNUSED0A010106.example.com
#10.1.1.7 UNUSED0A010107.example.com
#10.1.1.8 UNUSED0A010108.example.com
#10.1.1.9 UNUSED0A010109.example.com
10.1.1.10 DHCP_POOL
10.1.1.11 DHCP_POOL
10.1.1.12 DHCP_POOL
10.1.1.13 DHCP_POOL
10.1.1.14 DHCP_POOL
10.1.1.15 DHCP_POOL
#10.1.1.16 UNUSED0A010110.example.com
#10.1.1.17 UNUSED0A010111.example.com
#10.1.1.18 UNUSED0A010112.example.com
#10.1.1.19 UNUSED0A010113.example.com
#10.1.1.20 UNUSED0A010114.example.com
#10.1.1.21 UNUSED0A010115.example.com
#10.1.1.22 UNUSED0A010116.example.com
#10.1.1.23 UNUSED0A010117.example.com
#10.1.1.24 UNUSED0A010118.example.com
#10.1.1.25 UNUSED0A010119.example.com
#10.1.1.26 UNUSED0A01011A.example.com
#10.1.1.27 UNUSED0A01011B.example.com
#10.1.1.28 UNUSED0A01011C.example.com
#10.1.1.29 UNUSED0A01011D.example.com
#10.1.1.30 UNUSED0A01011E.example.com
#10.1.1.31 UNUSED0A01011F.example.com
#10.1.1.32 UNUSED0A010120.example.com
10 changes: 10 additions & 0 deletions tests/test1/localhost.zone
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
43 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ 1D IN NS @
1D IN A 127.0.0.1
10 changes: 10 additions & 0 deletions tests/test1/named.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$TTL 86400
@ IN SOA localhost. root.localhost. (
2004013101 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS localhost.

1 IN PTR localhost.
Loading

0 comments on commit fbddf5a

Please sign in to comment.