1
0
Fork 0

tests/beakerlib: Add new test which covers socket API.

And fix licences.
This commit is contained in:
Robin Hack 2023-03-29 07:46:42 -04:00
parent 7b1a20b64c
commit fb8b707aae
4 changed files with 120 additions and 26 deletions

View file

@ -0,0 +1,34 @@
summary: Test for BZ#2113900 (Expose TuneD API to the Unix Domain Socket)
description: |
Bug summary: Expose TuneD API to the Unix Domain Socket
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=2113900
enabled: true
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=2113900
tag:
- NoRHEL4
- NoRHEL5
- NoRHEL6
- NoRHEL7
- Tier1
tier: '1'
adjust:
- enabled: false
when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8
continue: false
contact: Robin Hack <rhack@redhat.com>
component:
- tuned
framework: beakerlib
require:
- library(tuned/basic)
recommend:
- tuned
- nmap-ncat
duration: 10m
extra-nitrate: TC#0614859
extra-summary: /CoreOS/tuned/Regression/Expose-TuneD-API-to-the-Unix-Domain-Socket
extra-task: /CoreOS/tuned/Regression/Expose-TuneD-API-to-the-Unix-Domain-Socket
extra-hardware: |
hostrequire = <cpu><cores op=">=" value="4"/></cpu>
id: b29d3505-f888-400f-8e7b-26449b301a6d

View file

@ -0,0 +1,82 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/tuned/Regression/Expose-TuneD-API-to-the-Unix-Domain-Socket
# Description: Test for BZ#2113900 (Expose TuneD API to the Unix Domain Socket)
# 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"
send() {
local data="$1"
local socket=/run/tuned/tuned.sock
# local send_only=--send-only
printf "$data" | nc $send_only -U /run/tuned/tuned.sock
}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlServiceStart "tuned"
rlImport "tuned/basic"
tunedProfileBackup
rlFileBackup '/etc/tuned/tuned-main.conf'
rlRun "sed -i '/#\? \?unix_socket_path =.*/ {s##unix_socket_path = /run/tuned/tuned.sock#;}' /etc/tuned/tuned-main.conf"
rlRun "sed -i '/#\? \?enable_unix_socket =.*/ {s##enable_unix_socket = 1#;}' /etc/tuned/tuned-main.conf"
rlServiceStop "tuned"
rlServiceStart "tuned"
rlPhaseEnd
rlPhaseStartTest
rlRun "tuned-adm profile virtual-host"
rlRun "tuned-adm profile virtual-guest"
sleep 2
send '{"jsonrpc": "2.0", "method": "active_profile", "id": 1}' | tee TESTOUT
rlAssertGrep "virtual-guest" "TESTOUT"
# combination of calls
send '[{"jsonrpc": "2.0", "method": "active_profile", "id": 1}, {"jsonrpc": "2.0", "method": "profiles", "id": 2}]' | tee TESTOUT
rlAssertGrep '"result": "virtual-guest"' "TESTOUT"
rlAssertGrep 'optimize-serial-console' "TESTOUT"
send '{"jsonrpc": "2.0", "method": "switch_profile", "params": {"profile_name": "balanced"}, "id": 1}' | tee TESTOUT
rlAssertGrep "true, \"OK\"" "TESTOUT"
rlRun "tuned-adm active | tee TESTOUT"
rlAssertGrep "balanced" TESTOUT
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
tunedProfileRestore
rlServiceStop "tuned"
rlFileRestore
rlServiceRestore "tuned"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -8,20 +8,9 @@
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2023 Red Hat, Inc.
# Copyright Red Hat
#
# 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/.
# SPDX-License-Identifier: GPL-2.0-or-later WITH GPL-CC-1.0
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -8,20 +8,9 @@
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2022 Red Hat, Inc.
# Copyright Red Hat
#
# 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/.
# SPDX-License-Identifier: GPL-2.0-or-later WITH GPL-CC-1.0
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~