2019-05-21 21:21:03 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2019 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2019-11-18 14:55:26 +00:00
|
|
|
curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
|
2019-05-21 21:21:03 +00:00
|
|
|
rootdir=$(readlink -f $curdir/../../..)
|
2020-04-01 15:06:17 +00:00
|
|
|
source $rootdir/test/ocf/common.sh
|
2019-08-22 15:55:46 +00:00
|
|
|
|
2020-03-17 09:59:19 +00:00
|
|
|
source $rootdir/scripts/common.sh
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
|
|
|
|
rpc_py=$rootdir/scripts/rpc.py
|
|
|
|
|
|
|
|
$rootdir/scripts/setup.sh
|
|
|
|
|
2020-10-21 10:59:09 +00:00
|
|
|
mapfile -t config < <("$rootdir/scripts/gen_nvme.sh")
|
2020-03-17 09:59:19 +00:00
|
|
|
# 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
|
|
|
|
)"
|
|
|
|
)
|
|
|
|
|
2021-05-12 11:49:53 +00:00
|
|
|
config+=(
|
|
|
|
"$(
|
|
|
|
cat <<- JSON
|
|
|
|
{
|
|
|
|
"method": "bdev_wait_for_examine"
|
|
|
|
}
|
|
|
|
JSON
|
|
|
|
)"
|
|
|
|
)
|
|
|
|
|
2020-03-17 09:59:19 +00:00
|
|
|
# First ']}' closes our config and bdev subsystem blocks
|
|
|
|
jq . <<- CONFIG > "$curdir/config"
|
|
|
|
{"subsystems":[
|
|
|
|
$(
|
|
|
|
IFS=","
|
|
|
|
printf '%s\n' "${config[*]}"
|
|
|
|
)
|
|
|
|
]}]}
|
|
|
|
CONFIG
|
2019-08-22 15:55:46 +00:00
|
|
|
|
2020-04-01 15:06:17 +00:00
|
|
|
# Clear nvme device which we will use in test
|
|
|
|
clear_nvme
|
2019-05-21 21:21:03 +00:00
|
|
|
|
2020-05-11 21:15:03 +00:00
|
|
|
"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" &
|
2019-05-21 21:21:03 +00:00
|
|
|
spdk_pid=$!
|
|
|
|
|
|
|
|
waitforlisten $spdk_pid
|
|
|
|
|
|
|
|
# Create ocf on persistent storage
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
$rpc_py bdev_ocf_create ocfWT wt Nvme0n1p0 Nvme0n1p1
|
|
|
|
$rpc_py bdev_ocf_create ocfPT pt Nvme0n1p2 Nvme0n1p3
|
2019-08-28 08:30:48 +00:00
|
|
|
$rpc_py bdev_ocf_create ocfWB0 wb Nvme0n1p4 Nvme0n1p5
|
|
|
|
$rpc_py bdev_ocf_create ocfWB1 wb Nvme0n1p4 Nvme0n1p6
|
2019-05-21 21:21:03 +00:00
|
|
|
|
|
|
|
# Sorting bdevs because we dont guarantee that they are going to be
|
|
|
|
# in the same order after shutdown
|
2019-08-28 08:43:22 +00:00
|
|
|
($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs
|
2019-05-21 21:21:03 +00:00
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
killprocess $spdk_pid
|
|
|
|
|
|
|
|
# Check for ocf persistency after restart
|
2020-05-11 21:15:03 +00:00
|
|
|
"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" &
|
2019-05-21 21:21:03 +00:00
|
|
|
spdk_pid=$!
|
|
|
|
|
2019-08-22 15:55:46 +00:00
|
|
|
trap 'killprocess $spdk_pid; rm -f $curdir/config ocf_bdevs ocf_bdevs_verify; exit 1' SIGINT SIGTERM EXIT
|
2019-05-21 21:21:03 +00:00
|
|
|
|
|
|
|
waitforlisten $spdk_pid
|
2020-03-17 09:59:19 +00:00
|
|
|
sleep 5
|
2019-05-21 21:21:03 +00:00
|
|
|
|
|
|
|
# OCF should be loaded now as well
|
|
|
|
|
2019-08-28 08:43:22 +00:00
|
|
|
($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs_verify
|
2019-05-21 21:21:03 +00:00
|
|
|
|
|
|
|
diff ocf_bdevs ocf_bdevs_verify
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
killprocess $spdk_pid
|
2019-08-22 15:55:46 +00:00
|
|
|
rm -f $curdir/config ocf_bdevs ocf_bdevs_verify
|
|
|
|
|
|
|
|
clear_nvme $bdf
|