-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/beakerlib: Add new test which covers build-in functions.
- Loading branch information
1 parent
b15de12
commit a3199e6
Showing
4 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
summary: built-in functions for various conversions. New functionality according to | ||
BZ#1225135. | ||
description: '' | ||
contact: rhack@redhat.com | ||
component: | ||
- tuned | ||
test: ./runtest.sh | ||
framework: beakerlib | ||
require: | ||
- library(tuned/basic) | ||
recommend: | ||
- tuned | ||
duration: 5m | ||
enabled: true | ||
tag: | ||
- FedoraReady | ||
- NoRHEL4 | ||
- NoRHEL5 | ||
- NoRHEL6 | ||
- TIPfail_infra | ||
- TIPpass | ||
- Tier1 | ||
tier: '1' | ||
link: | ||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1225135 | ||
adjust: | ||
- enabled: false | ||
when: distro == rhel-4, rhel-5, rhel-6, rhel-7 | ||
continue: false | ||
- enabled: false | ||
when: distro > rhel-8 | ||
continue: false | ||
- enabled: false | ||
when: distro > f-20 | ||
continue: false | ||
extra-nitrate: TC#0496876 | ||
extra-summary: /CoreOS/tuned/Sanity/built-in-functions | ||
extra-task: /CoreOS/tuned/Sanity/built-in-functions | ||
id: b04c6dd3-4412-4bd9-b4c7-a5cc44172574 |
16 changes: 16 additions & 0 deletions
16
tests/beakerlib/built-in-functions/rhel7_function_testfunc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import base | ||
from tuned.utils.commands import commands | ||
|
||
class testfunc(base.Function): | ||
""" | ||
Test function | ||
""" | ||
def __init__(self): | ||
super(self.__class__, self).__init__("testfunc", 2) | ||
|
||
def execute(self, args): | ||
f = open(str(args[0]),'w') | ||
f.write(str(args[1])) | ||
f.close() | ||
return str(args[1]) + 'returned' | ||
|
16 changes: 16 additions & 0 deletions
16
tests/beakerlib/built-in-functions/rhel8_function_testfunc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from . import base | ||
from tuned.utils.commands import commands | ||
|
||
class testfunc(base.Function): | ||
""" | ||
Test function | ||
""" | ||
def __init__(self): | ||
super(self.__class__, self).__init__("testfunc", 2) | ||
|
||
def execute(self, args): | ||
f = open(str(args[0]),'w') | ||
f.write(str(args[1])) | ||
f.close() | ||
return str(args[1]) + 'returned' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# runtest.sh of /CoreOS/tuned/Sanity/built-in-functions | ||
# Description: built-in functions for various conversions. New functionality according to BZ#1225135. | ||
# Author: Robin Hack <rhack@redhat.com> | ||
# | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# 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" | ||
TUNED_DIR="/usr/lib/tuned" | ||
PROFILE="myprofile" | ||
|
||
|
||
rlJournalStart | ||
|
||
rlPhaseStartSetup | ||
rlAssertRpm $PACKAGE | ||
rlImport "tuned/basic" | ||
rlServiceStart "tuned" | ||
tunedProfileBackup | ||
|
||
|
||
PSITE_PATH=$(python3 -c "import site; print(site.getsitepackages()[3])") | ||
|
||
# RHEL7 is not supported | ||
if rlIsRHEL '>=8' || rlIsCentOS >= 8 || rlIsFedora; then | ||
TEST_SCRIPT="rhel8_function_testfunc.py" | ||
fi | ||
rlRun "cp -v ${TEST_SCRIPT} ${PSITE_PATH}/tuned/profiles/functions/function_testfunc.py" | ||
|
||
# Prepare balanced profile | ||
rlRun "mkdir $TUNED_DIR/$PROFILE" | ||
rlRun -l "echo '[main] | ||
summary=My testing profile | ||
[variables] | ||
VAR1 = \${f:testfunc:/var/tmp/test1:IamTestingThis1} | ||
VAR2 = \${f:testfunc:/var/tmp/test2:\${VAR1}} | ||
cmd = echo | ||
cmd_out = \${f:exec:\${cmd}:output} | ||
VAR3 = \${f:testfunc:/var/tmp/test3:\${cmd_out}} | ||
' >> $TUNED_DIR/$PROFILE/tuned.conf" | ||
rlRun -l "cat $TUNED_DIR/$PROFILE/tuned.conf" | ||
|
||
echo > /var/log/tuned/tuned.log | ||
rlRun "tuned-adm profile $PROFILE" | ||
rlRun -l "cat /var/log/tuned/tuned.log" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest | ||
rlLog "Custom function and variable propagation" | ||
rlAssertGrep "IamTestingThis1" "/var/tmp/test1" | ||
rlAssertGrep "IamTestingThis1returned" "/var/tmp/test2" | ||
|
||
rlLog "Built in 'exec' function" | ||
rlAssertGrep "output" "/var/tmp/test3" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlFileRestore | ||
tunedProfileRestore | ||
rlServiceRestore "tuned" | ||
rlRun "rm -rf $TUNED_DIR/$PROFILE" | ||
rlRun "rm ${PSITE_PATH}/tuned/profiles/functions/function_testfunc.py" | ||
rlRun "rm /var/tmp/test1 /var/tmp/test2" | ||
rlPhaseEnd | ||
|
||
rlJournalPrintText | ||
rlJournalEnd |