Skip to content

Commit

Permalink
Merge pull request redhat-performance#665 from yarda/spec-profile-pat…
Browse files Browse the repository at this point in the history
…hs-macro

spec: used macro for profiles path and other fixes
  • Loading branch information
yarda authored Oct 16, 2024
2 parents 8570e80 + 7a41949 commit 35eed3c
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 107 deletions.
54 changes: 33 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ $(error Failed to determine python library directory)
endif
KERNELINSTALLHOOKDIR = /usr/lib/kernel/install.d
TUNED_SYSTEM_DIR = /usr/lib/tuned
TUNED_PROFILES_DIR = $(TUNED_SYSTEM_DIR)/profiles
TUNED_SYSTEM_PROFILES_DIR = $(TUNED_SYSTEM_DIR)/profiles
TUNED_CFG_DIR = $(SYSCONFDIR)/tuned
TUNED_USER_PROFILES_DIR = $(TUNED_CFG_DIR)/profiles
TUNED_RECOMMEND_DIR = $(TUNED_SYSTEM_DIR)/recommend.d
TUNED_USER_RECOMMEND_DIR = $(SYSCONFDIR)/tuned/recommend.d
TUNED_USER_RECOMMEND_DIR = $(TUNED_CFG_DIR)/recommend.d
BASH_COMPLETIONS = $(DATADIR)/bash-completion/completions

copy_executable = install -Dm 0755 $(1) $(2)
Expand Down Expand Up @@ -129,13 +131,13 @@ clean-html:

install-dirs:
mkdir -p $(DESTDIR)$(PYTHON_SITELIB)
mkdir -p $(DESTDIR)$(TUNED_PROFILES_DIR)
mkdir -p $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)
mkdir -p $(DESTDIR)/var/lib/tuned
mkdir -p $(DESTDIR)/var/log/tuned
mkdir -p $(DESTDIR)/run/tuned
mkdir -p $(DESTDIR)$(DOCDIR)
mkdir -p $(DESTDIR)$(SYSCONFDIR)
mkdir -p $(DESTDIR)$(SYSCONFDIR)/tuned/profiles
mkdir -p $(DESTDIR)$(TUNED_USER_PROFILES_DIR)
mkdir -p $(DESTDIR)$(TUNED_RECOMMEND_DIR)
mkdir -p $(DESTDIR)$(TUNED_USER_RECOMMEND_DIR)

Expand All @@ -161,26 +163,36 @@ install: install-dirs
experiments/powertop2tuned.py, $(DESTDIR)/usr/bin/powertop2tuned)

# configuration files
install -Dpm 0644 tuned-main.conf $(DESTDIR)$(SYSCONFDIR)/tuned/tuned-main.conf
# Update default profiles location, in the configuration and in the code
sed '/^\s*#\?\s*profile_dirs\s*=\s*/ s|\(profile_dirs\s*=\s*\).*$$|\1$(TUNED_SYSTEM_PROFILES_DIR),$(TUNED_USER_PROFILES_DIR)|' \
tuned-main.conf > tuned-main.conf.tmp
touch -r tuned-main.conf tuned-main.conf.tmp
sed -i '/^\s*USER_PROFILES_DIR\s*=\s*/ s|\(USER_PROFILES_DIR\s*=\s*\).*$$|\1"$(TUNED_USER_PROFILES_DIR)"|' \
$(DESTDIR)$(PYTHON_SITELIB)/tuned/consts.py
sed -i '/^\s*SYSTEM_PROFILES_DIR\s*=\s*/ s|\(SYSTEM_PROFILES_DIR\s*=\s*\).*$$|\1"$(TUNED_SYSTEM_PROFILES_DIR)"|' \
$(DESTDIR)$(PYTHON_SITELIB)/tuned/consts.py
install -Dpm 0644 tuned-main.conf.tmp $(DESTDIR)$(TUNED_CFG_DIR)/tuned-main.conf
rm -f tuned-main.conf.tmp

# None profile in the moment, autodetection will be used
echo -n > $(DESTDIR)$(SYSCONFDIR)/tuned/active_profile
echo -n > $(DESTDIR)$(SYSCONFDIR)/tuned/profile_mode
echo -n > $(DESTDIR)$(SYSCONFDIR)/tuned/post_loaded_profile
install -Dpm 0644 bootcmdline $(DESTDIR)$(SYSCONFDIR)/tuned/bootcmdline
echo -n > $(DESTDIR)$(TUNED_CFG_DIR)/active_profile
echo -n > $(DESTDIR)$(TUNED_CFG_DIR)/profile_mode
echo -n > $(DESTDIR)$(TUNED_CFG_DIR)/post_loaded_profile
install -Dpm 0644 bootcmdline $(DESTDIR)$(TUNED_CFG_DIR)/bootcmdline
install -Dpm 0644 modules.conf $(DESTDIR)$(SYSCONFDIR)/modprobe.d/tuned.conf

# profiles & system config
cp -a profiles/* $(DESTDIR)$(TUNED_PROFILES_DIR)/
mv $(DESTDIR)$(TUNED_PROFILES_DIR)/realtime/realtime-variables.conf \
$(DESTDIR)$(SYSCONFDIR)/tuned/realtime-variables.conf
mv $(DESTDIR)$(TUNED_PROFILES_DIR)/realtime-virtual-guest/realtime-virtual-guest-variables.conf \
$(DESTDIR)$(SYSCONFDIR)/tuned/realtime-virtual-guest-variables.conf
mv $(DESTDIR)$(TUNED_PROFILES_DIR)/realtime-virtual-host/realtime-virtual-host-variables.conf \
$(DESTDIR)$(SYSCONFDIR)/tuned/realtime-virtual-host-variables.conf
mv $(DESTDIR)$(TUNED_PROFILES_DIR)/cpu-partitioning/cpu-partitioning-variables.conf \
$(DESTDIR)$(SYSCONFDIR)/tuned/cpu-partitioning-variables.conf
mv $(DESTDIR)$(TUNED_PROFILES_DIR)/cpu-partitioning-powersave/cpu-partitioning-powersave-variables.conf \
$(DESTDIR)$(SYSCONFDIR)/tuned/cpu-partitioning-powersave-variables.conf
cp -a profiles/* $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)/
mv $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)/realtime/realtime-variables.conf \
$(DESTDIR)$(TUNED_CFG_DIR)/realtime-variables.conf
mv $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)/realtime-virtual-guest/realtime-virtual-guest-variables.conf \
$(DESTDIR)$(TUNED_CFG_DIR)/realtime-virtual-guest-variables.conf
mv $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)/realtime-virtual-host/realtime-virtual-host-variables.conf \
$(DESTDIR)$(TUNED_CFG_DIR)/realtime-virtual-host-variables.conf
mv $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)/cpu-partitioning/cpu-partitioning-variables.conf \
$(DESTDIR)$(TUNED_CFG_DIR)/cpu-partitioning-variables.conf
mv $(DESTDIR)$(TUNED_SYSTEM_PROFILES_DIR)/cpu-partitioning-powersave/cpu-partitioning-powersave-variables.conf \
$(DESTDIR)$(TUNED_CFG_DIR)/cpu-partitioning-powersave-variables.conf
install -pm 0644 recommend.conf $(DESTDIR)$(TUNED_RECOMMEND_DIR)/50-tuned.conf

# bash functions used by profile scripts
Expand Down Expand Up @@ -228,7 +240,7 @@ install: install-dirs
install -dD $(DESTDIR)$(DATADIR)/applications
desktop-file-install --dir=$(DESTDIR)$(DATADIR)/applications tuned-gui.desktop

install-ppd: install
install-ppd:
$(call install_python_script,tuned-ppd.py,$(DESTDIR)/usr/sbin/tuned-ppd)
install -Dpm 0644 tuned/ppd/tuned-ppd.service $(DESTDIR)$(UNITDIR)/tuned-ppd.service
install -Dpm 0644 tuned/ppd/tuned-ppd.dbus.service $(DESTDIR)$(DATADIR)/dbus-1/system-services/net.hadess.PowerProfiles.service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR="/etc/tuned/profiles"

rlJournalStart
rlPhaseStartSetup
Expand All @@ -29,33 +28,36 @@ rlJournalStart
rlServiceStart "tuned"
rlImport "tuned/basic"
tunedProfileBackup
rlFileBackup "/etc/tuned/active_profile"
rlFileBackup "/etc/tuned/active_profile"
rlFileBackup "/etc/tuned/profile_mode"

rlRun "mkdir $PROFILE_DIR/test-profile"
rlServiceStart "tuned"
PROFILE_DIR=$(tunedGetProfilesBaseDir)

rlRun "mkdir -p ${PROFILE_DIR}/test-profile"
rlServiceStop "tuned"
sleep 1
rlFileBackup "/var/log/tuned/tuned.log"
rlRun "rm -rf /var/log/tuned/tuned.log"
rlFileBackup "/var/log/tuned/tuned.log"
rlRun "rm -rf /var/log/tuned/tuned.log"
rlServiceStart "tuned"
rlPhaseEnd

rlPhaseStartTest
rlRun "pushd $PROFILE_DIR/test-profile"
cat << EOF > tuned.conf
rlRun "pushd $PROFILE_DIR/test-profile"
cat << EOF > tuned.conf
[scheduler]
runtime=0
EOF
rlRun "popd"
rlRun "popd"

rlRun "tuned-adm profile test-profile"
rlRun "tuned-adm profile test-profile"
rlServiceStop "tuned"
sleep 3
sleep 3
rlServiceStart "tuned"
sleep 3
sleep 3
rlServiceStop "tuned"

rlAssertNotGrep "Traceback" "/var/log/tuned/tuned.log"
rlAssertNotGrep "object has no attribute '_evlist'" "/var/log/tuned/tuned.log"
rlAssertNotGrep "Traceback" "/var/log/tuned/tuned.log"
rlAssertNotGrep "object has no attribute '_evlist'" "/var/log/tuned/tuned.log"
rlPhaseEnd

rlPhaseStartCleanup
Expand All @@ -65,10 +67,10 @@ EOF

tunedProfileRestore
rlServiceStop "tuned"
rlFileRestore
rlFileRestore

rlServiceRestore "tuned"
rlRun "rm -rf $PROFILE_DIR/test-profile"
rlRun "rm -rf $PROFILE_DIR/test-profile"
rlPhaseEnd

rlJournalPrintText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
SYSCONF_DIR=/etc/tuned
PROFILE_DIR=$SYSCONF_DIR/profiles
ACTIVE_PROFILE=$SYSCONF_DIR/active_profile
PROFILE_MODE=$SYSCONF_DIR/profile_mode
POST_LOADED_PROFILE=$SYSCONF_DIR/post_loaded_profile
SYSCONF_DIR="/etc/tuned"
ACTIVE_PROFILE=/etc/tuned/active_profile
POST_LOADED_PROFILE="/etc/tuned/post_loaded_profile"
PROFILE_MODE=/etc/tuned/profile_mode
SWAPPINESS=vm.swappiness
DIRTY_RATIO=vm.dirty_ratio
PID_FILE=/run/tuned/tuned.pid
Expand Down Expand Up @@ -62,9 +61,12 @@ function wait_for_tuned_stop()
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE

rlImport "tuned/basic"
tunedDisableSystemdRateLimitingStart
rlRun "for PYTHON in $PYTHON_CHECK; do \$PYTHON --version 2>/dev/null && break; done" 0 "Detect python"
PROFILE_DIR=$(tunedGetProfilesBaseDir)

rlRun "rlFileBackup --clean $SYSCONF_DIR"
rlRun "cp -r parent $PROFILE_DIR"
rlRun "cp -r parent2 $PROFILE_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR=/etc/tuned/profiles

rlJournalStart
rlPhaseStartSetup
Expand All @@ -29,7 +28,9 @@ rlJournalStart
rlServiceStart "tuned"
tunedProfileBackup

rlRun "mkdir $PROFILE_DIR/test-profile"
PROFILE_DIR=$(tunedGetProfilesBaseDir)

rlRun "mkdir -p $PROFILE_DIR/test-profile"
rlRun "pushd $PROFILE_DIR/test-profile"
cat << EOF > tuned.conf
[sysctl]
Expand All @@ -53,8 +54,8 @@ EOF

rlAssertGrep "test-profile" "/etc/tuned/active_profile"

# last value from config is used
rlAssertGrep "16384$" /sys/fs/selinux/avc/cache_threshold
# last value from config is used
rlAssertGrep "16384$" /sys/fs/selinux/avc/cache_threshold
rlPhaseEnd

rlPhaseStartCleanup
Expand Down
6 changes: 5 additions & 1 deletion tests/beakerlib/error-messages/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR="/usr/lib/tuned/profiles"

rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlImport "tuned/basic"

PROFILE_DIR=$(tunedGetSystemProfilesBaseDir)

rlFileBackup "/var/log/tuned/tuned.log"
tunedDisableSystemdRateLimitingStart
rlServiceStart "tuned"
tunedProfileBackup
Expand All @@ -50,6 +53,7 @@ rlJournalStart
rlPhaseStartCleanup
tunedDisableSystemdRateLimitingEnd
tunedProfileRestore
rlFileRestore
rlServiceRestore "tuned"
rlPhaseEnd
rlJournalPrintText
Expand Down
11 changes: 7 additions & 4 deletions tests/beakerlib/variables-support-in-profiles/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR="/usr/lib/tuned/profiles"

rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlImport "tuned/basic"

PROFILE_DIR=$(tunedGetProfilesBaseDir)

rlRun "mkdir -p $PROFILE_DIR/balanced"

tunedDisableSystemdRateLimitingStart
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlServiceStart "tuned"
tunedProfileBackup
rlFileBackup "$PROFILE_DIR/balanced/tuned.conf"

echo "
[variables]
Expand All @@ -55,8 +57,9 @@ vm.swappiness = \${SWAPPINESS2}
rlPhaseStartCleanup
rlRun "sysctl vm.swappiness=$OLD_SWAPPINESS"
tunedDisableSystemdRateLimitingEnd
rlFileRestore
tunedProfileRestore
rlRun "rm -f ${PROFILE_DIR}/balanced/*"
rlRun "rmdir ${PROFILE_DIR}/balanced"
rlServiceRestore "tuned"
rlRun "systemctl daemon-reload"
rlRun "popd"
Expand Down
Loading

0 comments on commit 35eed3c

Please sign in to comment.