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