]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/env bash |
2 | ||
3 | testdir=$(readlink -f $(dirname $0)) | |
4 | rootdir=$(readlink -f $testdir/../../..) | |
11fdf7f2 TL |
5 | source $rootdir/test/common/autotest_common.sh |
6 | source $rootdir/test/iscsi_tgt/common.sh | |
7c673cae | 7 | |
9f95a23c TL |
8 | # $1 = "iso" - triggers isolation mode (setting up required environment). |
9 | # $2 = test type posix or vpp. defaults to posix. | |
10 | iscsitestinit $1 $2 | |
7c673cae | 11 | |
11fdf7f2 | 12 | rpc_py="$rootdir/scripts/rpc.py" |
9f95a23c | 13 | node_base="iqn.2013-06.com.intel.ch.spdk" |
7c673cae | 14 | |
11fdf7f2 | 15 | timing_enter start_iscsi_tgt |
7c673cae | 16 | |
f67539c2 | 17 | "${ISCSI_APP[@]}" --wait-for-rpc & |
7c673cae FG |
18 | pid=$! |
19 | echo "Process pid: $pid" | |
20 | ||
f67539c2 | 21 | trap '$rpc_py bdev_split_delete Name0n1 || true; killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT |
7c673cae | 22 | |
11fdf7f2 | 23 | waitforlisten $pid |
f67539c2 TL |
24 | $rpc_py iscsi_set_options -o 30 -a 4 -b $node_base |
25 | $rpc_py framework_start_init | |
11fdf7f2 | 26 | $rootdir/scripts/gen_nvme.sh --json | $rpc_py load_subsystem_config |
f67539c2 | 27 | $rpc_py bdev_malloc_create 512 4096 --name Malloc0 |
7c673cae FG |
28 | echo "iscsi_tgt is listening. Running tests..." |
29 | ||
11fdf7f2 TL |
30 | timing_exit start_iscsi_tgt |
31 | ||
f67539c2 TL |
32 | $rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT |
33 | $rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK | |
34 | $rpc_py bdev_error_create 'Malloc0' | |
7c673cae FG |
35 | # "1:2" ==> map PortalGroup1 to InitiatorGroup2 |
36 | # "64" ==> iSCSI queue depth 64 | |
11fdf7f2 | 37 | # "-d" ==> disable CHAP authentication |
f67539c2 | 38 | $rpc_py iscsi_create_target_node Target0 Target0_alias EE_Malloc0:0 1:2 64 -d |
7c673cae FG |
39 | sleep 1 |
40 | ||
11fdf7f2 TL |
41 | iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT |
42 | iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT | |
f67539c2 | 43 | waitforiscsidevices 1 |
7c673cae | 44 | |
f67539c2 | 45 | trap 'for new_dir in $(dir -d /mnt/*dir); do umount $new_dir; rm -rf $new_dir; done; |
9f95a23c | 46 | iscsicleanup; killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT |
7c673cae | 47 | |
11fdf7f2 | 48 | echo "Test error injection" |
f67539c2 | 49 | $rpc_py bdev_error_inject_error EE_Malloc0 'all' 'failure' -n 1000 |
11fdf7f2 TL |
50 | |
51 | dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}') | |
52 | ||
53 | set +e | |
f67539c2 TL |
54 | waitforfile /dev/${dev} |
55 | if make_filesystem ext4 /dev/${dev}; then | |
11fdf7f2 TL |
56 | echo "mkfs successful - expected failure" |
57 | iscsicleanup | |
58 | killprocess $pid | |
59 | exit 1 | |
60 | else | |
61 | echo "mkfs failed as expected" | |
62 | fi | |
63 | set -e | |
64 | ||
9f95a23c | 65 | iscsicleanup |
f67539c2 TL |
66 | $rpc_py bdev_error_inject_error EE_Malloc0 'clear' 'failure' |
67 | $rpc_py iscsi_delete_target_node $node_base:Target0 | |
11fdf7f2 TL |
68 | echo "Error injection test done" |
69 | ||
11fdf7f2 | 70 | if [ -z "$NO_NVME" ]; then |
f67539c2 TL |
71 | bdev_size=$(get_bdev_size Nvme0n1) |
72 | split_size=$((bdev_size / 2)) | |
73 | if [ $split_size -gt 10000 ]; then | |
74 | split_size=10000 | |
75 | fi | |
76 | $rpc_py bdev_split_create Nvme0n1 2 -s $split_size | |
77 | $rpc_py iscsi_create_target_node Target1 Target1_alias Nvme0n1p0:0 1:2 64 -d | |
11fdf7f2 TL |
78 | fi |
79 | ||
80 | iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT | |
81 | iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT | |
f67539c2 | 82 | waitforiscsidevices 1 |
7c673cae FG |
83 | |
84 | devs=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}') | |
85 | ||
86 | for dev in $devs; do | |
f67539c2 | 87 | make_filesystem ext4 /dev/${dev} |
7c673cae | 88 | mkdir -p /mnt/${dev}dir |
f67539c2 | 89 | mount -o sync /dev/${dev} /mnt/${dev}dir |
7c673cae | 90 | |
11fdf7f2 | 91 | rsync -qav --exclude=".git" --exclude="*.o" $rootdir/ /mnt/${dev}dir/spdk |
7c673cae | 92 | |
11fdf7f2 | 93 | make -C /mnt/${dev}dir/spdk clean |
f67539c2 | 94 | (cd /mnt/${dev}dir/spdk && ./configure $(get_config_params)) |
11fdf7f2 | 95 | make -C /mnt/${dev}dir/spdk -j16 |
7c673cae FG |
96 | |
97 | # Print out space consumed on target device to help decide | |
98 | # if/when we need to increase the size of the malloc LUN | |
99 | df -h /dev/$dev | |
100 | ||
101 | rm -rf /mnt/${dev}dir/spdk | |
102 | done | |
103 | ||
104 | for dev in $devs; do | |
105 | umount /mnt/${dev}dir | |
106 | rm -rf /mnt/${dev}dir | |
107 | ||
11fdf7f2 | 108 | stats=($(cat /sys/block/$dev/stat)) |
7c673cae FG |
109 | echo "" |
110 | echo "$dev stats" | |
111 | printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ | |
11fdf7f2 | 112 | ${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]} |
7c673cae | 113 | printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ |
11fdf7f2 | 114 | ${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]} |
7c673cae | 115 | printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \ |
11fdf7f2 | 116 | ${stats[8]} ${stats[9]} ${stats[10]} |
7c673cae FG |
117 | echo "" |
118 | done | |
119 | ||
120 | trap - SIGINT SIGTERM EXIT | |
121 | ||
7c673cae | 122 | iscsicleanup |
f67539c2 TL |
123 | $rpc_py bdev_split_delete Nvme0n1 |
124 | $rpc_py bdev_error_delete EE_Malloc0 | |
11fdf7f2 TL |
125 | |
126 | if [ -z "$NO_NVME" ]; then | |
f67539c2 | 127 | $rpc_py bdev_nvme_detach_controller Nvme0 |
11fdf7f2 TL |
128 | fi |
129 | ||
7c673cae | 130 | killprocess $pid |
9f95a23c | 131 | iscsitestfini $1 $2 |