3 # Requires the pre-configured samba machine
16 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
17 . $LUSTRE/tests/test-framework.sh
19 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
21 . $LUSTRE/tests/setup-cifs.sh
23 check_and_setup_lustre
25 # first unmount all the lustre clients
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)
37 [ -z "$SMBCLIENTS" ] &&
38 skip_env "need at least two nodes: samba server and samba client" &&
41 # set CONFIGURE_SMB=false to skip smb config
42 CONFIGURE_SMB=${CONFIGURE_SMB:-true}
44 # store smb status to restart smb service if it was running initially
46 smb_status $LUSTRE_CLIENT_SMBSRV || SMBSTATUS=$?
47 SMBCONFTMP=$(do_node $LUSTRE_CLIENT_SMBSRV "mktemp -t smb.conf.XXX")
52 check_and_cleanup_lustre
57 cleanup_cifs $LUSTRE_CLIENT_SMBSRV $SMBCLIMNTPT $SMBCLIENTS ||
58 error_noexit false "failed to cleanup cifs"
59 zconf_umount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT force ||
60 error_noexit false "failed to umount lustre on $LUSTRE_CLIENT_SMBSRV"
61 # restore lustre mount
62 restore_mount $MOUNT ||
63 error_noexit false "failed to mount lustre"
65 $CONFIGURE_SMB && restore_config_smb $LUSTRE_CLIENT_SMBSRV $SMBCONFTMP
66 [[ $SMBSTATUS -eq 0 ]] &&
67 do_node $LUSTRE_CLIENT_SMBSRV "service smb start"
71 $CONFIGURE_SMB && configure_smb $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBUSER \
72 $SMBPASSWD $SMBSRVMNTPT $SMBCONFTMP ||
73 echo -e "\nSkipping smb config ..."
75 trap cleanup_exit EXIT SIGHUP SIGINT
77 # mount lustre client on smb server
78 zconf_mount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT ||
79 error "mount lustre on $LUSTRE_CLIENT_SMBSRV failed"
82 setup_cifs $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBCLIMNTPT $SMBUSER \
83 $SMBPASSWD $SMBCLIENTS ||
84 error false "setup cifs failed"
90 # Run short iteration in cifs mode
91 cbench_IDIRS=${cbench_IDIRS:-2}
92 cbench_RUNS=${cbench_RUNS:-2}
94 # source the common file after all parameters are set to take effect
95 . $LUSTRE/tests/functions.sh
104 do_nodes $clients grep -q \\\"$str\\\" $file 2>/dev/null
112 local start_ts=$(date +%s)
115 while ! check_prog_output $clients $file "$str"; do
116 elapsed=$(($(date +%s) - start_ts))
117 if [ $elapsed -gt $time ]; then
124 test_compilebench() {
125 run_compilebench $SMBCLIMNTPT
127 run_test compilebench "compilebench on cifs clients"
130 local clients=$SMBCLIENTS
131 local duration=${DBENCH_DURATION:-300}
132 local nproc=${DBENCH_NPROC:-1}
133 local delay=${dbench_STARTDELAY:-120}
134 local log=$TMP/dbench.log
137 local cmd="rundbench $nproc -t $duration"
141 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
142 PATH=\$PATH DBENCH_LIB=$DBENCH_LIB \
143 TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
144 DIR=$SMBCLIMNTPT/$tdir/\\\$(hostname) \
145 LCTL=$LCTL $cmd 2>&1 | tee $log; \
146 exit \\\${PIPESTATUS[0]}" &
149 # check that dbench is started on all clients after
150 # $dbench_STARTDELAY: the dbench log on each client
151 # is to be started for this moment and contain "dbench PID";
152 if ! wait_prog_output $clients $log "dbench PID" $delay; then
154 killall_process $clients dbench
155 error "dbench failed to start on $clients!"
158 log "Started rundbench load pid=$pid ..."
159 wait $pid || error "rundbench load on $clients failed!"
161 run_test dbench "dbench on cifs clients"
164 local clients=$SMBCLIENTS
165 local seed=${fsx_SEED:-$RANDOM}
166 local size=${fsx_SIZE:-1024}
167 local numop=${fsx_NUMOP:-100000}
168 local delay=${fsx_STARTDELAY:-120}
169 local log=$TMP/fsx.log
172 local nclients=$(get_node_count ${clients//,/ })
173 local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }')
174 [ $space -lt $((size * nclients)) ] && size=$((space * 3 / 4 / nclients))
176 local cmd="$FSX -c 50 -p 500 -S $seed -P $TMP -l $size -N $numop "
180 do_nodesv $clients "set -x; \
182 $cmd $SMBCLIMNTPT/f0.fsx_\\\$(hostname) 2>&1 | tee $log; \
183 exit \\\${PIPESTATUS[0]}" &
186 # check that fsx is started on all clients after
187 # $fsx_STARTDELAY: the fsx log on each client
188 # is to be started for this moment and contain "Seed set";
189 if ! wait_prog_output $clients $log "Seed set" $delay; then
191 killall_process $clients fsx
192 error "fsx failed to start on $clients!"
195 log "Started fsx load pid=$pid ..."
196 wait $pid || error "fsx load on $clients failed!"
198 run_test fsx "fsx on cifs clients"
201 local clients=$SMBCLIENTS
202 local size=${iozone_SIZE:-262144} # 256m
203 local delay=${iozone_STARTDELAY:-120}
204 local log=$TMP/iozone.log
207 local nclients=$(get_node_count ${clients//,/ })
209 local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }')
211 [[ $((size * nclients)) -gt $((space * 3 / 4)) ]] &&
212 size=$((space * 3 / 4 / nclients))
214 do_node $LUSTRE_CLIENT_SMBSRV "mkdir $SMBSRVMNTPT/$tdir
215 lfs setstripe -c -1 $SMBSRVMNTPT/$tdir"
217 log "free space: $space Kb, using $size size, $nclients number of clients"
219 local cmd="iozone -a -e -+d -s $size "
223 do_nodesv $clients "set -x; \
225 $cmd -f $SMBCLIMNTPT/$tdir/f0.iozone_\\\$(hostname) \
226 2>&1 | tee $log; exit \\\${PIPESTATUS[0]}" &
229 # check that iozone is started on all clients after
230 # $iozone_STARTDELAY: the iozone log on each client
231 # is to be started for this moment and contain "Command line used";
232 if ! wait_prog_output $clients $log "Command line used" $delay; then
234 killall_process $clients iozone
235 error "iozone failed to start on $clients!"
238 log "Started iozone load pid=$pid ..."
241 log "Processing iozone log"
242 do_nodesv $clients "tail -1 $log | grep -q complete" || rc=2
243 do_node $LUSTRE_CLIENT_SMBSRV "rm -rf $SMBSRVMNTPT/$tdir"
244 [ $rc -eq 0 ] || error "iozone load on $clients failed! rc=$rc"
246 run_test iozone "iozone on cifs clients"