michael@0: #! /bin/bash michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ######################################################################## michael@0: # michael@0: # mozilla/security/nss/tests/ssl/ssl_dist_stress.sh michael@0: # michael@0: # Script to test NSS SSL - distributed stresstest - this script needs to michael@0: # source the regular ssl.sh (for shellfunctions, certs and variables michael@0: # initialisation) michael@0: # create certs michael@0: # start server michael@0: # start itself via rsh on different systems to connect back to the server michael@0: # michael@0: # michael@0: # needs to work on all Unix and Windows platforms michael@0: # michael@0: # special strings michael@0: # --------------- michael@0: # FIXME ... known problems, search for this string michael@0: # NOTE .... unexpected behavior michael@0: # michael@0: ######################################################################## michael@0: michael@0: ############################## ssl_ds_init ############################# michael@0: # local shell function to initialize this script michael@0: ######################################################################## michael@0: ssl_ds_init() michael@0: { michael@0: if [ -z "$GLOB_MIN_CERT" ] ; then michael@0: GLOB_MIN_CERT=0 michael@0: fi michael@0: if [ -z "$GLOB_MAX_CERT" ] ; then michael@0: GLOB_MAX_CERT=200 michael@0: fi michael@0: IP_PARAM="" michael@0: CD_QADIR_SSL="" michael@0: michael@0: michael@0: if [ -n "$1" ] ; then michael@0: ssl_ds_eval_opts $* michael@0: fi michael@0: SCRIPTNAME=ssl_dist_stress.sh # sourced - $0 would point to all.sh michael@0: michael@0: if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for michael@0: CLEANUP="${SCRIPTNAME}" # cleaning this script will do it michael@0: fi michael@0: michael@0: ssl_init # let some other script do the hard work (initialize, generate certs, ... michael@0: michael@0: SCRIPTNAME=ssl_dist_stress.sh michael@0: echo "$SCRIPTNAME: SSL distributed stress tests ===============================" michael@0: michael@0: } michael@0: michael@0: ######################### ssl_ds_usage ################################# michael@0: # local shell function to explain the usage michael@0: ######################################################################## michael@0: ssl_ds_usage() michael@0: { michael@0: echo "Usage: `basename $1`" michael@0: echo " -host hostname " michael@0: echo " ...host who runs the server, for distributed stress test" michael@0: echo " -stress " michael@0: echo " ...runs the server sider of the distributed stress test" michael@0: echo " -dir unixdirectory " michael@0: echo " ...lets the server side of the distributed stress test" michael@0: echo " know where to find the scritp to start on the remote side" michael@0: echo " -certnum start-end" michael@0: echo " ... provides the range of certs for distributed stress test" michael@0: echo " for example -certnum 10-20 will connect 10 times" michael@0: echo " no blanks in the range string (not 10 - 20)" michael@0: echo " valid range ${GLOB_MIN_CERT}-${GLOB_MAX_CERT}" michael@0: echo " -? ...prints this text" michael@0: exit 1 #does not need to be Exit, very early in script michael@0: } michael@0: michael@0: ######################### ssl_ds_eval_opts ############################# michael@0: # local shell function to deal with options and parameters michael@0: ######################################################################## michael@0: ssl_ds_eval_opts() michael@0: { michael@0: #use $0 not $SCRIPTNAM/dev/null || CLIENT_OK="FALSE" michael@0: if [ "$CLIENT_OK" = "FALSE" ] ; then michael@0: echo "$SCRIPTNAME `uname -n`: $client can't be reached - skipping" michael@0: else michael@0: get_certrange $number michael@0: echo "$SCRIPTNAME `uname -n`: $RSH $client -l svbld \\ " michael@0: echo " \" $CD_QADIR_SSL ;ssl_dist_stress.sh \\" michael@0: echo " -host $HOST -certnum $CERTRANGE $IP_PARAM \" " michael@0: $RSH $client -l svbld \ michael@0: " $CD_QADIR_SSL;ssl_dist_stress.sh -host $HOST -certnum $CERTRANGE $IP_PARAM " & michael@0: fi michael@0: done michael@0: michael@0: echo cd "${CLIENTDIR}" michael@0: cd "${CLIENTDIR}" michael@0: michael@0: sleep 500 # give the clients time to finish #FIXME ADJUST michael@0: michael@0: echo "GET /stop HTTP/1.0\n\n" > stdin.txt #check to make sure it has /r/n michael@0: echo "tstclnt -h $HOSTADDR -p 8443 -d ${P_R_CLIENTDIR} -n TestUser0 " michael@0: echo " -w nss -f < stdin.txt" michael@0: ${BINDIR}/tstclnt -h $HOSTADDR -p 8443 -d ${P_R_CLIENTDIR} -n TestUser0 \ michael@0: -w nss -f < stdin.txt michael@0: michael@0: html_msg 0 0 "${testname}" michael@0: html "
" michael@0: } michael@0: michael@0: ############################ get_certrange ############################# michael@0: # local shell function to find the range of certs that the next remote michael@0: # client is supposed to use (only for server side of the dist stress test michael@0: ######################################################################## michael@0: get_certrange() michael@0: { michael@0: rangeOK=`echo $1 | sed -e 's/[0-9][0-9]*/OK/'` michael@0: if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o $1 = "OK" ] ; then michael@0: range=10 michael@0: echo "$SCRIPTNAME `uname -n`: $1 is not a valid number of certs " michael@0: echo " defaulting to 10 for $client" michael@0: else michael@0: range=$1 michael@0: if [ $range -gt $GLOB_MAX_CERT ] ; then michael@0: range=$GLOB_MAX_CERT michael@0: fi michael@0: fi michael@0: if [ -z "$FROM_CERT" ] ; then # start new on top of the cert stack michael@0: FROM_CERT=$GLOB_MAX_CERT michael@0: elif [ `expr $FROM_CERT - $range + 1 ` -lt 0 ] ; then michael@0: FROM_CERT=$GLOB_MAX_CERT # dont let it fall below 0 on the TO_CERT michael@0: michael@0: fi michael@0: TO_CERT=`expr $FROM_CERT - $range + 1 ` michael@0: if [ $TO_CERT -lt 0 ] ; then # it's not that I'm bad in math, I just michael@0: TO_CERT=0 # don't trust expr... michael@0: fi michael@0: CERTRANGE="${TO_CERT}-${FROM_CERT}" michael@0: FROM_CERT=`expr ${TO_CERT} - 1 ` #start the next client one below michael@0: } michael@0: michael@0: michael@0: ################## main ################################################# michael@0: michael@0: DO_DIST_ST="TRUE" michael@0: . ./ssl.sh michael@0: ssl_ds_init $* michael@0: if [ -n "$DO_REM_ST" -a "$DO_REM_ST" = "TRUE" ] ; then michael@0: ssl_ds_rem_stress michael@0: exit 0 #no cleanup on purpose michael@0: elif [ -n "$DO_DIST_ST" -a "$DO_DIST_ST" = "TRUE" ] ; then michael@0: ssl_ds_dist_stress michael@0: fi michael@0: ssl_cleanup