PR#1 Merged Add CI tests using the standard test interface

Proposed 4 months ago by yshapovalov
Modified 4 months ago
From git://fedorapeople.org/~yshapovalov/bind add_tests  into rpms/bind master
this is a remote pull-request, so we cannot provide you with a direct link to the file but you can always checkout the pull-request locally to review it entirely. +65
file added

@@ -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)
this is a remote pull-request, so we cannot provide you with a direct link to the file but you can always checkout the pull-request locally to review it entirely. +6
file added

@@ -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>
this is a remote pull-request, so we cannot provide you with a direct link to the file but you can always checkout the pull-request locally to review it entirely. +11
file added

@@ -0,0 +1,11 @@

+ options {

+         directory       "/var/named";

+         allow-query     { any; };

+ };

+ 

+ zone "<DOMAIN>" IN {

+   type master;

+   file "<DOMAIN>.zone";

+   allow-update { none; };

+ };

+ 
this is a remote pull-request, so we cannot provide you with a direct link to the file but you can always checkout the pull-request locally to review it entirely. +109
file added

@@ -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
this is a remote pull-request, so we cannot provide you with a direct link to the file but you can always checkout the pull-request locally to review it entirely. +27
file added

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

+ 
this is a remote pull-request, so we cannot provide you with a direct link to the file but you can always checkout the pull-request locally to review it entirely. +15
file added

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

Justification

Adds tests according to the CI wiki specifically the standard test interface in the spec.

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:

Test enveronment

Make sure you have installed packages from the spec

# rpm -q ansible python2-dnf libselinux-python standard-test-roles \
ansible-2.4.1.0-2.fc27.noarch
python2-dnf-2.7.5-1.fc27.noarch
libselinux-python-2.7-2.fc27.x86_64
standard-test-roles-2.5-1.fc27.noarch

Run tests for Classic

# export TEST_SUBJECTS=
# sudo ansible-playbook --tags classic tests.yml

Snip of the example test run for Classic tests:

TASK [standard-test-rhts : Check the results for failures] ********************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=39   changed=30   unreachable=0    failed=0   

Notes

Tests will be enabled in CI, yet gating is currently disabled, so nothing will change. Tests will run on each dist-git commit, they are not triggered on koji builds and if you are using FMN, it should notify you of failures normally.

The RH QE maintainer contact in case you have questions: yhsapova @redhat.com
The idea is that these tests become yours just as you're maintaining the package, there will of course be people around if you have questions or troubles.

4 months ago

Pull-Request has been merged by pemensik