Whamcloud - gitweb
LU-1538 tests: standardize test script init dne-part-1
[fs/lustre-release.git] / lustre / tests / parallel-scale-cifs.sh
1 #!/bin/bash
2
3 # Requires the pre-configured samba machine
4 # RPMS required are :
5 # server:
6 #      samba
7 #      samba-common
8 #      cifs-utils
9 # clients:
10 #      samba-client
11 #      samba-common
12 #      cifs-utils
13
14 #set -vx
15
16 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
17 . $LUSTRE/tests/test-framework.sh
18 init_test_env $@
19 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
20 init_logging
21 . $LUSTRE/tests/setup-cifs.sh
22
23 check_and_setup_lustre
24
25 # first unmount all the lustre clients
26 cleanup_mount $MOUNT
27 # lustre client used as samba server (default is mds node)
28 LUSTRE_CLIENT_SMBSRV=${LUSTRE_CLIENT_SMBSRV:-$(facet_active_host $SINGLEMDS)}
29 SMBSHARE=${SMBSHARE:-lustretest}
30 SMBUSER=${SMBUSER:-root}
31 SMBPASSWD=${SMBPASSWD:-lustre}
32 SMBSRVMNTPT=${SMBSRVMNTPT:-$MOUNT}
33 SMBCLIMNTPT=${SMBCLIMNTPT:-$MOUNT}
34 SMBCLIENTS=${SMBCLIENTS:-$CLIENTS}
35 SMBCLIENTS=$(exclude_items_from_list $SMBCLIENTS $LUSTRE_CLIENT_SMBSRV)
36
37 [ -z "$SMBCLIENTS" ] &&
38         skip_env "need at least two nodes: samba server and samba client"
39
40 # set CONFIGURE_SMB=false to skip smb config
41 CONFIGURE_SMB=${CONFIGURE_SMB:-true}
42
43 # store smb status to restart smb service if it was running initially
44 SMBSTATUS=0
45 smb_status $LUSTRE_CLIENT_SMBSRV || SMBSTATUS=$?
46 SMBCONFTMP=$(do_node $LUSTRE_CLIENT_SMBSRV "mktemp -t smb.conf.XXX")
47
48 cleanup_exit() {
49         trap 0
50         cleanup
51         check_and_cleanup_lustre
52         exit
53 }
54
55 cleanup() {
56         cleanup_cifs $LUSTRE_CLIENT_SMBSRV $SMBCLIMNTPT $SMBCLIENTS ||
57                 error_noexit false "failed to cleanup cifs"
58         zconf_umount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT force ||
59                 error_noexit false "failed to umount lustre on $LUSTRE_CLIENT_SMBSRV"
60         # restore lustre mount
61         restore_mount $MOUNT ||
62                 error_noexit false "failed to mount lustre"
63
64         $CONFIGURE_SMB && restore_config_smb $LUSTRE_CLIENT_SMBSRV $SMBCONFTMP
65         [[ $SMBSTATUS -eq 0 ]] &&
66                 do_node $LUSTRE_CLIENT_SMBSRV "service smb start"
67         unset CIFSCLIENT
68 }
69
70 $CONFIGURE_SMB && configure_smb $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBUSER \
71                 $SMBPASSWD $SMBSRVMNTPT $SMBCONFTMP ||
72         echo -e "\nSkipping smb config ..."
73
74 trap cleanup_exit EXIT SIGHUP SIGINT
75
76 # mount lustre client on smb server
77 zconf_mount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT ||
78         error "mount lustre on $LUSTRE_CLIENT_SMBSRV failed"
79
80 # setup the cifs
81 setup_cifs $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBCLIMNTPT $SMBUSER \
82                 $SMBPASSWD $SMBCLIENTS ||
83         error false "setup cifs failed"
84
85 CIFSCLIENT=yes
86 FAIL_ON_ERROR=false
87
88 # compilbench
89 # Run short iteration in cifs mode
90 cbench_IDIRS=${cbench_IDIRS:-2}
91 cbench_RUNS=${cbench_RUNS:-2}
92
93 # source the common file after all parameters are set to take effect
94 . $LUSTRE/tests/functions.sh
95
96 build_test_filter
97
98 check_prog_output() {
99         local clients=$1
100         local file=$2
101         local str=$3
102
103         do_nodes $clients grep -q \\\"$str\\\" $file 2>/dev/null
104 }
105
106 wait_prog_output() {
107         local clients=$1
108         local file=$2
109         local str=$3
110         local time=$4
111         local start_ts=$(date +%s)
112         local elapsed
113
114         while ! check_prog_output $clients $file "$str"; do
115                 elapsed=$(($(date +%s) - start_ts))
116                 if [ $elapsed -gt $time ]; then
117                         return 1
118                 fi
119                 sleep 1
120         done
121 }
122
123 test_compilebench() {
124         run_compilebench $SMBCLIMNTPT
125 }
126 run_test compilebench "compilebench on cifs clients"
127
128 test_dbench() {
129         local clients=$SMBCLIENTS
130         local duration=${DBENCH_DURATION:-300}
131         local nproc=${DBENCH_NPROC:-1}
132         local delay=${dbench_STARTDELAY:-120}
133         local log=$TMP/dbench.log
134         local pid=""
135
136         local cmd="rundbench $nproc -t $duration"
137
138         echo "Using: $cmd"
139
140         do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
141                 PATH=\$PATH DBENCH_LIB=$DBENCH_LIB \
142                 TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
143                 DIR=$SMBCLIMNTPT/$tdir/\\\$(hostname) \
144                 LCTL=$LCTL $cmd 2>&1 | tee $log; \
145                 exit \\\${PIPESTATUS[0]}" &
146         pid=$!
147
148         # check that dbench is started on all clients after
149         # $dbench_STARTDELAY: the dbench log on each client
150         # is to be started for this moment and contain "dbench PID";
151         if ! wait_prog_output $clients $log "dbench PID" $delay; then
152                 kill -s TERM $pid
153                 killall_process $clients dbench
154                 error "dbench failed to start on $clients!"
155         fi
156
157         log "Started rundbench load pid=$pid ..."
158         wait $pid || error "rundbench load on $clients failed!"
159 }
160 run_test dbench "dbench on cifs clients"
161
162 test_fsx() {
163         local clients=$SMBCLIENTS
164         local seed=${fsx_SEED:-$RANDOM}
165         local size=${fsx_SIZE:-1024}
166         local numop=${fsx_NUMOP:-100000}
167         local delay=${fsx_STARTDELAY:-120}
168         local log=$TMP/fsx.log
169         local pid=""
170
171         local nclients=$(get_node_count ${clients//,/ })
172         local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }')
173         [ $space -lt $((size * nclients)) ] && size=$((space * 3 / 4 / nclients))
174
175         local cmd="$FSX -c 50 -p 500 -S $seed -P $TMP -l $size -N $numop "
176
177         echo "Using: $cmd"
178
179         do_nodesv $clients "set -x; \
180                 PATH=\$PATH \
181                 $cmd $SMBCLIMNTPT/f0.fsx_\\\$(hostname) 2>&1 | tee $log; \
182                 exit \\\${PIPESTATUS[0]}" &
183         pid=$!
184
185         # check that fsx is started on all clients after
186         # $fsx_STARTDELAY: the fsx log on each client
187         # is to be started for this moment and contain "Seed set";
188         if ! wait_prog_output $clients $log "Seed set" $delay; then
189                 kill -s TERM $pid
190                 killall_process $clients fsx
191                 error "fsx failed to start on $clients!"
192         fi
193
194         log "Started fsx load pid=$pid ..."
195         wait $pid || error "fsx load on $clients failed!"
196 }
197 run_test fsx "fsx on cifs clients"
198
199 test_iozone() {
200         local clients=$SMBCLIENTS
201         local size=${iozone_SIZE:-262144} # 256m
202         local delay=${iozone_STARTDELAY:-120}
203         local log=$TMP/iozone.log
204         local pid=""
205
206         local nclients=$(get_node_count ${clients//,/ })
207
208         local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }')
209
210         [[ $((size * nclients)) -gt $((space * 3 / 4)) ]] &&
211                 size=$((space * 3 / 4 / nclients))
212
213         do_node $LUSTRE_CLIENT_SMBSRV "mkdir $SMBSRVMNTPT/$tdir
214                 lfs setstripe -c -1 $SMBSRVMNTPT/$tdir"
215
216         log "free space: $space Kb, using $size size, $nclients number of clients"
217
218         local cmd="iozone -a -e -+d -s $size "
219
220         echo "Using: $cmd"
221
222         do_nodesv $clients "set -x; \
223                 PATH=\$PATH \
224                 $cmd -f $SMBCLIMNTPT/$tdir/f0.iozone_\\\$(hostname) \
225                 2>&1 | tee $log; exit \\\${PIPESTATUS[0]}" &
226         pid=$!
227
228         # check that iozone is started on all clients after
229         # $iozone_STARTDELAY: the iozone log on each client
230         # is to be started for this moment and contain "Command line used";
231         if ! wait_prog_output $clients $log "Command line used" $delay; then
232                 kill -s TERM $pid
233                 killall_process $clients iozone
234                 error "iozone failed to start on $clients!"
235         fi
236
237         log "Started iozone load pid=$pid ..."
238         wait $pid
239         rc=$?
240         log "Processing iozone log"
241         do_nodesv $clients "tail -1 $log | grep -q complete" || rc=2
242         do_node $LUSTRE_CLIENT_SMBSRV "rm -rf $SMBSRVMNTPT/$tdir"
243         [ $rc -eq 0 ] || error "iozone load on $clients failed! rc=$rc"
244 }
245 run_test iozone "iozone on cifs clients"
246
247 complete $SECONDS
248 exit_status