Spdk/test/ocf/management/remove.sh
Tomasz Zawadzki 1c9125e78e test: add bdev_wait_for_examine to static JSON configs
Runtime RPCs such as bdev creation has no chance to wait for
bdev examination to finish. To handle this case commit below
introduced bdev_wait_for_examine RPC, and built it into all newly
saved JSON configurations:
(e57bb1af)lib/bdev: build bdev_wait_for_examine into subsystem

Some tests generate the configuration by hand, rather than
saving it from an existing application.
This patch embeds this RPC into the test configs.

Fixes #1760

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I79f998d722a2d19aa98b78333c64dbd2c1151444
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7861
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
2021-05-13 10:07:07 +00:00

85 lines
1.8 KiB
Bash
Executable File

#!/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"
}
},
{
"method": "bdev_wait_for_examine"
}
]
}
]
}
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