More imported sanity tests

This commit is contained in:
Petr Menšík 2019-10-09 17:40:40 +02:00
commit fdd78bd18c
30 changed files with 1341 additions and 0 deletions

View file

@ -0,0 +1,66 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/bind/Sanity/Master-server-chrooted-reverse-lookup
# 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-chrooted-reverse-lookup
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" >> $(METADATA)
@echo "Requires: bind-chroot" >> $(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)

View file

@ -0,0 +1,6 @@
PURPOSE of /CoreOS/bind/Sanity/Master-server-chrooted-reverse-lookup
Description: Set up master nameserver, run some reverse queries
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>

View file

@ -0,0 +1,11 @@
options {
directory "/var/named";
allow-query { any; };
};
zone "1.0.10.in-addr.arpa" IN {
type master;
file "<DOMAIN>.rr.zone";
allow-update { none; };
};

View file

@ -0,0 +1,99 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/bind/Sanity/Master-server-chrooted-reverse-lookup
# 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
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Some heplful functions
randomString () {
TEMPSTR=`date +%c%N | md5sum | awk '{print $1}'`
echo ${TEMPSTR:0:8}
unset TEMPSTR
}
randomNo () {
echo $[ $RANDOM / 256 + 1 ]
}
randomSerial () {
date +%N
}
# Variable declarations
SERIAL=`randomSerial`
NO1=`randomNo`
NO2=`randomNo`
NO3=`randomNo`
ORIGPWD=`pwd`
# The test
rlJournalStart
rlPhaseStartSetup
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "rlImport bind/bind-setup"
#rlRun "wget --quiet http://nest.test.redhat.com/mnt/qa/scratch/mcermak/bind-setup.tar.gz && tar xvzf bind-setup.tar.gz > /dev/null && . bind-setup/bind-setup.sh" 0 "Imported bind-setup functions."
bsBindSetupStart "$ORIGPWD/named.conf" "on"
rlRun "TDOMAIN=`randomString`.cz"
rlRun "TZONEFILE=$ROOTDIR/var/named/$TDOMAIN.rr.zone"
rlRun "sed -i \"s/<DOMAIN>/$TDOMAIN/g\" /etc/named.conf"
# zonefile
rlRun "cp $ORIGPWD/zonefile $TZONEFILE"
rlRun "chmod a+r $TZONEFILE"
rlRun "sed -i \"s/<DOMAIN>/$TDOMAIN/g\" $TZONEFILE"
rlRun "sed -i \"s/<SERIAL>/$SERIAL/g\" $TZONEFILE"
rlRun "sed -i \"s/<NO1>/$NO1/g\" $TZONEFILE"
rlRun "sed -i \"s/<NO2>/$NO2/g\" $TZONEFILE"
rlRun "sed -i \"s/<NO3>/$NO3/g\" $TZONEFILE"
if rlIsRHEL 5; then
rlRun "cp /etc/named.conf $ROOTDIR/etc/named.conf"
fi
bsBindSetupDone chroot
rlPhaseEnd
rlPhaseStartTest
# perform tests
rlRun "dig @localhost -x 10.0.1.$NO1 +short | grep \"^alice.$TDOMAIN.$\""
rlRun "dig @localhost -x 10.0.1.$NO2 +short | grep \"^betty.$TDOMAIN.$\""
rlRun "dig @localhost -x 10.0.1.$NO3 +short | grep \"^charlie.$TDOMAIN.$\""
rlPhaseEnd
rlPhaseStartCleanup
bsBindSetupCleanup chroot
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlRun "rm -rf $TZONEFILE"
rlPhaseEnd
rlJournalEnd

View file

@ -0,0 +1,16 @@
$ORIGIN 1.0.10.in-addr.arpa.
$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>.
<NO1> IN PTR alice.<DOMAIN>.
<NO2> IN PTR betty.<DOMAIN>.
<NO3> IN PTR charlie.<DOMAIN>.

View file

@ -0,0 +1,66 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/bind/Sanity/Master-server-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-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)
test -x runtest.sh || 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: 25m" >> $(METADATA)
@echo "RunFor: bind" >> $(METADATA)
@echo "Requires: bind" >> $(METADATA)
@echo "Requires: bind-chroot" >> $(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)

View file

@ -0,0 +1,6 @@
PURPOSE of /CoreOS/bind/Sanity/Master-server-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>

View file

@ -0,0 +1,11 @@
options {
directory "/var/named";
allow-query { any; };
};
zone "<DOMAIN>" IN {
type master;
file "<DOMAIN>.zone";
allow-update { none; };
};

View file

@ -0,0 +1,115 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/bind/Sanity/Master-server-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
. /usr/share/beakerlib/beakerlib.sh || exit 1
# 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"
#rlRun "wget --quiet http://nest.test.redhat.com/mnt/qa/scratch/mcermak/bind-setup.tar.gz && tar xvzf bind-setup.tar.gz > /dev/null && . bind-setup/bind-setup.sh" 0 "Imported bind-setup functions."
bsBindSetupStart "$ORIGPWD/named.conf" "on"
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"
if rlIsRHEL 5; then
rlRun "cp /etc/named.conf $ROOTDIR/etc/named.conf"
fi
bsBindSetupDone chroot
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 chroot
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlRun "rm -rf $TZONEFILE"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View 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

View file

@ -0,0 +1,65 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/bind/Sanity/Master-server-not-chrooted-reverse-lookup
# 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-reverse-lookup
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, test it." >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 150m" >> $(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)

View file

@ -0,0 +1,6 @@
PURPOSE of /CoreOS/bind/Sanity/Master-server-not-chrooted-reverse-lookup
Description: Set up master nameserver, run some reverse queries
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>

View file

@ -0,0 +1,11 @@
options {
directory "/var/named";
allow-query { any; };
};
zone "1.0.10.in-addr.arpa" IN {
type master;
file "<DOMAIN>.rr.zone";
allow-update { none; };
};

View file

@ -0,0 +1,97 @@
#!/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-reverse-lookup
# 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
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Some heplful functions
randomString () {
TEMPSTR=`date +%c%N | md5sum | awk '{print $1}'`
echo ${TEMPSTR:0:8}
unset TEMPSTR
}
randomNo () {
echo $[ $RANDOM / 256 + 1 ]
}
randomSerial () {
date +%N
}
# Variable declarations
SERIAL=`randomSerial`
NO1=`randomNo`
NO2=`randomNo`
NO3=`randomNo`
ORIGPWD=`pwd`
# The test
rlJournalStart
rlPhaseStartSetup
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "rlImport bind/bind-setup"
#rlRun "wget --quiet http://nest.test.redhat.com/mnt/qa/scratch/mcermak/bind-setup.tar.gz && tar xvzf bind-setup.tar.gz > /dev/null && . bind-setup/bind-setup.sh" 0 "Imported bind-setup functions."
bsBindSetupStart "$ORIGPWD/named.conf" "off"
rlRun "TDOMAIN=`randomString`.cz"
rlRun "TZONEFILE=$ROOTDIR/var/named/$TDOMAIN.rr.zone"
rlRun "sed -i \"s/<DOMAIN>/$TDOMAIN/g\" /etc/named.conf"
# zonefile
rlRun "cp $ORIGPWD/zonefile $TZONEFILE"
rlRun "chmod a+r $TZONEFILE"
rlRun "sed -i \"s/<DOMAIN>/$TDOMAIN/g\" $TZONEFILE"
rlRun "sed -i \"s/<SERIAL>/$SERIAL/g\" $TZONEFILE"
rlRun "sed -i \"s/<NO1>/$NO1/g\" $TZONEFILE"
rlRun "sed -i \"s/<NO2>/$NO2/g\" $TZONEFILE"
rlRun "sed -i \"s/<NO3>/$NO3/g\" $TZONEFILE"
bsBindSetupDone
rlPhaseEnd
rlPhaseStartTest
# perform tests
rlRun "dig @localhost -x 10.0.1.$NO1 +short | grep \"^alice.$TDOMAIN.$\""
rlRun "dig @localhost -x 10.0.1.$NO2 +short | grep \"^betty.$TDOMAIN.$\""
rlRun "dig @localhost -x 10.0.1.$NO3 +short | grep \"^charlie.$TDOMAIN.$\""
rlPhaseEnd
rlPhaseStartCleanup
bsBindSetupCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlRun "rm -rf $TZONEFILE"
rlPhaseEnd
rlJournalEnd

View file

@ -0,0 +1,16 @@
$ORIGIN 1.0.10.in-addr.arpa.
$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>.
<NO1> IN PTR alice.<DOMAIN>.
<NO2> IN PTR betty.<DOMAIN>.
<NO3> IN PTR charlie.<DOMAIN>.

View 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: 90m" >> $(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)

View 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>

View file

@ -0,0 +1,11 @@
options {
directory "/var/named";
allow-query { any; };
};
zone "<DOMAIN>" IN {
type master;
file "<DOMAIN>.zone";
allow-update { none; };
};

View file

@ -0,0 +1,115 @@
#!/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
#for i in `seq 1 8888888888888888`;do echo "ftp$i IN CNAME server1" >> $TZONEFILE ;done
#service named stop
#sleep 1
#service named start
#####dig @localhost ftp100.f759b6bf.cz
#dig @localhost ftp88888888.$TDOMAIN | grep \"^ftp.$TDOMAIN\" | grep \"server1.$TDOMAIN\""
rlPhaseStartCleanup
bsBindSetupCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlRun "rm -rf $TZONEFILE"
rlPhaseEnd
rlJournalEnd

View 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

View file

@ -0,0 +1,71 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/bind/Sanity/Run-internal-BIND-test-suite
# Description: Run internal BIND test suite
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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/Run-internal-BIND-test-suite
export TESTVERSION=1.3
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE knownerror* setup-named-softhsm.sh bind-systest-filter.sh
.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: Run internal BIND test suite" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 8h" >> $(METADATA)
@echo "RunFor: bind" >> $(METADATA)
@echo "Requires: bind perl-Net-DNS rpm-build bind-utils" >> $(METADATA)
@echo "Requires: bind-pkcs11 bind-pkcs11-utils softhsm" >> $(METADATA)
@echo "Requires: openssl-devel libtool autoconf" >> $(METADATA)
@echo "Requires: libcap-devel libidn-devel libxml2-devel" >> $(METADATA)
@echo "Requires: openldap-devel postgresql-devel" >> $(METADATA)
@echo "Requires: sqlite-devel krb5-devel net-tools perl-Net-DNS-Nameserver" >> $(METADATA)
@echo "Requires: yum-utils dnf-utils" >> $(METADATA)
@echo "Requires: gcc-c++" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Bug: 642970" >> $(METADATA)
rhts-lint $(METADATA)

View file

@ -0,0 +1,6 @@
PURPOSE of /CoreOS/bind/Sanity/Run-internal-BIND-test-suite
Description: Run internal BIND test suite
Author: Martin Cermak <mcermak@redhat.com>
Bug summary: Run internal BIND test suite
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=642970

View file

@ -0,0 +1,47 @@
#!/bin/bash
#
# This script will filter out output from BINDs tests
# It supports form from BIND 9.9 and BIND 9.11
# Its purpose is to display only failed tests from list of all tests
CURRENT_TEST=
CURRENT_OUTPUT=
STATUS_ONLY=
for P; do
case "$P" in
-s|--status) STATUS_ONLY=yes; shift ;;
esac
done
cat $@ | while read LINE; do
if [ "${LINE#S:}" != "$LINE" ]; then
CURRENT_TEST=`echo $LINE | cut -d: -f2`
CURRENT_OUTPUT="$LINE"$'\n'
elif [ "${LINE#R:}" != "$LINE" ]; then
# echo "$CURRENT_TEST $LINE"
if [ "${LINE/#R:*:*}" != "$LINE" ]; then
# more recent results contain test name
# R:dlz:FAIL
CURRENT_TEST="${LINE#R:}"
CURRENT_TEST="${CURRENT_TEST/%:*}"
RESULT="${LINE/#*:}"
else
# S:dlz:time
# R:FAIL
RESULT="${LINE/#R*:/}"
fi
if [ "$RESULT" != "PASS" ]; then
if [ -n "$STATUS_ONLY" ]; then
echo "$RESULT $CURRENT_TEST"
else
CURRENT_OUTPUT+="$LINE"
echo "$CURRENT_OUTPUT"
echo
fi
fi
CURRENT_OUTPUT=
else
CURRENT_OUTPUT+="$LINE"$'\n'
fi
done

View file

@ -0,0 +1 @@
A:System test dlz

View file

@ -0,0 +1,2 @@
A:System test rrl
A:System test autosign

View file

@ -0,0 +1,3 @@
dlz
dnssec
idna

View file

@ -0,0 +1,3 @@
dlz
dnssec
mkeys

View file

@ -0,0 +1 @@
dlz

View file

@ -0,0 +1,242 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/bind/Sanity/Run-internal-BIND-test-suite
# Description: Run internal BIND test suite
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Usable variables:
# override make target to start testing on more threads
# MAKE_TEST='-j4 test'
# Do not clean existing build if already built
# REUSE_BUILD=y
# Make retest faster, skip build if possible
# QUICK=y
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE=""
rpm -q bind && PACKAGE="bind"
rpm -q bind97 && PACKAGE="bind97"
rlJournalStart
rlPhaseStartSetup
rpm -q perl-Net-DNS-Nameserver || yum install -y perl-Net-DNS-Nameserver
rlLog "`rpm -q perl-Net-DNS-Nameserver`"
# package assertions
rlAssertRpm $PACKAGE
rlAssertRpm rpm-build
#pwd
ORIG=`pwd`
FOUNDERROR=`mktemp`
SETUP_SOFTHSM=`readlink -f setup-named-softhsm.sh`
FILTER=`readlink -f bind-systest-filter.sh`
TAG=generic
if [ -f /etc/os-release ]; then
# extract platform tag
VERSION_ID=`(source /etc/os-release && echo ${ID}-${VERSION_ID})`
TAG=`(source /etc/os-release && echo ${PLATFORM_ID#platform:})`
else
rlIsRHEL '6' && TAG=el6
fi
if [ -f "knownerror.$VERSION_ID" ]; then
KNOWNERROR=`readlink -f knownerror.$VERSION_ID`
elif [ -f "knownerror.$TAG" ]; then
KNOWNERROR=`readlink -f knownerror.$TAG`
elif [ -f "knownerror" ]; then
KNOWNERROR=`readlink -f knownerror`
fi
if [ -n "$QUICK" ]; then
REUSE_BUILD=y
MAKE_TEST='test -j4'
fi
#tempdir
rlRun "TMPDIR=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TMPDIR"
if rlIsRHEL 8 && dnf config-manager --help >/dev/null; then
# Some build dependencies are not in repositories enabled
# by default: libidn2-devel, softshm
dnf config-manager --set-enabled rhel-buildroot
#not checking return code: 1mt and beaker uses different names for repo
fi
# topdir
if rlIsRHEL 3 || rlIsRHEL 4 || rlIsRHEL 5; then
TOPDIR="/usr/src/redhat"
else
TOPDIR="/root/rpmbuild"
fi
# cleanup in topdir
mkdir -p $TOPDIR/{BUILD,SOURCES,SPECS}
if [ "$REUSE_BUILD" != y ]
then
rlRun "rm -rf $TOPDIR/{BUILD,SOURCES,SPECS}/*"
else
rlLog "Not cleaning previous build"
fi
# download src rpm
rlFetchSrcForInstalled "$PACKAGE"
if ! ls bind*.src.rpm; then
rlRun "yumdownloader --source bind" 0 "Trying alternative fetch from repository"
rlRun "rpm -i bind*.src.rpm"
fi
rlRun "rpm --define '_topdir $TOPDIR' -Uvh *rpm &> $TMPDIR/install.txt"
rlRun "cd $TOPDIR/SPECS"
# softhsm is no longer in normal repository. Enable idm module on RHEL8 to make softhsm module available
if rlIsRHEL 8
then
rlRun "dnf -y module enable idm:DL1"
fi
if dnf builddep --help >/dev/null; then
rlRun "dnf -y builddep --nobest *.spec"
elif which yum-builddep; then
rlRun "yum-builddep -y *.spec"
else
rlWarn "there is nor yum-utils neither dnf-utils for install dependencies, ENJOY!"
fi
# stop bind if it is running
service named stop
rlPhaseEnd
rlPhaseStartTest
if [ "$REUSE_BUILD" = y ] && ls -1 "$TOPDIR/BUILD"/bind* > /dev/null
then
rlLog "Skipping bind build"
else
# rebuild from source
rlRun "rpmbuild -ba *.spec &> $TMPDIR/build.txt" 0 "Building bind"
fi
# the test
rlRun "cd $TOPDIR/BUILD/bind*"
rlLogInfo "Test takes place in `pwd`"
rlRun "chown -R root ."
if [ -x "$SETUP_SOFTHSM" ]; then
rlRun "eval $(bash $SETUP_SOFTHSM -A)" 0 "Preparing PKCS#11 token slot"
rlRun "pkcs11-tokens" 0 "Testing token slot availability"
else
rlLog "PKCS#11 not initialized"
fi
if [ -d build ]; then
BUILD=build
else
BUILD=.
fi
rlRun "./bin/tests/system/ifconfig.sh up" 0 "Setup fake network interfaces."
# required by idna test
export LC_ALL=en_US.UTF-8
rlRun "pushd $BUILD"
# keep separate results on 9.11+
rlRun "sed -e 's/testsummary.sh/& -n/' -i bin/tests/system/Makefile" 0 "Modify to keep results"
# dlz test is broken because specific build way we use. It is supported only by named-sdb
# but that is not even tested by testsuite
rlRun "sed -e 's/ dlz / /' -i bin/tests/system/Makefile" 0 "Skip always failing dlz test"
# Try to fix tssgsig failures on some machines, do not use system kerberos configuration
export KRB5_CONFIG=/dev/null
# Allow speedup by defining MAKE_TEST='test -j4' on multiprocessor machines
rlRun "make ${MAKE_TEST:-test} &> $TMPDIR/test.txt" 0-255 "Perform the test."
export -n KRB5_CONFIG
# This would catch just errors on 9.11+
if [ -f bin/tests/system/testsummary.sh ]; then
FAILED_TESTS=`grep '^R:[a-z0-9_-][a-z0-9_-]*:FAIL' $TMPDIR/test.txt | cut -d':' -f2 | sort | xargs echo`
if [ -n "$FAILED_TESTS" ]; then
rlLog "Failed tests: $FAILED_TESTS"
rlRun "tar czf $TMPDIR/failed-artifacts.tar.gz -C bin/tests/system $FAILED_TESTS" 0 "Archiving failed artifacts in tests"
else
rlLog "No failed tests"
fi
else
FAILED_TESTS=:any:
rlRun "tar czf $TMPDIR/failed-artifacts.tar.gz bin/tests/system" 0 "Archiving all system tests"
fi
rlRun "popd"
rlRun "grep -C 10 FAIL $TMPDIR/test.txt" 0-255 "Quickly show the test error (if any)."
rlRun "./bin/tests/system/ifconfig.sh down" 0 "Remove fake network interfaces."
#list of failures:
rlRun "$FILTER $TMPDIR/test.txt" 0 "Showing unsuccessful tests"
rlRun "$FILTER -s $TMPDIR/test.txt > $FOUNDERROR" 0
rlRun "ls $KNOWNERROR $FOUNDERROR $TMPDIR/test.txt" 0 'check if there are needed files'
rlLog "`echo list;cat $FOUNDERROR`"
FAILED_FOUND="$(grep '^FAIL' $FOUNDERROR | wc -l)"
FAILED_KNOWN="$(wc -l <$KNOWNERROR)"
rlAssertLesserOrEqual "Checking number of found errors is in limits" "$FAILED_FOUND" "$FAILED_KNOWN"
cat $FOUNDERROR | while read STATUS TEST ; do
if [ "$STATUS" = FAIL ]; then
rlRun "grep '$TEST' $KNOWNERROR" 0 "Check $TEST failure is expected"
else
rlLog "$STATUS $TEST"
fi
done
if [ "$FAILED_TESTS" = ':any:' ] && [ "$FAILED_FOUND" -le "$FAILED_KNOWN" ]
then
# Newer version produces archive only when some error occured
rlLog "No error found, not uploading artifacts"
rm -f "$TMPDIR/failed-artifacts.tar.gz"
fi
rlPhaseEnd
rlPhaseStartCleanup "`echo RESULT_ ;cat $FOUNDERROR|grep 'FAIL'`"
#this phase is only due to report to webUI without needs of open file
rlLog "`echo RESULT_ ;cat $FOUNDERROR|grep FAIL`"
rlPhaseEnd
rlPhaseStartCleanup
rlBundleLogs "TEST_LOGS" "$TMPDIR/install.txt" "$TMPDIR/builddeps.txt" "$TMPDIR/build.txt" "$TMPDIR/test.txt"
if [ -r "$TMPDIR/failed-artifacts.tar.gz" ]; then
rlFileSubmit "$TMPDIR/failed-artifacts.tar.gz" failed-artifacts.tar.gz
fi
rlRun "popd"
rlRun "rm -r $TMPDIR" 0 "Removing tmp directory"
rlRun "rm -rf $FOUNDERROR"
rlPhaseEnd
rlJournalEnd

View file

@ -0,0 +1,123 @@
#!/bin/sh
#
# This script will initialise token storage of softhsm PKCS11 provider
# in custom location. Is useful to store tokens in non-standard location.
#
# Output can be evaluated from bash, it will prepare it for usage of temporary tokens.
# Recommended use:
# eval $(bash setup-named-softhsm.sh -A)
#
SOFTHSM2_CONF="$1"
TOKENPATH="$2"
GROUPNAME="$3"
# Do not use this script for real keys worth protection
# This is intended for crypto accelerators using PKCS11 interface.
# Uninitialized token would fail any crypto operation.
PIN=1234
SO_PIN=1234
LABEL=rpm
set -e
echo_i()
{
echo "#" $@
}
random()
{
if [ -x "$(which openssl 2>/dev/null)" ]; then
openssl rand -base64 $1
else
dd if=/dev/urandom bs=1c count=$1 | base64
fi
}
usage()
{
echo "Usage: $0 -A [token directory] [group]"
echo " or: $0 <config file> <token directory> [group]"
}
if [ "$SOFTHSM2_CONF" = "-A" -a -z "$TOKENPATH" ]; then
TOKENPATH=$(mktemp -d /var/tmp/softhsm-XXXXXX)
fi
if [ -z "$SOFTHSM2_CONF" -o -z "$TOKENPATH" ]; then
usage >&2
exit 1
fi
if [ "$SOFTHSM2_CONF" = "-A" ]; then
# Automagic mode instead
MODE=secure
SOFTHSM2_CONF="$TOKENPATH/softhsm2.conf"
PIN_SOURCE="$TOKENPATH/pin"
SOPIN_SOURCE="$TOKENPATH/so-pin"
TOKENPATH="$TOKENPATH/tokens"
else
MODE=legacy
fi
[ -d "$TOKENPATH" ] || mkdir -p "$TOKENPATH"
umask 0022
if ! [ -f "$SOFTHSM2_CONF" ]; then
cat << SED > "$SOFTHSM2_CONF"
# SoftHSM v2 configuration file
directories.tokendir = ${TOKENPATH}
objectstore.backend = file
# ERROR, WARNING, INFO, DEBUG
log.level = ERROR
# If CKF_REMOVABLE_DEVICE flag should be set
slots.removable = false
SED
else
echo_i "Config file $SOFTHSM2_CONF already exists" >&2
fi
if [ -n "$PIN_SOURCE" ]; then
touch "$PIN_SOURCE" "$SOPIN_SOURCE"
chmod 0600 "$PIN_SOURCE" "$SOPIN_SOURCE"
if [ -n "$GROUPNAME" ]; then
chgrp "$GROUPNAME" "$PIN_SOURCE" "$SOPIN_SOURCE"
chmod g+r "$PIN_SOURCE" "$SOPIN_SOURCE"
fi
fi
export SOFTHSM2_CONF
if softhsm2-util --show-slots | grep 'Initialized:[[:space:]]*yes' > /dev/null
then
echo_i "Token in ${TOKENPATH} is already initialized" >&2
[ -f "$PIN_SOURCE" ] && PIN=$(cat "$PIN_SOURCE")
[ -f "$SOPIN_SOURCE" ] && SO_PIN=$(cat "$SOPIN_SOURCE")
else
PIN=$(random 6)
SO_PIN=$(random 18)
if [ -n "$PIN_SOURCE" ]; then
echo -n "$PIN" > "$PIN_SOURCE"
echo -n "$SO_PIN" > "$SOPIN_SOURCE"
fi
echo_i "Initializing tokens to ${TOKENPATH}..."
softhsm2-util --init-token --free --label "$LABEL" --pin "$PIN" --so-pin "$SO_PIN" | sed -e 's/^/# /'
if [ -n "$GROUPNAME" ]; then
chgrp -R -- "$GROUPNAME" "$TOKENPATH"
chmod -R -- g=rX,o= "$TOKENPATH"
fi
fi
echo "export SOFTHSM2_CONF=\"$SOFTHSM2_CONF\""
echo "export PIN_SOURCE=\"$PIN_SOURCE\""
echo "export SOPIN_SOURCE=\"$SOPIN_SOURCE\""
# These are intentionaly not exported
echo "PIN=\"$PIN\""
echo "SO_PIN=\"$SO_PIN\""