diff options
Diffstat (limited to 'src/spdk/test/ocf/management')
-rwxr-xr-x | src/spdk/test/ocf/management/create-destruct.sh | 88 | ||||
-rwxr-xr-x | src/spdk/test/ocf/management/multicore.sh | 82 | ||||
-rwxr-xr-x | src/spdk/test/ocf/management/persistent-metadata.sh | 88 | ||||
-rwxr-xr-x | src/spdk/test/ocf/management/remove.sh | 81 |
4 files changed, 339 insertions, 0 deletions
diff --git a/src/spdk/test/ocf/management/create-destruct.sh b/src/spdk/test/ocf/management/create-destruct.sh new file mode 100755 index 000000000..162f7a679 --- /dev/null +++ b/src/spdk/test/ocf/management/create-destruct.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +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')" = "true" ]; then + return 0 + else + return 1 + fi +} + +$SPDK_BIN_DIR/iscsi_tgt & +spdk_pid=$! + +trap 'killprocess $spdk_pid; exit 1' SIGINT SIGTERM EXIT + +waitforlisten $spdk_pid + +$rpc_py bdev_malloc_create 101 512 -b Malloc0 +$rpc_py bdev_malloc_create 101 512 -b Malloc1 + +$rpc_py bdev_ocf_create PartCache wt Malloc0 NonExisting + +$rpc_py bdev_ocf_get_bdevs PartCache | jq -e \ + '.[0] | .started == false and .cache.attached and .core.attached == false' + +$rpc_py bdev_ocf_get_bdevs NonExisting | jq -e \ + '.[0] | .name == "PartCache"' + +if ! bdev_check_claimed Malloc0; then + echo >&2 "Base device expected to be claimed now" + exit 1 +fi + +$rpc_py bdev_ocf_delete PartCache +if bdev_check_claimed Malloc0; then + echo >&2 "Base device is not expected to be claimed now" + exit 1 +fi + +$rpc_py bdev_ocf_create FullCache wt Malloc0 Malloc1 + +$rpc_py bdev_ocf_get_bdevs FullCache | jq -e \ + '.[0] | .started and .cache.attached and .core.attached' + +if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then + echo >&2 "Base devices expected to be claimed now" + exit 1 +fi + +$rpc_py bdev_ocf_delete FullCache +if bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1; then + echo >&2 "Base devices are not expected to be claimed now" + exit 1 +fi + +$rpc_py bdev_ocf_create HotCache wt Malloc0 Malloc1 + +if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then + echo >&2 "Base devices expected to be claimed now" + exit 1 +fi + +$rpc_py bdev_malloc_delete Malloc0 + +if bdev_check_claimed Malloc1; then + echo >&2 "Base device is not expected to be claimed now" + exit 1 +fi + +status=$($rpc_py get_bdevs) +gone=$(echo $status | jq 'map(select(.name == "HotCache")) == []') +if [[ $gone == false ]]; then + echo >&2 "OCF bdev is expected to unregister" + exit 1 +fi + +# check if shutdown of running CAS bdev is ok +$rpc_py bdev_ocf_create PartCache wt NonExisting Malloc1 + +trap - SIGINT SIGTERM EXIT + +killprocess $spdk_pid diff --git a/src/spdk/test/ocf/management/multicore.sh b/src/spdk/test/ocf/management/multicore.sh new file mode 100755 index 000000000..8c4f89e1b --- /dev/null +++ b/src/spdk/test/ocf/management/multicore.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/common/autotest_common.sh + +rpc_py=$rootdir/scripts/rpc.py + +spdk_pid='?' +function start_spdk() { + $SPDK_BIN_DIR/iscsi_tgt & + spdk_pid=$! + trap 'killprocess $spdk_pid; exit 1' SIGINT SIGTERM EXIT + waitforlisten $spdk_pid +} +function stop_spdk() { + killprocess $spdk_pid + trap - SIGINT SIGTERM EXIT +} + +start_spdk + +# Hotplug case + +$rpc_py bdev_malloc_create 1 512 -b Core0 +$rpc_py bdev_malloc_create 1 512 -b Core1 + +$rpc_py bdev_ocf_create C1 wt Cache Core0 +$rpc_py bdev_ocf_create C2 wt Cache Core1 + +$rpc_py bdev_ocf_get_bdevs | jq -e \ + 'any(select(.started)) == false' + +$rpc_py bdev_malloc_create 101 512 -b Cache + +$rpc_py bdev_ocf_get_bdevs | jq -e \ + 'all(select(.started)) == true' + +#Be sure that we will not fail delete because examine is still in progress +waitforbdev C2 + +# Detaching cores + +$rpc_py bdev_ocf_delete C2 + +$rpc_py bdev_ocf_get_bdevs C1 | jq -e \ + '.[0] | .started' + +$rpc_py bdev_ocf_create C2 wt Cache Core1 + +$rpc_py bdev_ocf_get_bdevs C2 | jq -e \ + '.[0] | .started' + +# Normal shutdown + +stop_spdk + +# Hotremove case +start_spdk + +$rpc_py bdev_malloc_create 101 512 -b Cache +$rpc_py bdev_malloc_create 101 512 -b Malloc +$rpc_py bdev_malloc_create 1 512 -b Core + +$rpc_py bdev_ocf_create C1 wt Cache Malloc +$rpc_py bdev_ocf_create C2 wt Cache Core + +$rpc_py bdev_ocf_get_bdevs Cache | jq \ + 'length == 2' + +$rpc_py bdev_malloc_delete Cache + +$rpc_py bdev_ocf_get_bdevs | jq -e \ + '. == []' + +# Not fully initialized shutdown + +$rpc_py bdev_ocf_create C1 wt Malloc NonExisting +$rpc_py bdev_ocf_create C2 wt Malloc NonExisting +$rpc_py bdev_ocf_create C3 wt Malloc Core + +stop_spdk diff --git a/src/spdk/test/ocf/management/persistent-metadata.sh b/src/spdk/test/ocf/management/persistent-metadata.sh new file mode 100755 index 000000000..cbfcab341 --- /dev/null +++ b/src/spdk/test/ocf/management/persistent-metadata.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/ocf/common.sh + +source $rootdir/scripts/common.sh +source $rootdir/test/common/autotest_common.sh + +rpc_py=$rootdir/scripts/rpc.py + +$rootdir/scripts/setup.sh + +mapfile -t config < <("$rootdir/scripts/gen_nvme.sh" --json) +# Drop anything from last closing ] so we can inject our own config pieces ... +config=("${config[@]::${#config[@]}-2}") +# ... and now convert entire array to a single string item +config=("${config[*]}") + +config+=( + "$( + cat <<- JSON + { + "method": "bdev_split_create", + "params": { + "base_bdev": "Nvme0n1", + "split_count": 7, + "split_size_mb": 128 + } + } + JSON + )" +) + +# First ']}' closes our config and bdev subsystem blocks +jq . <<- CONFIG > "$curdir/config" + {"subsystems":[ + $( + IFS="," + printf '%s\n' "${config[*]}" + ) + ]}]} +CONFIG + +# Clear nvme device which we will use in test +clear_nvme + +"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" & +spdk_pid=$! + +waitforlisten $spdk_pid + +# Create ocf on persistent storage + +$rpc_py bdev_ocf_create ocfWT wt Nvme0n1p0 Nvme0n1p1 +$rpc_py bdev_ocf_create ocfPT pt Nvme0n1p2 Nvme0n1p3 +$rpc_py bdev_ocf_create ocfWB0 wb Nvme0n1p4 Nvme0n1p5 +$rpc_py bdev_ocf_create ocfWB1 wb Nvme0n1p4 Nvme0n1p6 + +# Sorting bdevs because we dont guarantee that they are going to be +# in the same order after shutdown +($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs + +trap - SIGINT SIGTERM EXIT + +killprocess $spdk_pid + +# Check for ocf persistency after restart +"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" & +spdk_pid=$! + +trap 'killprocess $spdk_pid; rm -f $curdir/config ocf_bdevs ocf_bdevs_verify; exit 1' SIGINT SIGTERM EXIT + +waitforlisten $spdk_pid +sleep 5 + +# OCF should be loaded now as well + +($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs_verify + +diff ocf_bdevs ocf_bdevs_verify + +trap - SIGINT SIGTERM EXIT + +killprocess $spdk_pid +rm -f $curdir/config ocf_bdevs ocf_bdevs_verify + +clear_nvme $bdf diff --git a/src/spdk/test/ocf/management/remove.sh b/src/spdk/test/ocf/management/remove.sh new file mode 100755 index 000000000..1302f16cd --- /dev/null +++ b/src/spdk/test/ocf/management/remove.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/common/autotest_common.sh + +rpc_py=$rootdir/scripts/rpc.py + +rm -f aio* +truncate -s 128M aio0 +truncate -s 128M aio1 + +jq . <<- JSON > "$curdir/config" + { + "subsystems": [ + { + "subsystem": "bdev", + "config": [ + { + "method": "bdev_aio_create", + "params": { + "name": "ai0", + "block_size": 512, + "filename": "./aio0" + } + }, + { + "method": "bdev_aio_create", + "params": { + "name": "aio1", + "block_size": 512, + "filename": "./aio1" + } + } + ] + } + ] + } +JSON + +"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" & +spdk_pid=$! + +waitforlisten $spdk_pid + +# Create ocf on persistent storage + +$rpc_py bdev_ocf_create ocfWT wt aio0 aio1 + +# Check that ocfWT was created properly + +$rpc_py bdev_ocf_get_bdevs | jq -r '.[] .name' | grep -qw ocfWT + +# Remove ocfWT, after delete via rpc ocf bdev should not load on next app start + +$rpc_py bdev_ocf_delete ocfWT + +# Check that ocfWT was deleted properly + +! $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .name' | grep -qw ocfWT + +trap - SIGINT SIGTERM EXIT + +killprocess $spdk_pid + +# Check for ocfWT was deleted permanently +"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" & +spdk_pid=$! + +trap 'killprocess $spdk_pid; rm -f aio* $curdir/config ocf_bdevs ocf_bdevs_verify; exit 1' SIGINT SIGTERM EXIT + +waitforlisten $spdk_pid + +# Check that ocfWT was not loaded on app start + +! $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .name' | grep -qw ocfWT + +trap - SIGINT SIGTERM EXIT + +killprocess $spdk_pid +rm -f aio* $curdir/config ocf_bdevs ocf_bdevs_verify |