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