From 5984559143b8ded083d1057b424001a95622356f Mon Sep 17 00:00:00 2001 From: Vector Li Date: Thu, 13 Jun 2019 14:50:57 +0800 Subject: [PATCH] Add iscsi/params test case (#827) Signed-off-by: Vector Li --- storage/include/libbkrm.sh | 94 +++++++++++++++++++++++++++++++++ storage/include/libdebug.sh | 29 ++++++++++ storage/include/libstqe.sh | 68 ++++++++++++++++++++++++ storage/iscsi/params/Makefile | 64 ++++++++++++++++++++++ storage/iscsi/params/PURPOSE | 28 ++++++++++ storage/iscsi/params/README.md | 15 ++++++ storage/iscsi/params/runtest.sh | 49 +++++++++++++++++ 7 files changed, 347 insertions(+) create mode 100644 storage/include/libbkrm.sh create mode 100644 storage/include/libdebug.sh create mode 100644 storage/include/libstqe.sh create mode 100644 storage/iscsi/params/Makefile create mode 100644 storage/iscsi/params/PURPOSE create mode 100644 storage/iscsi/params/README.md create mode 100644 storage/iscsi/params/runtest.sh diff --git a/storage/include/libbkrm.sh b/storage/include/libbkrm.sh new file mode 100644 index 00000000..4769636c --- /dev/null +++ b/storage/include/libbkrm.sh @@ -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 +} diff --git a/storage/include/libdebug.sh b/storage/include/libdebug.sh new file mode 100644 index 00000000..75aa777f --- /dev/null +++ b/storage/include/libdebug.sh @@ -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 +} diff --git a/storage/include/libstqe.sh b/storage/include/libstqe.sh new file mode 100644 index 00000000..9dbbef70 --- /dev/null +++ b/storage/include/libstqe.sh @@ -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" +} diff --git a/storage/iscsi/params/Makefile b/storage/iscsi/params/Makefile new file mode 100644 index 00000000..3fa683b7 --- /dev/null +++ b/storage/iscsi/params/Makefile @@ -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 " > $(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) diff --git a/storage/iscsi/params/PURPOSE b/storage/iscsi/params/PURPOSE new file mode 100644 index 00000000..b3a11ec8 --- /dev/null +++ b/storage/iscsi/params/PURPOSE @@ -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. diff --git a/storage/iscsi/params/README.md b/storage/iscsi/params/README.md new file mode 100644 index 00000000..0edbd239 --- /dev/null +++ b/storage/iscsi/params/README.md @@ -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:fsuba@redhat.com) + +## 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 +``` diff --git a/storage/iscsi/params/runtest.sh b/storage/iscsi/params/runtest.sh new file mode 100644 index 00000000..0d178a31 --- /dev/null +++ b/storage/iscsi/params/runtest.sh @@ -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