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"
40 # set CONFIGURE_SMB=false to skip smb config
41 CONFIGURE_SMB=${CONFIGURE_SMB:-true}
43 # store smb status to restart smb service if it was running initially
45 smb_status $LUSTRE_CLIENT_SMBSRV || SMBSTATUS=$?
46 SMBCONFTMP=$(do_node $LUSTRE_CLIENT_SMBSRV "mktemp -t smb.conf.XXX")
51 check_and_cleanup_lustre
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"
64 $CONFIGURE_SMB && restore_config_smb $LUSTRE_CLIENT_SMBSRV $SMBCONFTMP
65 [[ $SMBSTATUS -eq 0 ]] &&
66 do_node $LUSTRE_CLIENT_SMBSRV "service smb start"
70 $CONFIGURE_SMB && configure_smb $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBUSER \
71 $SMBPASSWD $SMBSRVMNTPT $SMBCONFTMP ||
72 echo -e "\nSkipping smb config ..."
74 trap cleanup_exit EXIT SIGHUP SIGINT
76 # mount lustre client on smb server
77 zconf_mount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT ||
78 error "mount lustre on $LUSTRE_CLIENT_SMBSRV failed"
81 setup_cifs $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBCLIMNTPT $SMBUSER \
82 $SMBPASSWD $SMBCLIENTS ||
83 error false "setup cifs failed"
89 # Run short iteration in cifs mode
90 cbench_IDIRS=${cbench_IDIRS:-2}
91 cbench_RUNS=${cbench_RUNS:-2}
93 # source the common file after all parameters are set to take effect
94 . $LUSTRE/tests/functions.sh
103 do_nodes $clients grep -q \\\"$str\\\" $file 2>/dev/null
111 local start_ts=$(date +%s)
114 while ! check_prog_output $clients $file "$str"; do
115 elapsed=$(($(date +%s) - start_ts))
116 if [ $elapsed -gt $time ]; then
123 test_compilebench() {
124 run_compilebench $SMBCLIMNTPT
126 run_test compilebench "compilebench on cifs clients"
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
136 local cmd="rundbench $nproc -t $duration"
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]}" &
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
153 killall_process $clients dbench
154 error "dbench failed to start on $clients!"
157 log "Started rundbench load pid=$pid ..."
158 wait $pid || error "rundbench load on $clients failed!"
160 run_test dbench "dbench on cifs clients"
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
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))
175 local cmd="$FSX -c 50 -p 500 -S $seed -P $TMP -l $size -N $numop "
179 do_nodesv $clients "set -x; \
181 $cmd $SMBCLIMNTPT/f0.fsx_\\\$(hostname) 2>&1 | tee $log; \
182 exit \\\${PIPESTATUS[0]}" &
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
190 killall_process $clients fsx
191 error "fsx failed to start on $clients!"
194 log "Started fsx load pid=$pid ..."
195 wait $pid || error "fsx load on $clients failed!"
197 run_test fsx "fsx on cifs clients"
200 local clients=$SMBCLIENTS
201 local size=${iozone_SIZE:-262144} # 256m
202 local delay=${iozone_STARTDELAY:-120}
203 local log=$TMP/iozone.log
206 local nclients=$(get_node_count ${clients//,/ })
208 local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }')
210 [[ $((size * nclients)) -gt $((space * 3 / 4)) ]] &&
211 size=$((space * 3 / 4 / nclients))
213 do_node $LUSTRE_CLIENT_SMBSRV "mkdir $SMBSRVMNTPT/$tdir
214 lfs setstripe -c -1 $SMBSRVMNTPT/$tdir"
216 log "free space: $space Kb, using $size size, $nclients number of clients"
218 local cmd="iozone -a -e -+d -s $size "
222 do_nodesv $clients "set -x; \
224 $cmd -f $SMBCLIMNTPT/$tdir/f0.iozone_\\\$(hostname) \
225 2>&1 | tee $log; exit \\\${PIPESTATUS[0]}" &
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
233 killall_process $clients iozone
234 error "iozone failed to start on $clients!"
237 log "Started iozone load pid=$pid ..."
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"
245 run_test iozone "iozone on cifs clients"