Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[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         exit 0
40
41 # set CONFIGURE_SMB=false to skip smb config
42 CONFIGURE_SMB=${CONFIGURE_SMB:-true}
43
44 # store smb status to restart smb service if it was running initially
45 SMBSTATUS=0
46 smb_status $LUSTRE_CLIENT_SMBSRV || SMBSTATUS=$?
47 SMBCONFTMP=$(do_node $LUSTRE_CLIENT_SMBSRV "mktemp -t smb.conf.XXX")
48
49 cleanup_exit() {
50         trap 0
51         cleanup
52         check_and_cleanup_lustre
53         exit
54 }
55
56 cleanup() {
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"
64
65         $CONFIGURE_SMB && restore_config_smb $LUSTRE_CLIENT_SMBSRV $SMBCONFTMP
66         [[ $SMBSTATUS -eq 0 ]] &&
67                 do_node $LUSTRE_CLIENT_SMBSRV "service smb start"
68         unset CIFSCLIENT
69 }
70
71 $CONFIGURE_SMB && configure_smb $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBUSER \
72                 $SMBPASSWD $SMBSRVMNTPT $SMBCONFTMP ||
73         echo -e "\nSkipping smb config ..."
74
75 trap cleanup_exit EXIT SIGHUP SIGINT
76
77 # mount lustre client on smb server
78 zconf_mount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT ||
79         error "mount lustre on $LUSTRE_CLIENT_SMBSRV failed"
80
81 # setup the cifs
82 setup_cifs $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBCLIMNTPT $SMBUSER \
83                 $SMBPASSWD $SMBCLIENTS ||
84         error false "setup cifs failed"
85
86 CIFSCLIENT=yes
87 FAIL_ON_ERROR=false
88
89 # compilbench
90 # Run short iteration in cifs mode
91 cbench_IDIRS=${cbench_IDIRS:-2}
92 cbench_RUNS=${cbench_RUNS:-2}
93
94 # source the common file after all parameters are set to take effect
95 . $LUSTRE/tests/functions.sh
96
97 build_test_filter
98
99 check_prog_output() {
100         local clients=$1
101         local file=$2
102         local str=$3
103
104         do_nodes $clients grep -q \\\"$str\\\" $file 2>/dev/null
105 }
106
107 wait_prog_output() {
108         local clients=$1
109         local file=$2
110         local str=$3
111         local time=$4
112         local start_ts=$(date +%s)
113         local elapsed
114
115         while ! check_prog_output $clients $file "$str"; do
116                 elapsed=$(($(date +%s) - start_ts))
117                 if [ $elapsed -gt $time ]; then
118                         return 1
119                 fi
120                 sleep 1
121         done
122 }
123
124 test_compilebench() {
125         run_compilebench $SMBCLIMNTPT
126 }
127 run_test compilebench "compilebench on cifs clients"
128
129 test_dbench() {
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
135         local pid=""
136
137         local cmd="rundbench $nproc -t $duration"
138
139         echo "Using: $cmd"
140
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]}" &
147         pid=$!
148
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
153                 kill -s TERM $pid
154                 killall_process $clients dbench
155                 error "dbench failed to start on $clients!"
156         fi
157
158         log "Started rundbench load pid=$pid ..."
159         wait $pid || error "rundbench load on $clients failed!"
160 }
161 run_test dbench "dbench on cifs clients"
162
163 test_fsx() {
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
170         local pid=""
171
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))
175
176         local cmd="$FSX -c 50 -p 500 -S $seed -P $TMP -l $size -N $numop "
177
178         echo "Using: $cmd"
179
180         do_nodesv $clients "set -x; \
181                 PATH=\$PATH \
182                 $cmd $SMBCLIMNTPT/f0.fsx_\\\$(hostname) 2>&1 | tee $log; \
183                 exit \\\${PIPESTATUS[0]}" &
184         pid=$!
185
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
190                 kill -s TERM $pid
191                 killall_process $clients fsx
192                 error "fsx failed to start on $clients!"
193         fi
194
195         log "Started fsx load pid=$pid ..."
196         wait $pid || error "fsx load on $clients failed!"
197 }
198 run_test fsx "fsx on cifs clients"
199
200 test_iozone() {
201         local clients=$SMBCLIENTS
202         local size=${iozone_SIZE:-262144} # 256m
203         local delay=${iozone_STARTDELAY:-120}
204         local log=$TMP/iozone.log
205         local pid=""
206
207         local nclients=$(get_node_count ${clients//,/ })
208
209         local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }')
210
211         [[ $((size * nclients)) -gt $((space * 3 / 4)) ]] &&
212                 size=$((space * 3 / 4 / nclients))
213
214         log "free space: $space Kb, using $size size, $nclients number of clients"
215
216         local cmd="iozone -a -e -+d -s $size "
217
218         echo "Using: $cmd"
219
220         do_nodesv $clients "set -x; \
221                 PATH=\$PATH \
222                 $cmd -f $SMBCLIMNTPT/f0.iozone_\\\$(hostname) 2>&1 | tee $log; \
223                 exit \\\${PIPESTATUS[0]}" &
224         pid=$!
225
226         # check that iozone is started on all clients after
227         # $iozone_STARTDELAY: the iozone log on each client
228         # is to be started for this moment and contain "Command line used";
229         if ! wait_prog_output $clients $log "Command line used" $delay; then
230                 kill -s TERM $pid
231                 killall_process $clients iozone
232                 error "iozone failed to start on $clients!"
233         fi
234
235         log "Started iozone load pid=$pid ..."
236         wait $pid
237         rc=$?
238         log "Processing iozone log"
239         do_nodesv $clients "tail -1 $log | grep -q complete" || rc=2
240         [ $rc -eq 0 ] || error "iozone load on $clients failed! rc=$rc"
241 }
242 run_test iozone "iozone on cifs clients"
243
244 complete $SECONDS
245 exit_status