diff --git a/Sanity/named/dnstap-logging/Makefile b/Sanity/named/dnstap-logging/Makefile new file mode 100644 index 0000000..ee7d5bf --- /dev/null +++ b/Sanity/named/dnstap-logging/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/bind/dnstap-logging +# Description: dnstap logging +# Author: psklenar@redhat.com +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2025 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/bind/dnstap-logging +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE named.conf + +.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: psklenar@redhat.com " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: dnstap logging" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: bind" >> $(METADATA) + @echo "Requires: bind" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/Sanity/named/dnstap-logging/PURPOSE b/Sanity/named/dnstap-logging/PURPOSE new file mode 100644 index 0000000..faa2fa7 --- /dev/null +++ b/Sanity/named/dnstap-logging/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/bind/dnstap-logging +Description: dnstap logging +Author: psklenar@redhat.com +Bug summary: dnstap logging diff --git a/Sanity/named/dnstap-logging/main.fmf b/Sanity/named/dnstap-logging/main.fmf new file mode 100644 index 0000000..f162df3 --- /dev/null +++ b/Sanity/named/dnstap-logging/main.fmf @@ -0,0 +1,20 @@ +summary: 'Test for: (dnstap logging)' +description: dnstap logging +contact: Petr Sklenar +test: ./runtest.sh +framework: beakerlib +duration: 15m +enabled: true +tag: + - NoRHEL6 + - NoRHEL7 + - Tier3 + - bind-utils +tier: '3' +adjust+: + - enabled: false + when: distro < rhel-9 + continue: false + - enabled: false + when: distro = rhel-alt-7 + continue: false diff --git a/Sanity/named/dnstap-logging/named.conf b/Sanity/named/dnstap-logging/named.conf new file mode 100644 index 0000000..1f497a3 --- /dev/null +++ b/Sanity/named/dnstap-logging/named.conf @@ -0,0 +1,17 @@ +options { + directory "/var/named"; + + // Enable dnstap logging + dnstap { all; }; + dnstap-output file "/var/named/data/dnstap.bin" versions 2; + + listen-on port 53 { any; }; + allow-query { any; }; + recursion yes; + dnssec-validation no; +}; + +zone "." IN { + type hint; + file "named.ca"; +}; diff --git a/Sanity/named/dnstap-logging/runtest.sh b/Sanity/named/dnstap-logging/runtest.sh new file mode 100755 index 0000000..e525966 --- /dev/null +++ b/Sanity/named/dnstap-logging/runtest.sh @@ -0,0 +1,85 @@ +#!/usr/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/bind/dnstap-logging +# Description: Test for dnstap logging +# Author: psklenar@redhat.com +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2025 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE=${PACKAGE:-bind} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE || rlDie "Package $PACKAGE not installed" + TESTDIR=$(pwd) + DEFAULT_IF="$(ip a)" + rlLog "Arch: $(arch), PC name: $(hostname), $(hostname -A) User: $(whoami)" + rlLog "$DEFAULT_IF" + + + rlIsRHEL && repos="--enablerepo=rhel-CRB --enablerepo=rhel-buildroot" + rlIsCentOS && repos="--enablerepo=crb" + rlIsRHELLike && rlRun "dnf install -y $(rlGetRecommended) $repos" + rlCheckDependencies + rm -f /var/named/data/dnstap* + + rlPhaseEnd + + rlPhaseStartTest + rlFileBackup /etc/named/conf + cp named.conf /etc/named.conf + rlRun "rlServiceStart named" + sleep 5 + dig @127.0.0.1 fedoraproject.org + dig @127.0.0.1 fedoraproject.org + dig @127.0.0.1 fedoraproject.org + dig @127.0.0.1 ibm.com + dig @127.0.0.1 ibm.com + dig @127.0.0.1 ibm.com + sleep 1 + + rlLog "Is file readable?" + rlLog "`dnstap-read /var/named/data/dnstap.bin|tail`" + rlRun "dnstap-read /var/named/data/dnstapXXX.bin" + if [ $(wc -l < /var/named/data/dnstap.bin) -gt 2 ]; then + rlPass "File has more than 2 lines" + else + rlFail "File has 2 or fewer lines" + fi + + rlLog "rollout logs" + rlRun "rndc dnstap -roll 3" + rlRun "dnstap-read /var/named/data/dnstap.bin.0" + + rlPhaseEnd + + rlPhaseStartCleanup + rlLog 'Cleanup' + rm -f /var/named/data/dnstap.bin.0 /var/named/data/dnstap.bin + rlFileRestore + rlServiceRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd