From 0487d3a4ee323051bdda074d6e06de0c05a448be Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Mon, 7 Jan 2019 21:17:47 +0000 Subject: [PATCH] OCF: tests: add construct-delete tests Add tests for creation and deletion of OCF bdev We explicitly check 'claimed' property of base devices Other issues like segfaults or custom SPDK errors also can be revealed by these tests Change-Id: Ia1d79df8db2e734e8d868a733655f69a0348de8e Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.gerrithub.io/c/439536 Tested-by: SPDK CI Jenkins Reviewed-by: Maciej Szwed Reviewed-by: Darek Stojaczyk Reviewed-by: Changpeng Liu Reviewed-by: Tomasz Zawadzki --- test/ocf/management/create-destruct.sh | 59 ++++++++++++++++++++++++++ test/ocf/ocf.sh | 1 + 2 files changed, 60 insertions(+) create mode 100755 test/ocf/management/create-destruct.sh diff --git a/test/ocf/management/create-destruct.sh b/test/ocf/management/create-destruct.sh new file mode 100755 index 000000000..199c252e7 --- /dev/null +++ b/test/ocf/management/create-destruct.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "$BASH_SOURCE")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/common/autotest_common.sh + +rpc_py=$rootdir/scripts/rpc.py + +function bdev_check_claimed() +{ + if $($rpc_py get_bdevs -b "$@" | jq '.[0].claimed'); then + return 0; + else + return 1; + fi +} + +$rootdir/app/iscsi_tgt/iscsi_tgt & +spdk_pid=$! + +trap "killprocess $spdk_pid; exit 1" SIGINT SIGTERM EXIT + +waitforlisten $spdk_pid + +$rpc_py construct_malloc_bdev 101 512 -b Malloc0 +$rpc_py construct_malloc_bdev 101 512 -b Malloc1 + +$rpc_py construct_ocf_bdev PartCache wt Malloc0 NonExisting + +if ! bdev_check_claimed Malloc0; then + >&2 echo "Base device expected to be claimed now" + exit 1 +fi + +$rpc_py delete_ocf_bdev PartCache +if bdev_check_claimed Malloc0; then + >&2 echo "Base device is not expected to be claimed now" + exit 1 +fi + +$rpc_py construct_ocf_bdev FullCache wt Malloc0 Malloc1 + +if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then + >&2 echo "Base devices expected to be claimed now" + exit 1 +fi + +$rpc_py delete_ocf_bdev FullCache +if bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1; then + >&2 echo "Base devices are not expected to be claimed now" + exit 1 +fi + +# check if shutdown of running CAS bdev is ok +$rpc_py construct_ocf_bdev PartCache wt NonExisting Malloc1 + +trap - SIGINT SIGTERM EXIT + +killprocess $spdk_pid diff --git a/test/ocf/ocf.sh b/test/ocf/ocf.sh index 374038349..9328d19ef 100755 --- a/test/ocf/ocf.sh +++ b/test/ocf/ocf.sh @@ -16,5 +16,6 @@ timing_enter ocf suite "$testdir/integrity/fio-mallocs.sh" suite "$testdir/integrity/bdevperf-iotypes.sh" +suite "$testdir/management/create-destruct.sh" timing_exit ocf