2016-09-26 07:53:49 +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-09-26 07:53:49 +00:00
|
|
|
|
2018-07-15 03:33:08 +00:00
|
|
|
delete_tmp_conf_files() {
|
|
|
|
rm -f /usr/local/etc/its.conf
|
|
|
|
}
|
|
|
|
|
2017-03-07 21:41:36 +00:00
|
|
|
if [ ! -d /usr/local/calsoft ]; then
|
|
|
|
echo "skipping calsoft tests"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-09-26 07:53:49 +00:00
|
|
|
timing_enter calsoft
|
|
|
|
|
2016-10-17 08:30:26 +00:00
|
|
|
MALLOC_BDEV_SIZE=64
|
2016-09-26 07:53:49 +00:00
|
|
|
MALLOC_BLOCK_SIZE=512
|
|
|
|
|
2018-09-11 13:26:14 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py"
|
|
|
|
calsoft_py="$testdir/calsoft.py"
|
2016-09-26 07:53:49 +00:00
|
|
|
|
|
|
|
# Copy the calsoft config file to /usr/local/etc
|
|
|
|
mkdir -p /usr/local/etc
|
|
|
|
cp $testdir/its.conf /usr/local/etc/
|
|
|
|
|
2018-03-29 15:52:12 +00:00
|
|
|
# Append target ip to calsoft config
|
|
|
|
echo "IP=$TARGET_IP" >> /usr/local/etc/its.conf
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
2018-08-10 10:20:25 +00:00
|
|
|
$ISCSI_APP -m 0x1 --wait-for-rpc &
|
2016-09-26 07:53:49 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
|
|
|
|
2018-07-15 03:33:08 +00:00
|
|
|
trap "killprocess $pid; delete_tmp_conf_files; exit 1 " SIGINT SIGTERM EXIT
|
2016-09-26 07:53:49 +00:00
|
|
|
|
2017-11-09 23:33:29 +00:00
|
|
|
waitforlisten $pid
|
2018-09-10 18:18:08 +00:00
|
|
|
$rpc_py load_subsystem_config < $testdir/iscsi.json
|
2018-07-12 19:26:27 +00:00
|
|
|
$rpc_py start_subsystem_init
|
2016-09-26 07:53:49 +00:00
|
|
|
echo "iscsi_tgt is listening. Running tests..."
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_exit start_iscsi_tgt
|
|
|
|
|
2018-11-15 01:34:03 +00:00
|
|
|
$rpc_py add_iscsi_auth_group 1 -c 'user:root secret:tester'
|
2018-11-21 18:07:58 +00:00
|
|
|
$rpc_py set_iscsi_discovery_auth -g 1
|
2018-03-27 13:56:16 +00:00
|
|
|
$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
|
2016-09-26 07:53:49 +00:00
|
|
|
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
|
2017-10-06 22:00:28 +00:00
|
|
|
$rpc_py construct_malloc_bdev -b MyBdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE
|
|
|
|
# "MyBdev:0" ==> use MyBdev blockdev for LUN0
|
2016-09-26 07:53:49 +00:00
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
|
|
|
# "64" ==> iSCSI queue depth 64
|
|
|
|
# "0 0 0 1" ==> enable CHAP authentication using auth group 1
|
2018-03-28 13:13:58 +00:00
|
|
|
$rpc_py construct_target_node Target3 Target3_alias 'MyBdev:0' $PORTAL_TAG:$INITIATOR_TAG 64 -g 1
|
2016-09-26 07:53:49 +00:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
if [ "$1" ]; then
|
|
|
|
$calsoft_py "$output_dir" "$1"
|
|
|
|
failed=$?
|
|
|
|
else
|
|
|
|
$calsoft_py "$output_dir"
|
|
|
|
failed=$?
|
|
|
|
fi
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
killprocess $pid
|
2018-07-15 03:33:08 +00:00
|
|
|
delete_tmp_conf_files
|
2016-09-26 07:53:49 +00:00
|
|
|
timing_exit calsoft
|
|
|
|
exit $failed
|