Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Add iscsi/params test case (#827)
Browse files Browse the repository at this point in the history
Signed-off-by: Vector Li <[email protected]>
  • Loading branch information
Vector Li authored and veruu committed Jun 20, 2019
1 parent 2a4c697 commit 5984559
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 0 deletions.
94 changes: 94 additions & 0 deletions storage/include/libbkrm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
#
# Copyright (c) 2019 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#

source /usr/bin/rhts_environment.sh
source /usr/share/beakerlib/beakerlib.sh

#
# A simple wrapper function to skip a test because beakerlib doesn't support
# such an important feature, right here we just leverage 'rhts'. Note we
# don't call function report_result() as it directly invoke command
# rhts-report-result actually
#
function rlSkip
{
rlLog "Skipping test because $*"
rhts-report-result "$TEST" SKIP "$OUTPUTFILE"

#
# As we want result="Skip" status="Completed" for all scenarios, right here
# we always exit 0, otherwise the test will skip/abort
#
exit 0
}

#
# A simple wrapper function to skip a test
#
function rlAbort
{
rlLog "Aborting test because $*"
rhts-report-result "$TEST" ABORTED "$OUTPUTFILE"
rhts-abort -t recipe
exit 1
}

function tc_hook_init
{
g_startup_hook=${1?"*** startup hook, e.g. startup"}
g_cleanup_hook=${2?"*** cleanup hook, e.g. cleanup"}
g_runtest_hook=${3?"*** runtest hook, e.g. runtest"}
}

function tc_hook_fini
{
unset g_startup_hook
unset g_cleanup_hook
unset g_runtest_hook
}

function _startup
{
rlPhaseStartSetup
[[ -n $g_startup_hook ]] && eval $g_startup_hook
rlPhaseEnd
}

function _cleanup
{
rlPhaseStartCleanup
[[ -n $g_cleanup_hook ]] && eval $g_cleanup_hook
rlPhaseEnd
}

function _runtest
{
rlPhaseStartTest
[[ -n $g_runtest_hook ]] && eval $g_runtest_hook
rlPhaseEnd
}

function tc_main
{
rlJournalStart
_startup
_runtest
_cleanup
rlJournalEnd
}
29 changes: 29 additions & 0 deletions storage/include/libdebug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
#
# Copyright (c) 2019 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#

function _initPS4
{
export PS4='__DEBUG__: [${FUNCNAME}@${BASH_SOURCE}:${LINENO}|${SECONDS}]+ '
}

function DEBUG
{
typeset -l s=$DEBUG
[[ $s == "yes" || $s == "true" ]] && _initPS4 && set -x
}
68 changes: 68 additions & 0 deletions storage/include/libstqe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
#
# Copyright (c) 2019 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#

source /usr/share/beakerlib/beakerlib.sh
source $(dirname $(readlink -f $BASH_SOURCE))/libbkrm.sh

STQE_GIT="https://gitlab.com/rh-kernel-stqe/python-stqe.git"
STQE_STABLE_VERSION=${STQE_STABLE_VERSION:-"ad38f15"}
LIBSAN_STABLE_VERSION=${LIBSAN_STABLE_VERSION:-"0.3.0"}

function stqe_get_fwroot
{
typeset fwroot="/var/tmp/$(basename $STQE_GIT | sed 's/.git//')"
echo $fwroot
}

function stqe_init_fwroot
{
typeset fwbranch=$1

# clone the framework
typeset fwroot=$(stqe_get_fwroot)
rlRun "rm -rf $fwroot"
rlRun "git clone $STQE_GIT $fwroot" || rlAbort "fail to clone $STQE_GIT"

# install the framework
pushd "." && rlRun "cd $fwroot"

if [[ $fwbranch != "master" ]]; then
if [[ -n $STQE_STABLE_VERSION ]]; then
rlRun "git checkout $STQE_STABLE_VERSION" || \
rlAbort "fail to checkout $STQE_STABLE_VERSION"
fi
if [[ -n $LIBSAN_STABLE_VERSION ]]; then
rlRun "pip3 install libsan==$LIBSAN_STABLE_VERSION" || \
rlAbort "fail to install libsan==$LIBSAN_STABLE_VERSION"
fi
fi

rlRun "python3 setup.py install --prefix=" || \
rlAbort "fail to install test framework"

popd

return 0
}

function stqe_fini_fwroot
{
typeset fwroot=$(stqe_get_fwroot)
rlRun "rm -rf $fwroot"
}
64 changes: 64 additions & 0 deletions storage/iscsi/params/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# Copyright (c) 2019 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#

export TEST=/kernel/storage/iscsi/params
export TESTVERSION=1.0

BUILT_FILES= runtest

FILES=$(METADATA) runtest.sh Makefile README.md

.PHONY: all install download clean

run: $(FILES) build
./runtest

runtest: runtest.sh
cp $< $@ && chmod +x $@

build: $(BUILT_FILES)

clean:

clobber: clean
rm -f *~ $(BUILT_FILES)
cl: clobber

include /usr/share/rhts/lib/rhts-make.include

$(METADATA): Makefile
@echo "Owner: Filip Suba <[email protected]>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: iSCSI parameters testing" >> $(METADATA)
@echo "Type: Functional" >> $(METADATA)
@echo "TestTime: 30m" >> $(METADATA)
@echo "RunFor: kernel" >> $(METADATA)
@echo "Requires: git" >> $(METADATA)
@echo "Requires: augeas" >> $(METADATA)
@echo "Requires: python3" >> $(METADATA)
@echo "Requires: python2-lxml" >> $(METADATA)
@echo "Requires: python3-lxml" >> $(METADATA)
@echo "RepoRequires: storage/include" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)

rhts-lint $(METADATA)
28 changes: 28 additions & 0 deletions storage/iscsi/params/PURPOSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PURPOSE of /kernel/storage/iscsi/params

DESCRIPTION: This test randomly generates values for following iSCSI parameters
[
'HeaderDigest',
'MaxRecvDataSegmentLength',
'MaxXmitDataSegmentLength',
'FirstBurstLength',
'MaxBurstLength',
'ImmediateData',
'InitialR2T'
]
And
o applies generated values to both initiator and local LIO target
o establishes iSCSI session
o prints negotiated values
o do IO with data verification using fio

If you'd like to check values manually, please try:
# iscsiadm -m session -P2 | grep HeaderDigest | cut -d " " -f 2
# cat /sys/class/iscsi_connection/connection*/header_digest
# cat /sys/class/iscsi_session/session*/first_burst_len

NOTES:
This test is using python-libsan and python-stqe. python-libsan is listed
in python-stqe dependencies in setup.py, so we need to clone just
python-stqe from gitlab and install it. Package 'Augeas' is required by
python-stqe.
15 changes: 15 additions & 0 deletions storage/iscsi/params/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# storage/iscsi/params suite
storage/iscsi/params provides parameters testing for iSCSI. The source code
can be found at https://gitlab.com/rh-kernel-stqe/python-stqe.
Test Maintainer: [Filip Suba](mailto:[email protected])

## How to run it

### Dependencies
Please refer to the top-leve README.md for common dependencies. Test-specific
dependencies will automatically be installed when executing 'make run'.

### Execute the test
```bash
$ make run
```
49 changes: 49 additions & 0 deletions storage/iscsi/params/runtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
#
# Copyright (c) 2019 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#

FILE=$(readlink -f ${BASH_SOURCE})
NAME=$(basename $FILE)
CDIR=$(dirname $FILE)

source ${CDIR%/storage/iscsi/*}/storage/include/libdebug.sh
source ${CDIR%/storage/iscsi/*}/storage/include/libbkrm.sh
source ${CDIR%/storage/iscsi/*}/storage/include/libstqe.sh

function startup
{
stqe_init_fwroot "master"
}

function cleanup
{
stqe_fini_fwroot
}

function runtest
{
typeset fwroot=$(stqe_get_fwroot)
pushd "." && rlRun "cd $fwroot"
rlRun "stqe-test run -t iscsi/iscsi_params.py"
popd
}

DEBUG
tc_hook_init startup cleanup runtest
tc_main
tc_hook_fini

0 comments on commit 5984559

Please sign in to comment.