3 curdir
=$
(dirname $
(readlink
-f "$BASH_SOURCE"))
4 rootdir
=$
(readlink
-f $curdir/..
/..
/..
)
5 source $rootdir/test
/common
/autotest_common.sh
7 rpc_py
=$rootdir/scripts
/rpc.py
9 function bdev_check_claimed
()
11 if $
($rpc_py get_bdevs
-b "$@" | jq
'.[0].claimed'); then
18 $rootdir/app
/iscsi_tgt
/iscsi_tgt
&
21 trap "killprocess $spdk_pid; exit 1" SIGINT SIGTERM EXIT
23 waitforlisten
$spdk_pid
25 $rpc_py construct_malloc_bdev
101 512 -b Malloc0
26 $rpc_py construct_malloc_bdev
101 512 -b Malloc1
28 $rpc_py construct_ocf_bdev PartCache wt Malloc0 NonExisting
30 $rpc_py get_ocf_bdevs PartCache | jq
-e \
31 '.[0] | .started == false and .cache.attached and .core.attached == false'
33 $rpc_py get_ocf_bdevs NonExisting | jq
-e \
34 '.[0] | .name == "PartCache"'
36 if ! bdev_check_claimed Malloc0
; then
37 >&2 echo "Base device expected to be claimed now"
41 $rpc_py delete_ocf_bdev PartCache
42 if bdev_check_claimed Malloc0
; then
43 >&2 echo "Base device is not expected to be claimed now"
47 $rpc_py construct_ocf_bdev FullCache wt Malloc0 Malloc1
49 $rpc_py get_ocf_bdevs FullCache | jq
-e \
50 '.[0] | .started and .cache.attached and .core.attached'
52 if ! (bdev_check_claimed Malloc0
&& bdev_check_claimed Malloc1
); then
53 >&2 echo "Base devices expected to be claimed now"
57 $rpc_py delete_ocf_bdev FullCache
58 if bdev_check_claimed Malloc0
&& bdev_check_claimed Malloc1
; then
59 >&2 echo "Base devices are not expected to be claimed now"
63 $rpc_py construct_ocf_bdev HotCache wt Malloc0 Malloc1
65 if ! (bdev_check_claimed Malloc0
&& bdev_check_claimed Malloc1
); then
66 >&2 echo "Base devices expected to be claimed now"
70 $rpc_py delete_malloc_bdev Malloc0
72 if bdev_check_claimed Malloc1
; then
73 >&2 echo "Base device is not expected to be claimed now"
77 status
=$
($rpc_py get_bdevs
)
78 gone
=$
(echo $status | jq
'map(select(.name == "HotCache")) == []')
79 if [[ $gone == false
]]; then
80 >&2 echo "OCF bdev is expected to unregister"
84 # check if shutdown of running CAS bdev is ok
85 $rpc_py construct_ocf_bdev PartCache wt NonExisting Malloc1
87 trap - SIGINT SIGTERM EXIT