]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/ocf/management/create-destruct.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / test / ocf / management / create-destruct.sh
1 #!/usr/bin/env bash
2
3 curdir=$(dirname $(readlink -f "$BASH_SOURCE"))
4 rootdir=$(readlink -f $curdir/../../..)
5 source $rootdir/test/common/autotest_common.sh
6
7 rpc_py=$rootdir/scripts/rpc.py
8
9 function bdev_check_claimed()
10 {
11 if $($rpc_py get_bdevs -b "$@" | jq '.[0].claimed'); then
12 return 0;
13 else
14 return 1;
15 fi
16 }
17
18 $rootdir/app/iscsi_tgt/iscsi_tgt &
19 spdk_pid=$!
20
21 trap "killprocess $spdk_pid; exit 1" SIGINT SIGTERM EXIT
22
23 waitforlisten $spdk_pid
24
25 $rpc_py construct_malloc_bdev 101 512 -b Malloc0
26 $rpc_py construct_malloc_bdev 101 512 -b Malloc1
27
28 $rpc_py construct_ocf_bdev PartCache wt Malloc0 NonExisting
29
30 $rpc_py get_ocf_bdevs PartCache | jq -e \
31 '.[0] | .started == false and .cache.attached and .core.attached == false'
32
33 $rpc_py get_ocf_bdevs NonExisting | jq -e \
34 '.[0] | .name == "PartCache"'
35
36 if ! bdev_check_claimed Malloc0; then
37 >&2 echo "Base device expected to be claimed now"
38 exit 1
39 fi
40
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"
44 exit 1
45 fi
46
47 $rpc_py construct_ocf_bdev FullCache wt Malloc0 Malloc1
48
49 $rpc_py get_ocf_bdevs FullCache | jq -e \
50 '.[0] | .started and .cache.attached and .core.attached'
51
52 if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then
53 >&2 echo "Base devices expected to be claimed now"
54 exit 1
55 fi
56
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"
60 exit 1
61 fi
62
63 $rpc_py construct_ocf_bdev HotCache wt Malloc0 Malloc1
64
65 if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then
66 >&2 echo "Base devices expected to be claimed now"
67 exit 1
68 fi
69
70 $rpc_py delete_malloc_bdev Malloc0
71
72 if bdev_check_claimed Malloc1; then
73 >&2 echo "Base device is not expected to be claimed now"
74 exit 1
75 fi
76
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"
81 exit 1
82 fi
83
84 # check if shutdown of running CAS bdev is ok
85 $rpc_py construct_ocf_bdev PartCache wt NonExisting Malloc1
86
87 trap - SIGINT SIGTERM EXIT
88
89 killprocess $spdk_pid