~ubuntu-branches/ubuntu/hardy/open-iscsi/hardy-updates

« back to all changes in this revision

Viewing changes to test/regression.sh

  • Committer: Bazaar Package Importer
  • Author(s): Martin Zobel-Helas
  • Date: 2006-12-03 16:54:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061203165421-xhttz5j4l9sowg8u
Tags: 2.0.730-0.2
upload to unstable, as no new bugs arised.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# See the file COPYING included with this distribution for more details.
18
18
#
19
19
 
20
 
PATH=$PATH:.
 
20
PATH=".:${PATH}"
 
21
FSTYPE="${FSTYPE:-ext3}"
 
22
DEFAULTMOUNTOPTS='-o _netdev'
 
23
[ -z "${MOUNTOPTS}" ] && MOUNTOPTS="${DEFAULTMOUNTOPTS}"
 
24
# to avoid mount looking for fstype
 
25
MOUNTOPTIONS="${MOUNTOPTIONS} -t ${FSTYPE}"
 
26
MKFSCMD="${MKFSCMD:-mkfs.${FSTYPE}} ${MKFSOPTS}"
 
27
PARTITIONSUFFIX="1"
 
28
BONNIEPARAMS="${BONNIEPARAMS:--r0 -n10:0:0 -s16 -uroot -f -q}"
21
29
 
22
30
trap regress_signal INT QUIT TERM
23
31
regress_signal() {
24
32
    printf "\nterminating, restore defaults: "
25
 
./iscsiadm -m node -r $record -o update \
26
 
        -n node.session.iscsi.ImmediateData -v Yes
27
 
./iscsiadm -m node -r $record -o update \
28
 
        -n node.session.iscsi.InitialR2T -v No
29
 
./iscsiadm -m node -r $record -o update \
30
 
        -n node.conn[0].iscsi.HeaderDigest -v None,CRC32C
31
 
./iscsiadm -m node -r $record -o update \
32
 
        -n node.session.iscsi.FirstBurstLength -v $((256*1024))
33
 
./iscsiadm -m node -r $record -o update \
34
 
        -n node.session.iscsi.MaxBurstLength -v $((16*1024*1024-1024))
35
 
./iscsiadm -m node -r $record -o update \
36
 
        -n node.conn[0].iscsi.MaxRecvDataSegmentLength -v $((128*1024))
 
33
        # use the other function to clean up
 
34
        imm_data_en="Yes"
 
35
        initial_r2t_en="No"
 
36
        hdrdgst_en="None,CRC32C"
 
37
        datdgst_en="None,CRC32C"
 
38
        c="${iscsiadm} -m node -T $target -p $ipnr -o update"
 
39
        first_burst="$((256*1024))"
 
40
        max_burst="$((16*1024*1024-1024))"
 
41
        max_recv_dlength="$((128*1024))"
 
42
        max_r2t="1"
 
43
        update_cfg
 
44
        ${iscsiadm} -m node -T $target -p $ipnr --logout 2>/dev/null >/dev/null
37
45
    printf "done\n"
38
46
    exit 0
39
47
}
40
48
 
41
49
function update_cfg() {
42
 
./iscsiadm -m node -r $record -u
43
 
./iscsiadm -m node -r $record -o update \
44
 
        -n node.session.iscsi.ImmediateData -v $imm_data_en
45
 
./iscsiadm -m node -r $record -o update \
46
 
        -n node.session.iscsi.InitialR2T -v $initial_r2t_en
47
 
./iscsiadm -m node -r $record -o update \
48
 
        -n node.conn[0].iscsi.HeaderDigest -v $hdrdgst_en
49
 
./iscsiadm -m node -r $record -o update \
50
 
        -n node.session.iscsi.FirstBurstLength -v $first_burst
51
 
./iscsiadm -m node -r $record -o update \
52
 
        -n node.session.iscsi.MaxBurstLength -v $max_burst
53
 
./iscsiadm -m node -r $record -o update \
54
 
        -n node.conn[0].iscsi.MaxRecvDataSegmentLength -v $max_recv_dlength
55
 
./iscsiadm -m node -r $record -l
 
50
        c="${iscsiadm} -m node -T $target -p $ipnr -o update"
 
51
        $c -n node.session.iscsi.ImmediateData -v $imm_data_en
 
52
        $c -n node.session.iscsi.InitialR2T -v $initial_r2t_en
 
53
        $c -n node.conn[0].iscsi.HeaderDigest -v $hdrdgst_en
 
54
        $c -n node.conn[0].iscsi.DataDigest -v $datdgst_en
 
55
        $c -n node.session.iscsi.FirstBurstLength -v $first_burst
 
56
        $c -n node.session.iscsi.MaxBurstLength -v $max_burst
 
57
        $c -n node.conn[0].iscsi.MaxRecvDataSegmentLength -v $max_recv_dlength
 
58
        $c -n node.session.iscsi.MaxOutstandingR2T -v $max_r2t
56
59
}
57
60
 
58
61
function disktest_run() {
59
62
        bsizes="512 1024 2048 4096 8192 16384 32768 65536 131072 1000000"
60
 
        test x$bsize != x && bsizes=$bsize
61
 
        test x$bsize = xbonnie && return 0;
 
63
        test "x$bsize" != x && bsizes=$bsize
 
64
        test "x$bsize" = xbonnie && return 0;
62
65
        for bs in $bsizes; do
63
66
                echo -n "disktest -T2 -K8 -B$bs -r -ID $device: "
64
 
                if ! disktest -T2 -K8 -B$bs -r -ID $device >/dev/null; then
 
67
                if ! ${disktest} -T2 -K8 -B$bs -r -ID $device >/dev/null; then
65
68
                        echo "FAILED"
66
69
                        return 1;
67
70
                fi
68
71
                echo "PASSED"
69
72
                echo -n "disktest -T2 -K8 -B$bs -E16 -w -ID $device: "
70
 
                if ! disktest -T2 -K8 -B$bs -E16 -w -ID $device >/dev/null;then
 
73
                if ! ${disktest} -T2 -K8 -B$bs -E16 -w -ID $device >/dev/null;then
71
74
                        echo "FAILED"
72
75
                        return 1;
73
76
                fi
77
80
}
78
81
 
79
82
function fdisk_run() {
80
 
        echo -n "fdisk $device: "
81
 
        if ! echo "
82
 
p
83
 
d
84
 
n
85
 
p
86
 
1
87
 
 
88
 
 
89
 
w
90
 
q
91
 
" | fdisk $device 2>/dev/null >/dev/null; then
 
83
        echo -n "sfdisk -Lqf $device: "
 
84
        sfdisk -Lqf $device >/dev/null 2>/dev/null <<-EOF
 
85
        0,
 
86
        ;
 
87
        ;
 
88
        ;
 
89
        EOF
 
90
        rc=$?
 
91
        if [ $rc -ne 0 ]; then
92
92
                echo "FAILED"
93
93
                return 1;
94
94
        fi
97
97
}
98
98
 
99
99
function mkfs_run() {
100
 
        echo -n "mke2fs $device: "
101
 
        if ! mke2fs $device"1" 2>/dev/null >/dev/null; then
 
100
        echo -n "${MKFSCMD} $device_partition: "
 
101
        if ! ${MKFSCMD} $device_partition 2>/dev/null >/dev/null; then
102
102
                echo "FAILED"
103
103
                return 1;
104
104
        fi
107
107
}
108
108
 
109
109
function bonnie_run() {
110
 
        dir="/tmp/iscsi.bonnie.regression"
111
 
        bonnie_dir=`pwd`
 
110
        dir="/tmp/iscsi.bonnie.regression.$record.$RANDOM"
112
111
        umount $dir 2>/dev/null >/dev/null
113
112
        rm -rf $dir; mkdir $dir
114
113
        echo -n "mount $dir: "
115
 
        if ! mount -t ext2 $device"1" $dir; then
 
114
        if ! mount ${MOUNTOPTIONS} $device_partition $dir; then
116
115
                echo "FAILED"
117
116
                return 1;
118
117
        fi
119
118
        echo "PASSED"
120
 
        echo -n "bonnie++ -r0 -n10:0:0 -s16 -uroot -f -q: "
 
119
        echo -n "bonnie++ ${BONNIEPARAMS}: "
121
120
        pushd $dir >/dev/null
122
 
        if ! $bonnie_dir/bonnie++ -r0 -n10:0:0 -s16 -uroot -f -q 2>/dev/null >/dev/null; then
123
 
                popd >/dev/null
124
 
                umount $dir 2>/dev/null >/dev/null
125
 
                echo "FAILED"
126
 
                return 1;
127
 
        fi
 
121
        ${bonnie} ${BONNIEPARAMS} 2>/dev/null >/dev/null
 
122
        rc=$?
128
123
        popd >/dev/null
129
124
        umount $dir 2>/dev/null >/dev/null
 
125
        rmdir ${dir}
 
126
        if [ $rc -ne 0 ]; then
 
127
                echo "FAILED"
 
128
                return 1;
 
129
        fi
130
130
        echo "PASSED"
131
131
        return 0;
132
132
}
133
133
 
134
134
function fatal() {
135
135
        echo "regression.sh: $1"
136
 
        echo "Usage: regression.sh <rec#|-f> <device> [test#[:#]] [bsize]"
 
136
        echo "Usage: regression.sh <targetname|-f> <ipnumber#> <device> [test#[:#]] [bsize]"
137
137
        exit 1
138
138
}
139
139
 
140
140
############################ main ###################################
141
141
 
142
 
test ! -e regression.dat && fatal "can not find regression.dat"
143
 
test ! -e disktest && fatal "can not find disktest"
144
 
test ! -e iscsiadm && fatal "can not find iscsiadm"
145
 
test ! -e bonnie++ && fatal "can not find bonnie++"
146
 
test x$1 = x && fatal "node record parameter error"
147
 
test x$2 = x && fatal "SCSI device parameter error"
 
142
disktest=`which disktest`
 
143
iscsiadm=`which iscsiadm`
 
144
bonnie=`which bonnie++`
 
145
datfile=`dirname $0`"/regression.dat"
 
146
test ! -e ${datfile} && fatal "can not find regression.dat"
 
147
test ! -e ${disktest} && fatal "can not find disktest"
 
148
test ! -e ${iscsiadm} && fatal "can not find iscsiadm"
 
149
test ! -e ${bonnie} && fatal "can not find bonnie++"
 
150
test x$1 = x && fatal "target name parameter error"
 
151
test x$2 = x && fatal "ipnumber parameter error"
 
152
test x$3 = x && fatal "SCSI device parameter error"
148
153
 
149
 
device=$2
150
154
if test x$1 = "x-f" -o x$1 = "x--format"; then
151
155
        mkfs_run
152
156
        exit
153
157
fi
154
158
 
155
 
record=$1
156
 
test x$3 != x && begin=$3
157
 
test x$4 != x && bsize=$4
158
 
 
159
 
if test x$begin != x; then
160
 
        end=`echo $begin | awk -F: '{print $2}'`
161
 
        begin=`echo $begin | awk -F: '{print $1}'`
162
 
fi
163
 
 
164
 
printf "
165
 
BIG FAT WARNING!
166
 
 
167
 
Open-iSCSI Regression Test Suite is about to start. It is going
168
 
to use "$device" for its testing. iSCSI session could be re-opened
169
 
during the tests several times and as the result device name could
170
 
not match provided device name if some other SCSI activity happened
171
 
during the test.
172
 
 
173
 
Are you sure you want to continue? [y/n]: "
174
 
read line
175
 
if test x$line = xn -o x$line = xN -o x$line = xno -o x$line = xNO; then
176
 
        echo "aborting..."
177
 
        exit
 
159
target="$1"
 
160
ipnr="$2"
 
161
device=$3
 
162
 
 
163
device_dir="$(dirname ${device})"
 
164
device_partition=''
 
165
case "${device_dir}" in
 
166
        # /dev/sdaX
 
167
        /dev) device_partition="${device}1" ;;
 
168
        # /dev/disk/by-id/scsi-${ID_SERIAL}-part1
 
169
        # where ID_SERIAL is SCSI disk SERIAL from scsi_id
 
170
        /dev/disk/by-id|/dev/disk/by-path) device_partition="${device}-part1" ;;
 
171
        # upcoming stuff
 
172
        /dev/iscsi/*) device_partition="${device}-part1" ;;
 
173
esac
 
174
 
 
175
if [ -z "${device_partition}" ]; then
 
176
        echo 'Unable to find device name for first partition.' >&2
 
177
        exit 1
 
178
fi
 
179
 
 
180
test "x$4" != x && begin="$4"
 
181
test "x$5" != x && bsize="$5"
 
182
 
 
183
if test "x$begin" != "x"; then
 
184
        end="${begin/*:}"
 
185
        begin="${begin/:*}"
 
186
fi
 
187
 
 
188
# don't say we didn't warn you
 
189
if [ -z "${SKIP_WARNING}" ]; then
 
190
        cat <<-EOF
 
191
        BIG FAT WARNING!
 
192
        
 
193
        Open-iSCSI Regression Test Suite is about to start. It is going
 
194
        to use "$device" for its testing. iSCSI session could be re-opened
 
195
        during the tests several times and as the result device name could
 
196
        not match provided device name if some other SCSI activity happened
 
197
        during the test.
 
198
        
 
199
        Are you sure you want to continue? [y/n]:
 
200
        EOF
 
201
        read line
 
202
        if test x$line = xn -o x$line = xN -o x$line = xno -o x$line = xNO; then
 
203
                echo "aborting..."
 
204
                exit
 
205
        fi
178
206
fi
179
207
 
180
208
i=0
181
 
cat regression.dat | while read line; do
 
209
cat ${datfile} | while read line; do
182
210
        if echo $line | grep "^#" >/dev/null; then continue; fi
183
211
        if echo $line | grep "^$" >/dev/null; then continue; fi
184
212
        if test x$begin != x; then
196
224
        if test x$imm_data_en = x; then continue; fi
197
225
        initial_r2t_en=`echo $line | awk '{print $2}'`
198
226
        hdrdgst_en=`echo $line | awk '{print $3}'`
199
 
        first_burst=`echo $line | awk '{print $4}'`
200
 
        max_burst=`echo $line | awk '{print $5}'`
201
 
        max_recv_dlength=`echo $line | awk '{print $6}'`
202
 
        max_r2t=`echo $line | awk '{print $7}'`
 
227
        datdgst_en=`echo $line | awk '{print $4}'`
 
228
        first_burst=`echo $line | awk '{print $5}'`
 
229
        max_burst=`echo $line | awk '{print $6}'`
 
230
        max_recv_dlength=`echo $line | awk '{print $7}'`
 
231
        max_r2t=`echo $line | awk '{print $8}'`
 
232
        # ensure we are logged out
 
233
        ${iscsiadm} -m node -T $target -p $ipnr --logout 2>/dev/null >/dev/null
 
234
        # set parameters for next run
203
235
        update_cfg
204
236
        echo "================== TEST #$i BEGIN ===================="
205
 
        echo "imm_data_en = $imm_data_en"
206
 
        echo "initial_r2t_en = $initial_r2t_en"
207
 
        echo "hdrdgst_en = $hdrdgst_en"
208
 
        echo "first_burst = $first_burst"
209
 
        echo "max_burst = $max_burst"
210
 
        echo "max_recv_dlength = $max_recv_dlength"
211
 
        echo "max_r2t = $max_r2t"
 
237
        echo "ImmediateData = $imm_data_en"
 
238
        echo "InitialR2T = $initial_r2t_en"
 
239
        echo "HeaderDigest = $hdrdgst_en"
 
240
        echo "DataDigest = $datdgst_en"
 
241
        echo "FirstBurstLength = $first_burst"
 
242
        echo "MaxBurstLength = $max_burst"
 
243
        echo "MaxRecvDataSegmentLength = $max_recv_dlength"
 
244
        echo "MaxOutstandingR2T = $max_r2t"
 
245
        # login for new test
 
246
        # catch errors on this
 
247
        if ! ${iscsiadm} -m node -T $target -p $ipnr --login; then break; fi
 
248
        while [ ! -e $device ] ; do sleep 1 ; done
212
249
        if ! disktest_run; then break; fi
213
250
        if ! fdisk_run; then break; fi
214
251
        if ! mkfs_run; then break; fi