2016-11-23 03:04:34 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2017-04-04 23:20:16 +00:00
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
2018-02-27 22:14:08 +00:00
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2017-05-24 23:29:24 +00:00
|
|
|
source $rootdir/test/iscsi_tgt/common.sh
|
2016-11-23 03:04:34 +00:00
|
|
|
|
2019-05-06 22:46:30 +00:00
|
|
|
# $1 = "iso" - triggers isolation mode (setting up required environment).
|
|
|
|
# $2 = test type posix or vpp. defaults to posix.
|
|
|
|
iscsitestinit $1 $2
|
|
|
|
|
2018-09-11 13:26:14 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py"
|
|
|
|
fio_py="$rootdir/scripts/fio.py"
|
2016-11-23 03:04:34 +00:00
|
|
|
|
2018-04-25 16:16:08 +00:00
|
|
|
# Namespaces are NOT used here on purpose. This test requires changes to detect
|
2019-09-18 08:53:32 +00:00
|
|
|
# ifc_index for interface that was put into namespace. Needed for net_interface_add_ip_address.
|
2020-02-20 10:24:53 +00:00
|
|
|
# Reset ISCSI_APP[] to use only the plain app for this test without TARGET_NS_CMD preset.
|
|
|
|
source "$rootdir/test/common/applications.sh"
|
2017-02-01 18:14:03 +00:00
|
|
|
NETMASK=127.0.0.0/24
|
|
|
|
MIGRATION_ADDRESS=127.0.0.2
|
|
|
|
|
2016-11-23 03:04:34 +00:00
|
|
|
function kill_all_iscsi_target() {
|
2018-04-18 08:36:46 +00:00
|
|
|
for ((i = 0; i < 2; i++)); do
|
2017-11-20 18:01:28 +00:00
|
|
|
rpc_addr="/var/tmp/spdk${i}.sock"
|
2019-09-19 21:13:36 +00:00
|
|
|
$rpc_py -s $rpc_addr spdk_kill_instance SIGTERM
|
2016-11-23 03:04:34 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function rpc_config() {
|
2017-11-20 18:01:28 +00:00
|
|
|
# $1 = RPC server address
|
2016-11-23 03:04:34 +00:00
|
|
|
# $2 = Netmask
|
2019-09-03 08:53:37 +00:00
|
|
|
$rpc_py -s $1 iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $2
|
2019-08-09 11:15:35 +00:00
|
|
|
$rpc_py -s $1 bdev_malloc_create 64 512
|
2016-11-23 03:04:34 +00:00
|
|
|
}
|
2018-03-15 06:44:53 +00:00
|
|
|
|
2019-12-03 20:48:22 +00:00
|
|
|
function rpc_validate_ip() {
|
|
|
|
# Always delete the IP first in case it is there already
|
|
|
|
cmd="$rpc_py -s $1 net_interface_delete_ip_address 1 $MIGRATION_ADDRESS"
|
|
|
|
if $cmd; then
|
|
|
|
echo "Delete existing IP succeeded."
|
|
|
|
else
|
|
|
|
echo "Ignore the failure as IP did not exist."
|
|
|
|
fi
|
|
|
|
|
|
|
|
cmd="$rpc_py -s $1 net_interface_add_ip_address 1 $MIGRATION_ADDRESS"
|
|
|
|
if $cmd; then
|
|
|
|
echo "Add new IP succeeded."
|
|
|
|
else
|
|
|
|
echo "Add new IP failed. Expected to succeed..."
|
2020-05-07 11:27:06 +00:00
|
|
|
exit 1
|
2019-12-03 20:48:22 +00:00
|
|
|
fi
|
|
|
|
# Add same IP again
|
|
|
|
if $cmd; then
|
|
|
|
echo "Same IP existed. Expected to fail..."
|
2020-05-07 11:27:06 +00:00
|
|
|
exit 1
|
2019-12-03 20:48:22 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cmd="$rpc_py -s $1 net_interface_delete_ip_address 1 $MIGRATION_ADDRESS"
|
|
|
|
if $cmd; then
|
|
|
|
echo "Delete existing IP succeeded."
|
|
|
|
else
|
|
|
|
echo "Delete existing IP failed. Expected to succeed..."
|
2020-05-07 11:27:06 +00:00
|
|
|
exit 1
|
2019-12-03 20:48:22 +00:00
|
|
|
fi
|
|
|
|
# Delete same IP again
|
|
|
|
if $cmd; then
|
|
|
|
echo "No required IP existed. Expected to fail..."
|
2020-05-07 11:27:06 +00:00
|
|
|
exit 1
|
2019-12-03 20:48:22 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-03-15 06:44:53 +00:00
|
|
|
function rpc_add_target_node() {
|
2019-09-18 08:53:32 +00:00
|
|
|
$rpc_py -s $1 net_interface_add_ip_address 1 $MIGRATION_ADDRESS
|
2019-09-09 10:35:30 +00:00
|
|
|
$rpc_py -s $1 iscsi_create_portal_group $PORTAL_TAG $MIGRATION_ADDRESS:$ISCSI_PORT
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py -s $1 iscsi_create_target_node target1 target1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d
|
2019-12-03 20:48:22 +00:00
|
|
|
$rpc_py -s $1 net_interface_delete_ip_address 1 $MIGRATION_ADDRESS
|
2016-11-23 03:04:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "Running ip migration tests"
|
2018-04-18 08:36:46 +00:00
|
|
|
for ((i = 0; i < 2; i++)); do
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt_$i
|
|
|
|
|
2017-11-20 18:01:28 +00:00
|
|
|
rpc_addr="/var/tmp/spdk${i}.sock"
|
|
|
|
|
2017-05-25 16:27:36 +00:00
|
|
|
# TODO: run the different iSCSI instances on non-overlapping CPU masks
|
2020-02-20 10:24:53 +00:00
|
|
|
"${ISCSI_APP[@]}" -r $rpc_addr -i $i -m $ISCSI_TEST_CORE_MASK --wait-for-rpc &
|
2017-02-01 18:14:03 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
2016-11-23 03:04:34 +00:00
|
|
|
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'kill_all_iscsi_target; exit 1' SIGINT SIGTERM EXIT
|
2016-11-23 03:04:34 +00:00
|
|
|
|
2017-11-20 18:01:28 +00:00
|
|
|
waitforlisten $pid $rpc_addr
|
2019-09-11 11:15:34 +00:00
|
|
|
$rpc_py -s $rpc_addr iscsi_set_options -o 30 -a 64
|
2019-09-11 13:30:14 +00:00
|
|
|
$rpc_py -s $rpc_addr framework_start_init
|
2016-11-23 03:04:34 +00:00
|
|
|
echo "iscsi_tgt is listening. Running tests..."
|
2017-05-25 20:06:51 +00:00
|
|
|
|
|
|
|
timing_exit start_iscsi_tgt_$i
|
|
|
|
|
2017-11-20 18:01:28 +00:00
|
|
|
rpc_config $rpc_addr $NETMASK
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'kill_all_iscsi_target; iscsitestfini $1 $2; exit 1' \
|
2016-11-23 03:04:34 +00:00
|
|
|
SIGINT SIGTERM EXIT
|
|
|
|
done
|
|
|
|
|
2017-11-20 18:01:28 +00:00
|
|
|
rpc_first_addr="/var/tmp/spdk0.sock"
|
2019-12-03 20:48:22 +00:00
|
|
|
rpc_validate_ip $rpc_first_addr
|
2018-03-15 06:44:53 +00:00
|
|
|
rpc_add_target_node $rpc_first_addr
|
2016-11-23 03:04:34 +00:00
|
|
|
|
|
|
|
sleep 1
|
2018-03-27 13:39:38 +00:00
|
|
|
iscsiadm -m discovery -t sendtargets -p $MIGRATION_ADDRESS:$ISCSI_PORT
|
2016-11-23 03:04:34 +00:00
|
|
|
sleep 1
|
2018-03-27 13:39:38 +00:00
|
|
|
iscsiadm -m node --login -p $MIGRATION_ADDRESS:$ISCSI_PORT
|
2020-06-09 11:28:58 +00:00
|
|
|
waitforiscsidevices 1
|
2016-11-23 03:04:34 +00:00
|
|
|
|
|
|
|
# fio tests for multi-process
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 4096 -d 32 -t randrw -r 10 &
|
2016-11-23 03:04:34 +00:00
|
|
|
fiopid=$!
|
|
|
|
sleep 5
|
|
|
|
|
2019-09-19 21:13:36 +00:00
|
|
|
$rpc_py -s $rpc_first_addr spdk_kill_instance SIGTERM
|
2016-11-23 03:04:34 +00:00
|
|
|
|
2017-11-20 18:01:28 +00:00
|
|
|
rpc_second_addr="/var/tmp/spdk1.sock"
|
2018-03-15 06:44:53 +00:00
|
|
|
rpc_add_target_node $rpc_second_addr
|
2016-11-23 03:04:34 +00:00
|
|
|
|
|
|
|
wait $fiopid
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
iscsicleanup
|
|
|
|
|
2019-09-19 21:13:36 +00:00
|
|
|
$rpc_py -s $rpc_second_addr spdk_kill_instance SIGTERM
|
2019-05-06 22:46:30 +00:00
|
|
|
iscsitestfini $1 $2
|