lib/ftl: Functional tests

This patch adjust functional tests to
new FTL stack.

Change-Id: I0b8ff08c61793d7f1685942031aecf9cc88d1f24
Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468738
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Wojciech Malikowski 2019-10-25 03:31:14 -04:00 committed by Tomasz Zawadzki
parent 151e37cfaa
commit f2c8083ef3
10 changed files with 87 additions and 71 deletions

View File

@ -263,9 +263,9 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then
run_test "ocf" ./test/ocf/ocf.sh run_test "ocf" ./test/ocf/ocf.sh
fi fi
# if [ $SPDK_TEST_FTL -eq 1 ]; then if [ $SPDK_TEST_FTL -eq 1 ]; then
# run_test "ftl" ./test/ftl/ftl.sh run_test "ftl" ./test/ftl/ftl.sh
# fi fi
if [ $SPDK_TEST_VMD -eq 1 ]; then if [ $SPDK_TEST_VMD -eq 1 ]; then
run_test "vmd" ./test/vmd/vmd.sh run_test "vmd" ./test/vmd/vmd.sh

View File

@ -5,21 +5,15 @@ set -e
rootdir=$(readlink -f $(dirname $0))/.. rootdir=$(readlink -f $(dirname $0))/..
function usage { function usage {
echo "Usage: [-j] $0 -a TRANSPORT_ADDR -n BDEV_NAME [-u UUID] [-c CACHE]" echo "Usage: [-j] $0 -n BDEV_NAME -d BASE_BDEV [-u UUID] [-c CACHE]"
echo "UUID is required when restoring device state" echo "UUID is required when restoring device state"
echo echo
echo "-j json format"
echo "TRANSPORT_ADDR - SSD's PCIe address"
echo "BDEV_NAME - name of the bdev" echo "BDEV_NAME - name of the bdev"
echo "BASE_BDEV - name of the bdev to be used as underlying device"
echo "UUID - bdev's uuid (used when in restore mode)" echo "UUID - bdev's uuid (used when in restore mode)"
echo "CACHE - name of the bdev to be used as write buffer cache" echo "CACHE - name of the bdev to be used as write buffer cache"
} }
function create_classic_config {
echo "[Ftl]"
echo " TransportID \"trtype:PCIe traddr:$1\" $2 $3 $4"
}
function create_json_config() function create_json_config()
{ {
echo "{" echo "{"
@ -28,9 +22,8 @@ function create_json_config()
echo '{' echo '{'
echo '"method": "bdev_ftl_create",' echo '"method": "bdev_ftl_create",'
echo '"params": {' echo '"params": {'
echo "\"name\": \"$2\"," echo "\"name\": \"$1\","
echo '"trtype": "PCIe",' echo "\"base_bdev\": \"$2\","
echo "\"traddr\": \"$1\","
if [ -n "$4" ]; then if [ -n "$4" ]; then
echo "\"uuid\": \"$3\"," echo "\"uuid\": \"$3\","
echo "\"cache\": \"$4\"" echo "\"cache\": \"$4\""
@ -45,27 +38,22 @@ function create_json_config()
uuid=00000000-0000-0000-0000-000000000000 uuid=00000000-0000-0000-0000-000000000000
while getopts "ja:n:l:m:u:c:h" arg; do while getopts ":c:d:hn:u:" arg; do
case "$arg" in case "$arg" in
j) json=1 ;; n) name=$OPTARG ;;
a) addr=$OPTARG ;; d) base_bdev=$OPTARG ;;
n) name=$OPTARG ;; u) uuid=$OPTARG ;;
u) uuid=$OPTARG ;; c) cache=$OPTARG ;;
c) cache=$OPTARG ;;
h) usage h) usage
exit 0 ;; exit 0 ;;
*) usage *) usage
exit 1 ;; exit 1 ;;
esac esac
done done
if [[ -z "$addr" || -z "$name" ]]; then if [[ -z "$name" || -z "$base_bdev" ]]; then
usage usage
exit 1 exit 1
fi fi
if [ -n "$json" ]; then create_json_config $name $base_bdev $uuid $cache
create_json_config $addr $name $uuid $cache
else
create_classic_config $addr $name $uuid $cache
fi

View File

@ -1540,21 +1540,17 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
print_dict(rpc.bdev.bdev_ftl_create(args.client, print_dict(rpc.bdev.bdev_ftl_create(args.client,
name=args.name, name=args.name,
trtype=args.trtype, base_bdev=args.base_bdev,
traddr=args.traddr,
uuid=args.uuid, uuid=args.uuid,
cache=args.cache, cache=args.cache,
allow_open_bands=args.allow_open_bands, allow_open_bands=args.allow_open_bands,
overprovisioning=args.overprovisioning, overprovisioning=args.overprovisioning,
**arg_limits)) **arg_limits))
p = subparsers.add_parser('bdev_ftl_create', aliases=['construct_ftl_bdev'], p = subparsers.add_parser('bdev_ftl_create', aliases=['construct_ftl_bdev'], help='Add FTL bdev')
help='Add FTL bdev')
p.add_argument('-b', '--name', help="Name of the bdev", required=True) p.add_argument('-b', '--name', help="Name of the bdev", required=True)
p.add_argument('-t', '--trtype', p.add_argument('-d', '--base_bdev', help='Name of zoned bdev used as underlying device',
help='NVMe target trtype: e.g., pcie', default='pcie') required=True)
p.add_argument('-a', '--traddr',
help='NVMe target address: e.g., an ip address or BDF', required=True)
p.add_argument('-u', '--uuid', help='UUID of restored bdev (not applicable when creating new ' p.add_argument('-u', '--uuid', help='UUID of restored bdev (not applicable when creating new '
'instance): e.g. b286d19a-0059-4709-abcd-9f7732b1567d (optional)') 'instance): e.g. b286d19a-0059-4709-abcd-9f7732b1567d (optional)')
p.add_argument('-c', '--cache', help='Name of the bdev to be used as a write buffer cache (optional)') p.add_argument('-c', '--cache', help='Name of the bdev to be used as a write buffer cache (optional)')

View File

@ -884,18 +884,16 @@ def bdev_split_delete(client, base_bdev):
@deprecated_alias('construct_ftl_bdev') @deprecated_alias('construct_ftl_bdev')
def bdev_ftl_create(client, name, trtype, traddr, **kwargs): def bdev_ftl_create(client, name, base_bdev, **kwargs):
"""Construct FTL bdev """Construct FTL bdev
Args: Args:
name: name of the bdev name: name of the bdev
trtype: transport type base_bdev: name of the base bdev
traddr: transport address
kwargs: optional parameters kwargs: optional parameters
""" """
params = {'name': name, params = {'name': name,
'trtype': trtype, 'base_bdev': base_bdev}
'traddr': traddr}
for key, value in kwargs.items(): for key, value in kwargs.items():
if value is not None: if value is not None:
params[key] = value params[key] = value

View File

@ -3,15 +3,32 @@
testdir=$(readlink -f $(dirname $0)) testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..) rootdir=$(readlink -f $testdir/../..)
source $rootdir/test/common/autotest_common.sh source $rootdir/test/common/autotest_common.sh
source $testdir/common.sh
tests=('-q 1 -w randwrite -t 4 -o 69632' '-q 128 -w randwrite -t 4 -o 4096' '-q 128 -w verify -t 4 -o 4096') tests=('-q 1 -w randwrite -t 4 -o 69632' '-q 128 -w randwrite -t 4 -o 4096' '-q 128 -w verify -t 4 -o 4096')
device=$1 device=$1
ftl_bdev_conf=$testdir/config/ftl.conf rpc_py=$rootdir/scripts/rpc.py
$rootdir/scripts/gen_ftl.sh -a $device -n nvme0 > $ftl_bdev_conf ftl_bdev_conf=$testdir/config/ftl.conf
gen_ftl_nvme_conf > $ftl_bdev_conf
for (( i=0; i<${#tests[@]}; i++ )) do for (( i=0; i<${#tests[@]}; i++ )) do
timing_enter "${tests[$i]}" timing_enter "${tests[$i]}"
$rootdir/test/bdev/bdevperf/bdevperf -c $ftl_bdev_conf ${tests[$i]} $rootdir/test/bdev/bdevperf/bdevperf -z -T ftl0 ${tests[$i]} -c $ftl_bdev_conf &
bdevperf_pid=$!
trap 'killprocess $bdevperf_pid; exit 1' SIGINT SIGTERM EXIT
waitforlisten $bdevperf_pid
$rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie
$rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1
$rpc_py bdev_ftl_create -b ftl0 -d nvme0n1
$rootdir/test/bdev/bdevperf/bdevperf.py perform_tests
$rpc_py delete_ftl_bdev -b ftl0
$rpc_py bdev_ocssd_delete nvme0n1
$rpc_py delete_nvme_controller nvme0
killprocess $bdevperf_pid
trap - SIGINT SIGTERM EXIT
timing_exit "${tests[$i]}" timing_exit "${tests[$i]}"
done done
rm -f $ftl_bdev_conf

View File

@ -46,3 +46,8 @@ function create_nv_cache_bdev() {
nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf) nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf)
$rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1 $rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1
} }
function gen_ftl_nvme_conf() {
echo "[Nvme]"
echo " AdminPollRate 100"
}

View File

@ -17,13 +17,15 @@ done
shift $((OPTIND -1)) shift $((OPTIND -1))
device=$1 device=$1
ftl_bdev_conf=$testdir/config/ftl.conf
gen_ftl_nvme_conf > $ftl_bdev_conf
restore_kill() { restore_kill() {
rm -f $testdir/config/ftl.json rm -f $testdir/config/ftl.json
rm -f $testdir/testfile.md5 rm -f $testdir/testfile.md5
rm -f $testdir/testfile2.md5 rm -f $testdir/testfile2.md5
rm -f $ftl_bdev_conf
$rpc_py bdev_ftl_delete -b nvme0 || true
killprocess $svcpid || true killprocess $svcpid || true
rmmod nbd || true rmmod nbd || true
} }
@ -38,14 +40,16 @@ pu_count=$((num_group * num_pu))
# Write one band worth of data + one extra chunk # Write one band worth of data + one extra chunk
data_size=$((chunk_size * (pu_count + 1))) data_size=$((chunk_size * (pu_count + 1)))
$rootdir/app/spdk_tgt/spdk_tgt & svcpid=$! $rootdir/app/spdk_tgt/spdk_tgt -c $ftl_bdev_conf & svcpid=$!
waitforlisten $svcpid waitforlisten $svcpid
if [ -n "$nv_cache" ]; then if [ -n "$nv_cache" ]; then
nvc_bdev=$(create_nv_cache_bdev nvc0 $device $nv_cache $pu_count) nvc_bdev=$(create_nv_cache_bdev nvc0 $device $nv_cache $pu_count)
fi fi
ftl_construct_args="bdev_ftl_create -b nvme0 -a $device -o" $rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie
$rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1
ftl_construct_args="bdev_ftl_create -b ftl0 -d nvme0n1 -o"
[ -n "$nvc_bdev" ] && ftl_construct_args+=" -c $nvc_bdev" [ -n "$nvc_bdev" ] && ftl_construct_args+=" -c $nvc_bdev"
[ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" [ -n "$uuid" ] && ftl_construct_args+=" -u $uuid"
@ -54,7 +58,7 @@ $rpc_py $ftl_construct_args
# Load the nbd driver # Load the nbd driver
modprobe nbd modprobe nbd
$rpc_py nbd_start_disk nvme0 /dev/nbd0 $rpc_py nbd_start_disk ftl0 /dev/nbd0
waitfornbd nbd0 waitfornbd nbd0
$rpc_py save_config > $testdir/config/ftl.json $rpc_py save_config > $testdir/config/ftl.json
@ -68,7 +72,7 @@ $rpc_py nbd_stop_disk /dev/nbd0
kill -9 $svcpid kill -9 $svcpid
rm -f /dev/shm/spdk_tgt_trace.pid$svcpid rm -f /dev/shm/spdk_tgt_trace.pid$svcpid
$rootdir/app/spdk_tgt/spdk_tgt -L ftl_init & svcpid=$! $rootdir/app/spdk_tgt/spdk_tgt -c $ftl_bdev_conf -L ftl_init & svcpid=$!
waitforlisten $svcpid waitforlisten $svcpid
$rpc_py load_config < $testdir/config/ftl.json $rpc_py load_config < $testdir/config/ftl.json

View File

@ -61,14 +61,19 @@ run_test "ftl_json" $testdir/json.sh $device
if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then
run_test "ftl_fio_basic" $testdir/fio.sh $device basic run_test "ftl_fio_basic" $testdir/fio.sh $device basic
$rootdir/app/spdk_tgt/spdk_tgt & ftl_bdev_conf=$testdir/config/ftl.conf
svc_pid=$! gen_ftl_nvme_conf > $ftl_bdev_conf
$rootdir/app/spdk_tgt/spdk_tgt -c $ftl_bdev_conf & svcpid=$!
trap 'killprocess $svc_pid; exit 1' SIGINT SIGTERM EXIT trap 'killprocess $svcpid; exit 1' SIGINT SIGTERM EXIT
waitforlisten $svc_pid waitforlisten $svcpid
uuid=$($rpc_py bdev_ftl_create -b nvme0 -a $device | jq -r '.uuid')
killprocess $svc_pid $rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie
$rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1
uuid=$($rpc_py bdev_ftl_create -b ftl0 -d nvme0n1 | jq -r '.uuid')
killprocess $svcpid
rm -f $ftl_bdev_conf
trap - SIGINT SIGTERM EXIT trap - SIGINT SIGTERM EXIT

View File

@ -3,20 +3,22 @@
testdir=$(readlink -f $(dirname $0)) testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..) rootdir=$(readlink -f $testdir/../..)
source $rootdir/test/common/autotest_common.sh source $rootdir/test/common/autotest_common.sh
source $testdir/common.sh
rpc_py=$rootdir/scripts/rpc.py rpc_py=$rootdir/scripts/rpc.py
device=$1 device=$1
FTL_BDEV_CONF=$testdir/config/ftl.json ftl_bdev_conf=$testdir/config/ftl.conf
gen_ftl_nvme_conf > $ftl_bdev_conf
json_kill() { json_kill() {
killprocess $svcpid killprocess $svcpid
rm -f $ftl_bdev_conf
} }
trap "json_kill; exit 1" SIGINT SIGTERM EXIT trap "json_kill; exit 1" SIGINT SIGTERM EXIT
$rootdir/app/spdk_tgt/spdk_tgt & svcpid=$! $rootdir/app/spdk_tgt/spdk_tgt -c $ftl_bdev_conf & svcpid=$!
waitforlisten $svcpid waitforlisten $svcpid
# Create new bdev from json configuration # Create new bdev from json configuration
@ -27,16 +29,12 @@ $rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1
waitforbdev ftl0 waitforbdev ftl0
uuid=$($rpc_py bdev_get_bdevs | jq -r ".[] | select(.name==\"ftl0\").uuid") uuid=$($rpc_py bdev_get_bdevs | jq -r ".[] | select(.name==\"ftl0\").uuid")
$rpc_py bdev_ftl_delete -b nvme0 $rpc_py bdev_ftl_delete -b ftl0
# Restore bdev from json configuration # Restore bdev from json configuration
$rootdir/scripts/gen_ftl.sh -j -a $device -n nvme0 -u $uuid | $rpc_py load_subsystem_config $rootdir/scripts/gen_ftl.sh -n ftl0 -d nvme0n1 -u $uuid | $rpc_py load_subsystem_config
$rpc_py bdev_ftl_delete -b nvme0 $rpc_py bdev_ftl_delete -b ftl0
# Create new bdev from RPC $rpc_py bdev_nvme_detach_controller nvme0
$rpc_py bdev_ftl_create -b nvme1 -a $device
$rpc_py bdev_ftl_delete -b nvme1
# TODO: add negative test cases
trap - SIGINT SIGTERM EXIT trap - SIGINT SIGTERM EXIT
json_kill json_kill

View File

@ -22,6 +22,9 @@ num_group=$(get_num_group $device)
num_pu=$(get_num_pu $device) num_pu=$(get_num_pu $device)
pu_count=$((num_group * num_pu)) pu_count=$((num_group * num_pu))
ftl_bdev_conf=$testdir/config/ftl.conf
gen_ftl_nvme_conf > $ftl_bdev_conf
restore_kill() { restore_kill() {
if mount | grep $mount_dir; then if mount | grep $mount_dir; then
umount $mount_dir umount $mount_dir
@ -30,15 +33,15 @@ restore_kill() {
rm -f $testdir/testfile.md5 rm -f $testdir/testfile.md5
rm -f $testdir/testfile2.md5 rm -f $testdir/testfile2.md5
rm -f $testdir/config/ftl.json rm -f $testdir/config/ftl.json
rm -f $ftl_bdev_conf
$rpc_py bdev_ftl_delete -b nvme0
killprocess $svcpid killprocess $svcpid
rmmod nbd || true rmmod nbd || true
} }
trap "restore_kill; exit 1" SIGINT SIGTERM EXIT trap "restore_kill; exit 1" SIGINT SIGTERM EXIT
$rootdir/app/spdk_tgt/spdk_tgt & svcpid=$! $rootdir/app/spdk_tgt/spdk_tgt -c $ftl_bdev_conf & svcpid=$!
# Wait until spdk_tgt starts # Wait until spdk_tgt starts
waitforlisten $svcpid waitforlisten $svcpid
@ -46,7 +49,9 @@ if [ -n "$nv_cache" ]; then
nvc_bdev=$(create_nv_cache_bdev nvc0 $device $nv_cache $pu_count) nvc_bdev=$(create_nv_cache_bdev nvc0 $device $nv_cache $pu_count)
fi fi
ftl_construct_args="bdev_ftl_create -b nvme0 -a $device" $rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie
$rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1
ftl_construct_args="bdev_ftl_create -b ftl0 -d nvme0n1"
[ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" [ -n "$uuid" ] && ftl_construct_args+=" -u $uuid"
[ -n "$nv_cache" ] && ftl_construct_args+=" -c $nvc_bdev" [ -n "$nv_cache" ] && ftl_construct_args+=" -c $nvc_bdev"
@ -55,7 +60,7 @@ $rpc_py $ftl_construct_args
# Load the nbd driver # Load the nbd driver
modprobe nbd modprobe nbd
$rpc_py nbd_start_disk nvme0 /dev/nbd0 $rpc_py nbd_start_disk ftl0 /dev/nbd0
waitfornbd nbd0 waitfornbd nbd0
$rpc_py save_config > $testdir/config/ftl.json $rpc_py save_config > $testdir/config/ftl.json
@ -72,7 +77,7 @@ md5sum $mount_dir/testfile > $testdir/testfile.md5
umount $mount_dir umount $mount_dir
killprocess $svcpid killprocess $svcpid
$rootdir/app/spdk_tgt/spdk_tgt -L ftl_init & svcpid=$! $rootdir/app/spdk_tgt/spdk_tgt -c $ftl_bdev_conf -L ftl_init & svcpid=$!
# Wait until spdk_tgt starts # Wait until spdk_tgt starts
waitforlisten $svcpid waitforlisten $svcpid