diff --git a/core/logging-to-journald/httpd.conf b/core/logging-to-journald/httpd.conf new file mode 100644 index 0000000..98111e8 --- /dev/null +++ b/core/logging-to-journald/httpd.conf @@ -0,0 +1,7 @@ +CustomLog journald:notice combined + + + ServerName vhost.localdomain:80 + LogFormat "foo@@%v@@%U@@bar" rhjournal + CustomLog journald:error rhjournal + diff --git a/core/logging-to-journald/main.fmf b/core/logging-to-journald/main.fmf new file mode 100644 index 0000000..bb19a8c --- /dev/null +++ b/core/logging-to-journald/main.fmf @@ -0,0 +1,34 @@ +summary: RFE-logging-to-journald +description: | + Bug summary: RFE: CustomLog should be able to use syslog as ErrorLog does + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1209162 +contact: Branislav NĂ¡ter +component: +- httpd +test: ./runtest.sh +framework: beakerlib +require: +- library(httpd/http) +recommend: +- httpd +- curl +duration: 5m +enabled: true +tag: +- HttpdSclDone +- NoRHEL4 +- NoRHEL5 +- TIPfail +- Tier1 +tier: '1' +adjust: +- because: fixed in rhel-8.3 + enabled: false + when: distro < rhel-8 + continue: false +- enabled: false + when: distro ~< rhel-8.3 + continue: false +extra-nitrate: TC#0607562 +extra-summary: /CoreOS/httpd/Regression/bz1209162-RFE-logging-to-journald +extra-task: /CoreOS/httpd/Regression/bz1209162-RFE-logging-to-journald diff --git a/core/logging-to-journald/runtest.sh b/core/logging-to-journald/runtest.sh new file mode 100755 index 0000000..83375e0 --- /dev/null +++ b/core/logging-to-journald/runtest.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/httpd/Regression/bz1209162-RFE-logging-to-journald +# Description: RFE-logging-to-journald +# Author: Joe Orton +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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 + +PACKAGES=${PACKAGES:-"httpd"} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlImport httpd/http || rlDie + rlRun "CONF=$httpCONFDIR/conf.d/bz1209162.conf" + rlRun "cp httpd.conf $CONF" + rlRun "rlFileBackup /etc/hosts" + rlRun "echo 127.0.0.2 vhost.localdomain >> /etc/hosts" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "httpStart" + rlPhaseEnd + + rlPhaseStartTest + # Do all testing with a unique prefix so multiple runs aren't confused + rlRun "PFX=bz1209162_${RANDOM}_${RANDOM}" + # Check that something is logged + rlRun "curl http://localhost/${PFX}-test-alpha > /dev/null" 0 + rlRun "journalctl -u httpd -g ${PFX}-test-alpha > journal.alpha" + rlAssertGrep "GET /${PFX}-test-alpha" journal.alpha + + # Test that requests are only logged at the configured level + rlRun "curl http://localhost/${PFX}-test-beta > /dev/null" 0 + rlRun "journalctl -q -u httpd -g ${PFX}-test-beta -p crit > journal.crit" + rlRun "journalctl -q -u httpd -g ${PFX}-test-beta -p emerg > journal.emerg" + rlRun "journalctl -q -u httpd -g ${PFX}-test-beta -p notice > journal.notice" + rlAssertNotDiffer journal.crit /dev/null + rlAssertNotDiffer journal.emerg /dev/null + rlAssertGrep "GET /${PFX}-test-beta" journal.notice + + # Test for a different vhost config + rlRun "curl http://vhost.localdomain/${PFX}-test-gamma > /dev/null" 0 + rlRun "journalctl -u httpd -g ${PFX}-test-gamma -p err > journal.vhost" + rlAssertGrep "foo@@vhost.localdomain@@/${PFX}-test-gamma@@bar" journal.vhost + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + httpStop + rlFileRestore + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "rm -f $CONF" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd