From 1f0b377b182c659bcc6c656faab78c3852bf4f08 Mon Sep 17 00:00:00 2001 From: Serhii Turivnyi Date: Apr 11 2018 09:51:53 +0000 Subject: Add CI tests using the standard test interface --- diff --git a/tests/Basic-sanity-test/Makefile b/tests/Basic-sanity-test/Makefile new file mode 100644 index 0000000..ce59f5b --- /dev/null +++ b/tests/Basic-sanity-test/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/avahi/Sanity/Basic-sanity-test +# Description: Tests basic functionality of avahi. +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 Red Hat, Inc. +# +# 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/avahi/Sanity/Basic-sanity-test +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 -e 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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Tests basic functionality of avahi." >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 10m" >> $(METADATA) + @echo "RunFor: avahi" >> $(METADATA) + @echo "Requires: avahi avahi-tools bind bind-chroot bind-utils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RedHatEnterpriseLinux3 -RedHatEnterpriseLinux4" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Basic-sanity-test/PURPOSE b/tests/Basic-sanity-test/PURPOSE new file mode 100644 index 0000000..1486bec --- /dev/null +++ b/tests/Basic-sanity-test/PURPOSE @@ -0,0 +1,15 @@ +PURPOSE of /CoreOS/avahi/Sanity/Basic-sanity-test +Description: Tests basic functionality of avahi. +Author: Martin Cermak + +My objective was to write a very basic sanity test for avahi. +As I'm the avahi newbie, I browsed avahi.org, experimented +a little with RHEL avahi packages and pinged Lennart, which +did not respond. + +My result is a simple test for the avahi domain name resolver. +It requires the avahi-daemon running. As the RHTS/Beaker is/will +shortly be a closed system without the possibility to reach the +outside network, this test contains its own nameserver. + + diff --git a/tests/Basic-sanity-test/named.conf b/tests/Basic-sanity-test/named.conf new file mode 100644 index 0000000..e477af9 --- /dev/null +++ b/tests/Basic-sanity-test/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/Basic-sanity-test/runtest.sh b/tests/Basic-sanity-test/runtest.sh new file mode 100755 index 0000000..b027d39 --- /dev/null +++ b/tests/Basic-sanity-test/runtest.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/avahi/Sanity/Basic-sanity-test +# Description: Tests basic functionality of avahi. +# Author: Martin Cermak +# Author: Tomas Dolezal - rhel7 updates +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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 +. /usr/bin/rhts-environment.sh +. /usr/lib/beakerlib/beakerlib.sh + +TEMPSTR=$(date +%c%N | md5sum | awk '{print $1}' | cut -c -8) +ORIGPWD=$(pwd) + +IP1='127.0.0.1' +IP2='::1' + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm 'avahi' + rlAssertRpm 'avahi-tools' + + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + + ROOTDIR="" #using non-chroot + rlFileBackup /etc/named.conf /etc/resolv.conf + rlFileBackup --clean /var/named/ + cat $ORIGPWD/named.conf > /etc/named.conf + + rlRun "TDOMAIN=$TEMPSTR.cz" + rlRun "TZONEFILE=$ROOTDIR/var/named/$TDOMAIN.zone" + + # set up /etc/named.conf + rlRun "sed -i \"s//$TDOMAIN/g\" /etc/named.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//$(date +%N)/g\" $TZONEFILE" + + rlServiceStart named #using non-chroot + + # set default resolver + rlRun "echo nameserver 127.0.0.1 > /etc/resolv.conf" + rlPhaseEnd + + rlPhaseStartTest + # check bind + rlRun "dig @localhost server1.$TDOMAIN +short | grep $IP1" + rlRun "dig AAAA @localhost server2.$TDOMAIN +short | grep $IP2" + + # turn on avahi or restart it with new resolv.conf + rlServiceStart "avahi-daemon" + + # the test itself... + rlRun "avahi-resolve -4n server1.$TDOMAIN | grep '127.0.0.1'" 0 "Test the IPv4 avahi DN resolver." + rlRun "avahi-resolve -6n server2.$TDOMAIN | grep '::1'" 0 "Test the IPv6 avahi DN resolver." + + rlPhaseEnd + + rlPhaseStartCleanup + rlFileRestore + rlServiceStart avahi-daemon + rlServiceRestore named avahi-daemon + + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd + rlJournalPrintText +rlJournalEnd diff --git a/tests/Basic-sanity-test/zonefile b/tests/Basic-sanity-test/zonefile new file mode 100644 index 0000000..46b8421 --- /dev/null +++ b/tests/Basic-sanity-test/zonefile @@ -0,0 +1,23 @@ +$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 AAAA + +dns1 IN A +dns2 IN A + diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..09b2613 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,16 @@ +--- + +# Tests that run in classic context +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - Basic-sanity-test + required_packages: + - avahi + - avahi-tools + - bind + - bind-chroot + - bind-utils