From 4179bfc84e71eb431a2c655009770b230285932a Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Wed, 31 Jan 2018 15:50:16 +0100 Subject: [PATCH] test/vhost: move migration test case 1 to separate file Change-Id: Iae11ee2e631bc6bc1965c96f81352094a81a29be Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/398750 Reviewed-by: Karol Latecki Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp --- ...migration-malloc.job => migration-tc1.job} | 0 test/vhost/migration/migration-tc1.sh | 121 ++++++++++++++++++ .../{migration-malloc.sh => migration.sh} | 114 +---------------- test/vhost/spdk_vhost.sh | 2 +- 4 files changed, 125 insertions(+), 112 deletions(-) rename test/vhost/migration/{migration-malloc.job => migration-tc1.job} (100%) create mode 100644 test/vhost/migration/migration-tc1.sh rename test/vhost/migration/{migration-malloc.sh => migration.sh} (53%) diff --git a/test/vhost/migration/migration-malloc.job b/test/vhost/migration/migration-tc1.job similarity index 100% rename from test/vhost/migration/migration-malloc.job rename to test/vhost/migration/migration-tc1.job diff --git a/test/vhost/migration/migration-tc1.sh b/test/vhost/migration/migration-tc1.sh new file mode 100644 index 000000000..c69c5b77b --- /dev/null +++ b/test/vhost/migration/migration-tc1.sh @@ -0,0 +1,121 @@ +function migration_tc1_clean_vhost_config() +{ + # Restore trap + trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT + + notice "Removing vhost devices & controllers via RPC ..." + # Delete bdev first to remove all LUNs and SCSI targets + $rpc delete_bdev Malloc0 + + # Delete controllers + $rpc remove_vhost_controller $incoming_vm_ctrlr + $rpc remove_vhost_controller $target_vm_ctrlr + + unset -v incoming_vm target_vm incoming_vm_ctrlr target_vm_ctrlr rpc +} + +function migration_tc1_configure_vhost() +{ + # Those are global intentionaly - they will be unset in cleanup handler + incoming_vm=0 + target_vm=1 + incoming_vm_ctrlr=naa.Malloc0.$incoming_vm + target_vm_ctrlr=naa.Malloc0.$target_vm + rpc="python $SPDK_BUILD_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" + + trap 'migration_tc1_error_handler; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT + + # Construct shared Malloc Bdev + $rpc construct_malloc_bdev -b Malloc0 128 4096 + + # And two controllers - one for each VM. Both are using the same Malloc Bdev as LUN 0 + $rpc construct_vhost_scsi_controller $incoming_vm_ctrlr + $rpc add_vhost_scsi_lun $incoming_vm_ctrlr 0 Malloc0 + + $rpc construct_vhost_scsi_controller $target_vm_ctrlr + $rpc add_vhost_scsi_lun $target_vm_ctrlr 0 Malloc0 +} + +function migration_tc1_error_handler() +{ + trap - SIGINT ERR EXIT + set -x + + vm_kill_all + migration_tc1_clean_vhost_config + + warning "Migration TC1 FAILED" +} + +function migration_tc1() +{ + # Use 2 VMs: + # incoming VM - the one we want to migrate + # targe VM - the one which will accept migration + local job_file="$BASE_DIR/migration-tc1.job" + + # Run vhost + spdk_vhost_run --conf-path=$BASE_DIR + migration_tc1_configure_vhost + + notice "Setting up VMs" + vm_setup --os="$os_image" --force=$incoming_vm --disk-type=spdk_vhost_scsi --disks=Malloc0 --migrate-to=$target_vm + vm_setup --force=$target_vm --disk-type=spdk_vhost_scsi --disks=Malloc0 --incoming=$incoming_vm + + # Run everything + vm_run $incoming_vm $target_vm + + # Wait only for incoming VM, as target is waiting for migration + vm_wait_for_boot 600 $incoming_vm + + # Run fio before migration + notice "Starting FIO" + + vm_check_scsi_location $incoming_vm + run_fio $fio_bin --job-file="$job_file" --local --vm="${incoming_vm}$(printf ':/dev/%s' $SCSI_DISK)" + + # Wait a while to let the FIO time to issue some IO + sleep 5 + + # Check if fio is still running before migration + if ! is_fio_running $incoming_vm; then + vm_ssh $incoming_vm "cat /root/$(basename ${job_file}).out" + error "FIO is not running before migration: process crashed or finished too early" + fi + + vm_migrate $incoming_vm + sleep 3 + + # Check if fio is still running after migration + if ! is_fio_running $target_vm; then + vm_ssh $target_vm "cat /root/$(basename ${job_file}).out" + error "FIO is not running after migration: process crashed or finished too early" + fi + + notice "Waiting for fio to finish" + local timeout=40 + while is_fio_running $target_vm; do + sleep 1 + echo -n "." + if (( timeout-- == 0 )); then + error "timeout while waiting for FIO!" + fi + done + + notice "Fio result is:" + vm_ssh $target_vm "cat /root/$(basename ${job_file}).out" + + notice "Migration DONE" + + notice "Shutting down all VMs" + vm_shutdown_all + + migration_tc1_clean_vhost_config + + notice "killing vhost app" + spdk_vhost_kill + + notice "Migration TC1 SUCCESS" +} + +migration_tc1 diff --git a/test/vhost/migration/migration-malloc.sh b/test/vhost/migration/migration.sh similarity index 53% rename from test/vhost/migration/migration-malloc.sh rename to test/vhost/migration/migration.sh index 29384515d..33af8d56c 100755 --- a/test/vhost/migration/migration-malloc.sh +++ b/test/vhost/migration/migration.sh @@ -20,7 +20,6 @@ function usage() echo " --work-dir=WORK_DIR Where to find build file. Must exist. [default: $TEST_DIR]" echo " --os ARGS VM configuration. This parameter might be used more than once:" echo " --fio-bin=FIO Use specific fio binary (will be uploaded to VM)" - echo " --fio-job= Fio config to use for test." echo " num=NUM - VM number" echo " os=OS - VM os disk path" echo " bdevs=DISKS - VM test disks/devices path separated by ':'" @@ -49,8 +48,6 @@ done . $(readlink -e "$(dirname $0)/../common/common.sh") || exit 1 -job_file="$BASE_DIR/migration-malloc.job" - trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT function vm_monitor_send() @@ -100,51 +97,6 @@ function vm_migrate() notice "Migration complete" } -# FIXME: this shoul'd not be needed -vm_kill_all - -rpc="python $SPDK_BUILD_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" - -# Use 2 VMs: -# incoming VM - the one we want to migrate -# targe VM - the one which will accept migration -incoming_vm=0 -target_vm=1 -incoming_vm_ctrlr=naa.Malloc0.$incoming_vm -target_vm_ctrlr=naa.Malloc0.$target_vm - -vm_setup --os="$os_image" --force=$incoming_vm --disk-type=spdk_vhost_scsi --disks=Malloc0 --migrate-to=$target_vm -vm_setup --force=$target_vm --disk-type=spdk_vhost_scsi --disks=Malloc0 --incoming=$incoming_vm - -spdk_vhost_run --conf-path=$BASE_DIR - -notice "===============" -notice "" -notice "Setting up VMs" -notice "" - -declare -A vm_ctrlr - -function clean_vhost_config() -{ - notice "Removing vhost devices & controllers via RPC ..." - # Delete bdev first to remove all LUNs and SCSI targets - $rpc delete_bdev Malloc0 - - # Delete controllers - $rpc remove_vhost_controller $incoming_vm_ctrlr - $rpc remove_vhost_controller $target_vm_ctrlr -} - -function error_migration_clean() -{ - trap - SIGINT ERR EXIT - set -x - - vm_kill_all - clean_vhost_config -} - function is_fio_running() { local shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" @@ -160,70 +112,10 @@ function is_fio_running() return $ret } -trap 'error_migration_clean; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT +# FIXME: this shoul'd not be needed +vm_kill_all -# Construct shared Malloc Bdev -$rpc construct_malloc_bdev -b Malloc0 128 4096 - -# And two controllers - one for each VM. Both are using the same Malloc Bdev as LUN 0 -$rpc construct_vhost_scsi_controller $incoming_vm_ctrlr -$rpc add_vhost_scsi_lun $incoming_vm_ctrlr 0 Malloc0 - -$rpc construct_vhost_scsi_controller $target_vm_ctrlr -$rpc add_vhost_scsi_lun $target_vm_ctrlr 0 Malloc0 - -# Run everything -vm_run $incoming_vm $target_vm - -# Wait only for incoming VM, as target is waiting for migration -vm_wait_for_boot 600 $incoming_vm - -# Run fio before migration -notice "Starting FIO" - -vm_check_scsi_location $incoming_vm -run_fio $fio_bin --job-file="$job_file" --local --vm="${incoming_vm}$(printf ':/dev/%s' $SCSI_DISK)" - -# Wait a while to let the FIO time to issue some IO -sleep 5 - -# Check if fio is still running before migration -if ! is_fio_running $incoming_vm; then - vm_ssh $incoming_vm "cat /root/$(basename ${job_file}).out" - error "FIO is not running before migration: process crashed or finished too early" -fi - -vm_migrate $incoming_vm -sleep 3 - -# Check if fio is still running after migration -if ! is_fio_running $target_vm; then - vm_ssh $target_vm "cat /root/$(basename ${job_file}).out" - error "FIO is not running after migration: process crashed or finished too early" -fi - -notice "Waiting for fio to finish" -timeout=40 -while is_fio_running $target_vm; do - sleep 1 - echo -n "." - if (( timeout-- == 0 )); then - error "timeout while waiting for FIO!" - fi -done - -notice "Fio result is:" -vm_ssh $target_vm "cat /root/$(basename ${job_file}).out" - -notice "Migration DONE" - - -notice "Shutting down all VMs" -vm_shutdown_all -clean_vhost_config - -notice "killing vhost app" -spdk_vhost_kill +source $BASE_DIR/migration-tc1.sh notice "Migration Test SUCCESS" notice "===============" diff --git a/test/vhost/spdk_vhost.sh b/test/vhost/spdk_vhost.sh index a187cbf88..fdfd21adc 100755 --- a/test/vhost/spdk_vhost.sh +++ b/test/vhost/spdk_vhost.sh @@ -77,7 +77,7 @@ case $1 in ;; -m|--migration) echo 'Running migration suite...' - $WORKDIR/migration/migration-malloc.sh -x \ + $WORKDIR/migration/migration.sh -x \ --fio-bin=$FIO_BIN --os=$VM_IMAGE ;; -i|--integrity)