test/vhost/initiator: inline create_bdev_config()

This function is not really reusable. Inline it to have
a simple, top-to-bottom test flow.

This already shows the test is unnecessarily complicated.
If anything with lib/virtio goes wrong this file is the last
script that will be used for debugging. It would be OK if
there simpler tests for lib/virtio, but there are not.

While here, also add comments for the three major steps
in this test script because it finally looks sane.

Change-Id: Ic8ae611d853d4a685d38aa3112d16e396b0e110d
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1552
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Darek Stojaczyk 2020-03-27 17:05:32 +01:00 committed by Tomasz Zawadzki
parent ce85fac4c3
commit 2fc1a2d056

View File

@ -9,7 +9,20 @@ function run_spdk_fio() {
--verify_state_save=0
}
function create_bdev_config() {
function err_cleanup() {
rm -f $testdir/bdev.json
killprocess $vhost_pid
if [[ -n "$dummy_spdk_pid" ]] && kill -0 $dummy_spdk_pid &> /dev/null; then
killprocess $dummy_spdk_pid
fi
}
# start vhost and configure it
trap 'err_cleanup; exit 1' SIGINT SIGTERM EXIT
$rootdir/app/vhost/vhost &
vhost_pid=$!
waitforlisten $vhost_pid
$rootdir/scripts/gen_nvme.sh --json | $rootdir/scripts/rpc.py load_subsystem_config
if [ -z "$(rpc_cmd bdev_get_bdevs | jq '.[] | select(.name=="Nvme0n1")')" ]; then
echo "Nvme0n1 bdev not found!" && false
@ -33,26 +46,8 @@ function create_bdev_config() {
rpc_cmd bdev_malloc_create 128 4096 --name Malloc1
rpc_cmd vhost_create_scsi_controller naa.Malloc1.0
rpc_cmd vhost_scsi_controller_add_target naa.Malloc1.0 0 Malloc1
}
function err_cleanup() {
rm -f $testdir/bdev.json
killprocess $vhost_pid
if [[ -n "$dummy_spdk_pid" ]] && kill -0 $dummy_spdk_pid &> /dev/null; then
killprocess $dummy_spdk_pid
fi
}
trap 'err_cleanup; exit 1' SIGINT SIGTERM EXIT
$rootdir/app/vhost/vhost &
vhost_pid=$!
waitforlisten $vhost_pid
timing_enter create_bdev_config
create_bdev_config
timing_exit create_bdev_config
# start a dummy app and generate a json config for FIO
# start a dummy app, create vhost bdevs in it, then dump the config for FIO
$rootdir/app/spdk_tgt/spdk_tgt -r /tmp/spdk2.sock -g &
dummy_spdk_pid=$!
waitforlisten $dummy_spdk_pid /tmp/spdk2.sock
@ -70,6 +65,7 @@ cat <<- CONF > $testdir/bdev.json
CONF
killprocess $dummy_spdk_pid
# run FIO with previously acquired spdk config files
timing_enter run_spdk_fio
run_spdk_fio $testdir/bdev.fio --filename=* --section=job_randwrite --section=job_randrw \
--section=job_write --section=job_rw --spdk_json_conf=$testdir/bdev.json