3 testdir
=$
(readlink
-f $
(dirname $0))
4 rootdir
=$
(readlink
-f $testdir/..
/..
/..
)
5 source $rootdir/test
/common
/autotest_common.sh
6 source $rootdir/test
/iscsi_tgt
/common.sh
8 # $1 = "iso" - triggers isolation mode (setting up required environment).
9 # $2 = test type posix or vpp. defaults to posix.
12 TRACE_TMP_FOLDER
=.
/tmp-trace
13 TRACE_RECORD_OUTPUT
=${TRACE_TMP_FOLDER}/record.trace
14 TRACE_RECORD_NOTICE_LOG
=${TRACE_TMP_FOLDER}/record.notice
15 TRACE_TOOL_LOG
=${TRACE_TMP_FOLDER}/trace.log
18 rm -rf $TRACE_TMP_FOLDER
21 if [ -z "$TARGET_IP" ]; then
22 echo "TARGET_IP not defined in environment"
26 if [ -z "$INITIATOR_IP" ]; then
27 echo "INITIATOR_IP not defined in environment"
31 NUM_TRACE_ENTRIES
=4096
33 MALLOC_BLOCK_SIZE
=4096
35 rpc_py
="$rootdir/scripts/rpc.py"
36 fio_py
="$rootdir/scripts/fio.py"
38 timing_enter start_iscsi_tgt
40 echo "start iscsi_tgt with trace enabled"
41 "${ISCSI_APP[@]}" -m 0xf --num-trace-entries $NUM_TRACE_ENTRIES --tpoint-group-mask 0xf &
43 echo "Process pid: $iscsi_pid"
45 trap 'killprocess $iscsi_pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
47 waitforlisten
$iscsi_pid
49 echo "iscsi_tgt is listening. Running tests..."
51 timing_exit start_iscsi_tgt
53 mkdir
-p ${TRACE_TMP_FOLDER}
54 .
/build
/bin
/spdk_trace_record
-s iscsi
-p ${iscsi_pid} -f ${TRACE_RECORD_OUTPUT} -q 1> ${TRACE_RECORD_NOTICE_LOG} &
56 echo "Trace record pid: $record_pid"
59 RPCS
+="iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT\n"
60 RPCS
+="iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK\n"
62 echo "Create bdevs and target nodes"
64 for i
in $
(seq 0 $CONNECTION_NUMBER); do
65 RPCS
+="bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc$i\n"
66 RPCS
+="iscsi_create_target_node Target$i Target${i}_alias "Malloc
$i:0" $PORTAL_TAG:$INITIATOR_TAG 256 -d\n"
68 echo -e $RPCS |
$rpc_py
72 iscsiadm
-m discovery
-t sendtargets
-p $TARGET_IP:$ISCSI_PORT
73 iscsiadm
-m node
--login -p $TARGET_IP:$ISCSI_PORT
74 waitforiscsidevices $
((CONNECTION_NUMBER
+ 1))
76 trap 'iscsicleanup; killprocess $iscsi_pid; killprocess $record_pid; delete_tmp_files; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
79 $fio_py -p iscsi
-i 131072 -d 32 -t randrw
-r 1
84 # Delete Malloc blockdevs and targets
85 for i
in $
(seq 0 $CONNECTION_NUMBER); do
86 RPCS
+="iscsi_delete_target_node iqn.2016-06.io.spdk:Target$i\n"
87 RPCS
+="bdev_malloc_delete Malloc$i\n"
89 echo -e $RPCS |
$rpc_py
91 trap 'delete_tmp_files; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
93 killprocess
$iscsi_pid
94 killprocess
$record_pid
95 .
/build
/bin
/spdk_trace
-f ${TRACE_RECORD_OUTPUT} > ${TRACE_TOOL_LOG}
97 #verify trace record and trace tool
98 #trace entries str in trace-record, like "Trace Size of lcore (0): 4136"
99 record_num
="$(grep "trace entries
for lcore
" ${TRACE_RECORD_NOTICE_LOG} | cut -d ' ' -f 2)"
101 #trace entries str in trace-tool, like "Port 4096 trace entries for lcore (0) in 441871 msec"
102 trace_tool_num
="$(grep "Trace Size of lcore
" ${TRACE_TOOL_LOG} | cut -d ' ' -f 6)"
106 echo "entries numbers from trace record are:" $record_num
107 echo "entries numbers from trace tool are:" $trace_tool_num
109 arr_record_num
=($record_num)
110 arr_trace_tool_num
=($trace_tool_num)
111 len_arr_record_num
=${#arr_record_num[@]}
112 len_arr_trace_tool_num
=${#arr_trace_tool_num[@]}
115 if [ $len_arr_record_num -ne $len_arr_trace_tool_num ]; then
116 echo "trace record test on iscsi: failure on lcore number check"
120 #trace entries num check
121 for i
in $
(seq 0 $
((len_arr_record_num
- 1))); do
122 if [ ${arr_record_num[$i]} -le ${NUM_TRACE_ENTRIES} ]; then
123 echo "trace record test on iscsi: failure on inefficient entries number check"
127 if [ ${arr_record_num[$i]} -ne ${arr_trace_tool_num[$i]} ]; then
128 echo "trace record test on iscsi: failure on entries number check"
134 trap - SIGINT SIGTERM EXIT