From 0c52d474f0cc51b4679b961a926b5583f96ebbc1 Mon Sep 17 00:00:00 2001 From: Robin Hack Date: Wed, 31 Jan 2024 08:27:59 -0500 Subject: [PATCH] tests/beakerlib: Add new test which covers sysctl differently. --- .../main.fmf | 24 ++++++++ .../runtest.sh | 60 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/main.fmf create mode 100755 tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/runtest.sh diff --git a/tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/main.fmf b/tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/main.fmf new file mode 100644 index 000000000..eb9bb9df7 --- /dev/null +++ b/tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/main.fmf @@ -0,0 +1,24 @@ +summary: Test for BZ#959732 (tuned ignores /etc/sysctl.d) +description: | + Bug summary: tuned ignores /etc/sysctl.d + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=959732 +contact: rhack@redhat.com +component: [] +framework: beakerlib +recommend: + - tuned +duration: 5m +enabled: true +tag: + - TIPpass + - Tier1 + - TipWaived6 +tier: '1' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=959732 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1103691 +adjust: + - enabled: false + when: arch == s390x + continue: false +id: 38c4c3b1-d68d-451f-bdf9-5de27e4ea822 diff --git a/tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/runtest.sh b/tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/runtest.sh new file mode 100755 index 000000000..cd66cfd75 --- /dev/null +++ b/tests/beakerlib/bz959732-tuned-ignores-etc-sysctl-d/runtest.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/tuned/Regression/bz959732-tuned-ignores-etc-sysctl-d +# Description: Test for BZ#959732 (tuned ignores /etc/sysctl.d) +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright Red Hat +# +# SPDX-License-Identifier: GPL-2.0-or-later WITH GPL-CC-1.0 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="tuned" + +rlJournalStart + rlPhaseStartSetup + + DEFAULT_PROFILE="balanced" + rlIsRHEL 6 && DEFAULT_PROFILE="default" + + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlServiceStart "tuned" + rlRun "mkdir -p /etc/sysctl.d" + rlRun "OLD_VALUE=$(sysctl -n fs.file-max)" + rlRun "NEW_VALUE=$(($OLD_VALUE-1))" + rlLog "Create file in /etc/sysctl.d/ with custom value" + rlRun "echo \"fs.file-max = $NEW_VALUE\" > /etc/sysctl.d/custom.conf" + rlPhaseEnd + + rlPhaseStartTest + for profile in $(tuned-adm list | awk '/^-/ {print $2}') + do + rlLog "Profile: ${profile}" + rlRun "test $(sysctl -n fs.file-max) -eq $OLD_VALUE" + rlRun "tuned-adm profile ${profile}" + sleep 1 + rlRun "test $(sysctl -n fs.file-max) -eq $NEW_VALUE" + rlRun "sysctl -w fs.file-max=$OLD_VALUE" + done + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore "tuned" + rlRun "sysctl fs.file-max=$OLD_VALUE" + rlRun "rm -rf /etc/sysctl.d/custom.conf" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd