|
1 #! /bin/bash |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 |
|
7 ######################################################################## |
|
8 # |
|
9 # mozilla/security/nss/tests/ssl/ssl_dist_stress.sh |
|
10 # |
|
11 # Script to test NSS SSL - distributed stresstest - this script needs to |
|
12 # source the regular ssl.sh (for shellfunctions, certs and variables |
|
13 # initialisation) |
|
14 # create certs |
|
15 # start server |
|
16 # start itself via rsh on different systems to connect back to the server |
|
17 # |
|
18 # |
|
19 # needs to work on all Unix and Windows platforms |
|
20 # |
|
21 # special strings |
|
22 # --------------- |
|
23 # FIXME ... known problems, search for this string |
|
24 # NOTE .... unexpected behavior |
|
25 # |
|
26 ######################################################################## |
|
27 |
|
28 ############################## ssl_ds_init ############################# |
|
29 # local shell function to initialize this script |
|
30 ######################################################################## |
|
31 ssl_ds_init() |
|
32 { |
|
33 if [ -z "$GLOB_MIN_CERT" ] ; then |
|
34 GLOB_MIN_CERT=0 |
|
35 fi |
|
36 if [ -z "$GLOB_MAX_CERT" ] ; then |
|
37 GLOB_MAX_CERT=200 |
|
38 fi |
|
39 IP_PARAM="" |
|
40 CD_QADIR_SSL="" |
|
41 |
|
42 |
|
43 if [ -n "$1" ] ; then |
|
44 ssl_ds_eval_opts $* |
|
45 fi |
|
46 SCRIPTNAME=ssl_dist_stress.sh # sourced - $0 would point to all.sh |
|
47 |
|
48 if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for |
|
49 CLEANUP="${SCRIPTNAME}" # cleaning this script will do it |
|
50 fi |
|
51 |
|
52 ssl_init # let some other script do the hard work (initialize, generate certs, ... |
|
53 |
|
54 SCRIPTNAME=ssl_dist_stress.sh |
|
55 echo "$SCRIPTNAME: SSL distributed stress tests ===============================" |
|
56 |
|
57 } |
|
58 |
|
59 ######################### ssl_ds_usage ################################# |
|
60 # local shell function to explain the usage |
|
61 ######################################################################## |
|
62 ssl_ds_usage() |
|
63 { |
|
64 echo "Usage: `basename $1`" |
|
65 echo " -host hostname " |
|
66 echo " ...host who runs the server, for distributed stress test" |
|
67 echo " -stress " |
|
68 echo " ...runs the server sider of the distributed stress test" |
|
69 echo " -dir unixdirectory " |
|
70 echo " ...lets the server side of the distributed stress test" |
|
71 echo " know where to find the scritp to start on the remote side" |
|
72 echo " -certnum start-end" |
|
73 echo " ... provides the range of certs for distributed stress test" |
|
74 echo " for example -certnum 10-20 will connect 10 times" |
|
75 echo " no blanks in the range string (not 10 - 20)" |
|
76 echo " valid range ${GLOB_MIN_CERT}-${GLOB_MAX_CERT}" |
|
77 echo " -? ...prints this text" |
|
78 exit 1 #does not need to be Exit, very early in script |
|
79 } |
|
80 |
|
81 ######################### ssl_ds_eval_opts ############################# |
|
82 # local shell function to deal with options and parameters |
|
83 ######################################################################## |
|
84 ssl_ds_eval_opts() |
|
85 { |
|
86 #use $0 not $SCRIPTNAM<E, too early, SCRIPTNAME not yet set |
|
87 |
|
88 while [ -n "$1" ] |
|
89 do |
|
90 case $1 in |
|
91 -host) |
|
92 BUILD_OPT=1 |
|
93 export BUILD_OPT |
|
94 DO_REM_ST="TRUE" |
|
95 shift |
|
96 SERVERHOST=$1 |
|
97 HOST=$1 |
|
98 if [ -z $SERVERHOST ] ; then |
|
99 echo "$0 `uname -n`: -host requires hostname" |
|
100 ssl_ds_usage |
|
101 fi |
|
102 echo "$0 `uname -n`: host $HOST ($1)" |
|
103 ;; |
|
104 -certn*) |
|
105 shift |
|
106 rangeOK=`echo $1 | sed -e 's/[0-9][0-9]*-[0-9][0-9]*/OK/'` |
|
107 MIN_CERT=`echo $1 | sed -e 's/-[0-9][0-9]*//' -e 's/^00*//'` |
|
108 MAX_CERT=`echo $1 | sed -e 's/[0-9][0-9]*-//' -e 's/^00*//'` |
|
109 if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o \ |
|
110 -z "$MIN_CERT" -o -z "$MAX_CERT" -o \ |
|
111 "$MIN_CERT" -gt "$MAX_CERT" -o \ |
|
112 "$MIN_CERT" -lt "$GLOB_MIN_CERT" -o \ |
|
113 "$MAX_CERT" -gt "$GLOB_MAX_CERT" ] ; then |
|
114 echo "$0 `uname -n`: -certn range not valid" |
|
115 ssl_ds_usage |
|
116 fi |
|
117 echo "$0 `uname -n`: will use certs from $MIN_CERT to $MAX_CERT" |
|
118 ;; |
|
119 -server|-stress|-dist*st*) |
|
120 BUILD_OPT=1 |
|
121 export BUILD_OPT |
|
122 DO_DIST_ST="TRUE" |
|
123 ;; |
|
124 -dir|-unixdir|-uxdir|-qadir) |
|
125 shift |
|
126 UX_DIR=$1 |
|
127 #FIXME - we need a default unixdir |
|
128 if [ -z "$UX_DIR" ] ; then # -o ! -d "$UX_DIR" ] ; then can't do, Win doesn't know... |
|
129 echo "$0 `uname -n`: -dir requires directoryname " |
|
130 ssl_ds_usage |
|
131 fi |
|
132 CD_QADIR_SSL="cd $UX_DIR" |
|
133 ;; |
|
134 -ip*) |
|
135 shift |
|
136 IP_ADDRESS=$1 |
|
137 if [ -z "$IP_ADDRESS" ] ; then |
|
138 echo "$0 `uname -n`: -ip requires ip-address " |
|
139 ssl_ds_usage |
|
140 fi |
|
141 USE_IP=TRUE |
|
142 IP_PARAM="-ip $IP_ADDRESS" |
|
143 ;; |
|
144 -h|-help|"-?"|*) |
|
145 ssl_ds_usage |
|
146 ;; |
|
147 esac |
|
148 shift |
|
149 done |
|
150 } |
|
151 |
|
152 ############################## ssl_ds_rem_stress ####################### |
|
153 # local shell function to perform the client part of the SSL stress test |
|
154 ######################################################################## |
|
155 |
|
156 ssl_ds_rem_stress() |
|
157 { |
|
158 testname="SSL remote part of Stress test (`uname -n`)" |
|
159 echo "$SCRIPTNAME `uname -n`: $testname" |
|
160 |
|
161 #cp -r "${CLIENTDIR}" /tmp/ssl_ds.$$ #FIXME |
|
162 #cd /tmp/ssl_ds.$$ |
|
163 #verbose="-v" |
|
164 |
|
165 cd ${CLIENTDIR} |
|
166 |
|
167 CONTINUE=$MAX_CERT |
|
168 while [ $CONTINUE -ge $MIN_CERT ] |
|
169 do |
|
170 echo "strsclnt -D -p ${PORT} -d ${P_R_CLIENTDIR} -w nss -c 1 $verbose " |
|
171 echo " -n TestUser$CONTINUE ${HOSTADDR} #`uname -n`" |
|
172 ${BINDIR}/strsclnt -D -p ${PORT} -d . -w nss -c 1 $verbose \ |
|
173 -n "TestUser$CONTINUE" ${HOSTADDR} & |
|
174 #${HOSTADDR} & |
|
175 CONTINUE=`expr $CONTINUE - 1 ` |
|
176 #sleep 4 #give process time to start up |
|
177 done |
|
178 |
|
179 html_msg 0 0 "${testname}" #FIXME |
|
180 } |
|
181 |
|
182 ######################### ssl_ds_dist_stress ########################### |
|
183 # local shell function to perform the server part of the new, distributed |
|
184 # SSL stress test |
|
185 ######################################################################## |
|
186 |
|
187 ssl_ds_dist_stress() |
|
188 { |
|
189 max_clientlist=" |
|
190 box-200 |
|
191 washer-200 |
|
192 dryer-200 |
|
193 hornet-50 |
|
194 shabadoo-50 |
|
195 y2sun2-10 |
|
196 galileo-10 |
|
197 shame-10 |
|
198 axilla-10 |
|
199 columbus-10 |
|
200 smarch-10 |
|
201 nugget-10 |
|
202 charm-10 |
|
203 hp64-10 |
|
204 biggayal-10 |
|
205 orville-10 |
|
206 kwyjibo-10 |
|
207 hbombaix-10 |
|
208 raven-10 |
|
209 jordan-10 |
|
210 phaedrus-10 |
|
211 louie-10 |
|
212 trex-10 |
|
213 compaqtor-10" |
|
214 |
|
215 #clientlist=" huey-2 dewey-2 hornet-2 shabadoo-2" #FIXME ADJUST |
|
216 clientlist=" box-200 washer-200 huey-200 dewey-200 hornet-200 shabadoo-200 louie-200" |
|
217 #clientlist=" box-2 huey-2 " |
|
218 #clientlist="washer-200 huey-200 dewey-200 hornet-200 " |
|
219 |
|
220 html_head "SSL Distributed Stress Test" |
|
221 |
|
222 testname="SSL distributed Stress test" |
|
223 |
|
224 echo cd "${CLIENTDIR}" |
|
225 cd "${CLIENTDIR}" |
|
226 if [ -z "CD_QADIR_SSL" ] ; then |
|
227 CD_QADIR_SSL="cd $QADIR/ssl" |
|
228 else |
|
229 cp -r $HOSTDIR $HOSTDIR/../../../../../booboo_Solaris8/mozilla/tests_results/security |
|
230 fi |
|
231 |
|
232 #sparam=" -t 128 -D -r " |
|
233 sparam=" -t 16 -D -r -r -y " |
|
234 start_selfserv |
|
235 |
|
236 for c in $clientlist |
|
237 do |
|
238 client=`echo $c | sed -e "s/-.*//"` |
|
239 number=`echo $c | sed -e "s/.*-//"` |
|
240 CLIENT_OK="TRUE" |
|
241 echo $client |
|
242 ping $client >/dev/null || CLIENT_OK="FALSE" |
|
243 if [ "$CLIENT_OK" = "FALSE" ] ; then |
|
244 echo "$SCRIPTNAME `uname -n`: $client can't be reached - skipping" |
|
245 else |
|
246 get_certrange $number |
|
247 echo "$SCRIPTNAME `uname -n`: $RSH $client -l svbld \\ " |
|
248 echo " \" $CD_QADIR_SSL ;ssl_dist_stress.sh \\" |
|
249 echo " -host $HOST -certnum $CERTRANGE $IP_PARAM \" " |
|
250 $RSH $client -l svbld \ |
|
251 " $CD_QADIR_SSL;ssl_dist_stress.sh -host $HOST -certnum $CERTRANGE $IP_PARAM " & |
|
252 fi |
|
253 done |
|
254 |
|
255 echo cd "${CLIENTDIR}" |
|
256 cd "${CLIENTDIR}" |
|
257 |
|
258 sleep 500 # give the clients time to finish #FIXME ADJUST |
|
259 |
|
260 echo "GET /stop HTTP/1.0\n\n" > stdin.txt #check to make sure it has /r/n |
|
261 echo "tstclnt -h $HOSTADDR -p 8443 -d ${P_R_CLIENTDIR} -n TestUser0 " |
|
262 echo " -w nss -f < stdin.txt" |
|
263 ${BINDIR}/tstclnt -h $HOSTADDR -p 8443 -d ${P_R_CLIENTDIR} -n TestUser0 \ |
|
264 -w nss -f < stdin.txt |
|
265 |
|
266 html_msg 0 0 "${testname}" |
|
267 html "</TABLE><BR>" |
|
268 } |
|
269 |
|
270 ############################ get_certrange ############################# |
|
271 # local shell function to find the range of certs that the next remote |
|
272 # client is supposed to use (only for server side of the dist stress test |
|
273 ######################################################################## |
|
274 get_certrange() |
|
275 { |
|
276 rangeOK=`echo $1 | sed -e 's/[0-9][0-9]*/OK/'` |
|
277 if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o $1 = "OK" ] ; then |
|
278 range=10 |
|
279 echo "$SCRIPTNAME `uname -n`: $1 is not a valid number of certs " |
|
280 echo " defaulting to 10 for $client" |
|
281 else |
|
282 range=$1 |
|
283 if [ $range -gt $GLOB_MAX_CERT ] ; then |
|
284 range=$GLOB_MAX_CERT |
|
285 fi |
|
286 fi |
|
287 if [ -z "$FROM_CERT" ] ; then # start new on top of the cert stack |
|
288 FROM_CERT=$GLOB_MAX_CERT |
|
289 elif [ `expr $FROM_CERT - $range + 1 ` -lt 0 ] ; then |
|
290 FROM_CERT=$GLOB_MAX_CERT # dont let it fall below 0 on the TO_CERT |
|
291 |
|
292 fi |
|
293 TO_CERT=`expr $FROM_CERT - $range + 1 ` |
|
294 if [ $TO_CERT -lt 0 ] ; then # it's not that I'm bad in math, I just |
|
295 TO_CERT=0 # don't trust expr... |
|
296 fi |
|
297 CERTRANGE="${TO_CERT}-${FROM_CERT}" |
|
298 FROM_CERT=`expr ${TO_CERT} - 1 ` #start the next client one below |
|
299 } |
|
300 |
|
301 |
|
302 ################## main ################################################# |
|
303 |
|
304 DO_DIST_ST="TRUE" |
|
305 . ./ssl.sh |
|
306 ssl_ds_init $* |
|
307 if [ -n "$DO_REM_ST" -a "$DO_REM_ST" = "TRUE" ] ; then |
|
308 ssl_ds_rem_stress |
|
309 exit 0 #no cleanup on purpose |
|
310 elif [ -n "$DO_DIST_ST" -a "$DO_DIST_ST" = "TRUE" ] ; then |
|
311 ssl_ds_dist_stress |
|
312 fi |
|
313 ssl_cleanup |