diff --git a/security/nss/tests/ssl/ssl_dist_stress.sh b/security/nss/tests/ssl/ssl_dist_stress.sh index f640b584dfe..03e5208da04 100755 --- a/security/nss/tests/ssl/ssl_dist_stress.sh +++ b/security/nss/tests/ssl/ssl_dist_stress.sh @@ -1,343 +1,344 @@ -#! /bin/sh -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape security libraries. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1994-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# -# -######################################################################## -# -# mozilla/security/nss/tests/ssl/ssl_dist_stress.sh -# -# Script to test NSS SSL - distributed stresstest - this script needs to -# source the regular ssl.sh (for shellfunctions, certs and variables -# initialisation) -# create certs -# start server -# start itself via rsh on different systems to connect back to the server -# -# -# needs to work on all Unix and Windows platforms -# -# special strings -# --------------- -# FIXME ... known problems, search for this string -# NOTE .... unexpected behavior -# -# FIXME _ don't know yet how long to wait until the server needs to be killed -# especially on NT -# -######################################################################## - -############################## ssl_ds_init ############################# -# local shell function to initialize this script -######################################################################## -ssl_ds_init() -{ - if [ -z "$GLOB_MIN_CERT" ] ; then - GLOB_MIN_CERT=0 - fi - if [ -z "$GLOB_MAX_CERT" ] ; then - GLOB_MAX_CERT=200 - fi - IP_PARAM="" - CD_QADIR_SSL="" - - - if [ -n "$1" ] ; then - ssl_ds_eval_opts $* - fi - SCRIPTNAME=ssl_dist_stress.sh # sourced - $0 would point to all.sh - - if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for - CLEANUP="${SCRIPTNAME}" # cleaning this script will do it - fi - - ssl_init # let some other script do the hard work (initialize, generate certs, ... - - SCRIPTNAME=ssl_dist_stress.sh - echo "$SCRIPTNAME: SSL distributed stress tests ===============================" - -} - -######################### ssl_ds_usage ################################# -# local shell function to explain the usage -######################################################################## -ssl_ds_usage() -{ - echo "Usage: `basename $1`" - echo " -host hostname " - echo " ...host who runs the server, for distributed stress test" - echo " -stress " - echo " ...runs the server sider of the distributed stress test" - echo " -dir unixdirectory " - echo " ...lets the server side of the distributed stress test" - echo " know where to find the scritp to start on the remote side" - echo " -certnum start-end" - echo " ... provides the range of certs for distributed stress test" - echo " for example -certnum 10-20 will connect 10 times" - echo " no blanks in the range string (not 10 - 20)" - echo " valid range ${GLOB_MIN_CERT}-${GLOB_MAX_CERT}" - echo " -? ...prints this text" - exit 1 #does not need to be Exit, very early in script -} - -######################### ssl_ds_eval_opts ############################# -# local shell function to deal with options and parameters -######################################################################## -ssl_ds_eval_opts() -{ - #use $0 not $SCRIPTNAM/dev/null || CLIENT_OK="FALSE" - if [ "$CLIENT_OK" = "FALSE" ] ; then - echo "$SCRIPTNAME `uname -n`: $client can't be reached - skipping" - else - get_certrange $number - echo "$SCRIPTNAME `uname -n`: $RSH $client -l svbld \\ " - echo " \" $CD_QADIR_SSL ;ssl_dist_stress.sh \\" - echo " -host $HOST -certnum $CERTRANGE $IP_PARAM \" " - $RSH $client -l svbld \ - " $CD_QADIR_SSL;ssl_dist_stress.sh -host $HOST -certnum $CERTRANGE $IP_PARAM " & - fi - done - - echo cd "${CLIENTDIR}" - cd "${CLIENTDIR}" - - sleep 600 # give the clients time to finish #FIXME ADJUST - - echo "GET /stop HTTP/1.0\n\n" > stdin.txt #check to make sure it has /r/n - echo "tstclnt -h $HOSTADDR -p 8443 -d ${CLIENTDIR} -n TestUser0 " - echo " -w nss -f < stdin.txt" - tstclnt -h $HOSTADDR -p 8443 -d ${CLIENTDIR} -n TestUser0 \ - -w nss -f < stdin.txt - - html_msg 0 0 "${testname}" - html "
" -} - -############################ get_certrange ############################# -# local shell function to find the range of certs that the next remote -# client is supposed to use (only for server side of the dist stress test -######################################################################## -get_certrange() -{ - rangeOK=`echo $1 | sed -e 's/[0-9][0-9]*/OK/'` - if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o $1 = "OK" ] ; then - range=10 - echo "$SCRIPTNAME `uname -n`: $1 is not a valid number of certs " - echo " defaulting to 10 for $client" - else - range=$1 - if [ $range -gt $GLOB_MAX_CERT ] ; then - range=$GLOB_MAX_CERT - fi - fi - if [ -z "$FROM_CERT" ] ; then # start new on top of the cert stack - FROM_CERT=$GLOB_MAX_CERT - elif [ `expr $FROM_CERT - $range + 1 ` -lt 0 ] ; then - FROM_CERT=$GLOB_MAX_CERT # dont let it fall below 0 on the TO_CERT - - fi - TO_CERT=`expr $FROM_CERT - $range + 1 ` - if [ $TO_CERT -lt 0 ] ; then # it's not that I'm bad in math, I just - TO_CERT=0 # don't trust expr... - fi - CERTRANGE="${TO_CERT}-${FROM_CERT}" - FROM_CERT=`expr ${TO_CERT} - 1 ` #start the next client one below -} - - -################## main ################################################# - -DO_DIST_ST="TRUE" -. ssl.sh -ssl_ds_init $* -if [ -n "$DO_REM_ST" -a "$DO_REM_ST" = "TRUE" ] ; then - ssl_ds_rem_stress - exit 0 #no cleanup on purpose -elif [ -n "$DO_DIST_ST" -a "$DO_DIST_ST" = "TRUE" ] ; then - ssl_ds_dist_stress -fi -ssl_cleanup +#! /bin/sh +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# +######################################################################## +# +# mozilla/security/nss/tests/ssl/ssl_dist_stress.sh +# +# Script to test NSS SSL - distributed stresstest - this script needs to +# source the regular ssl.sh (for shellfunctions, certs and variables +# initialisation) +# create certs +# start server +# start itself via rsh on different systems to connect back to the server +# +# +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +# FIXME _ don't know yet how long to wait until the server needs to be killed +# especially on NT +# +######################################################################## + +############################## ssl_ds_init ############################# +# local shell function to initialize this script +######################################################################## +ssl_ds_init() +{ + if [ -z "$GLOB_MIN_CERT" ] ; then + GLOB_MIN_CERT=0 + fi + if [ -z "$GLOB_MAX_CERT" ] ; then + GLOB_MAX_CERT=200 + fi + IP_PARAM="" + CD_QADIR_SSL="" + + + if [ -n "$1" ] ; then + ssl_ds_eval_opts $* + fi + SCRIPTNAME=ssl_dist_stress.sh # sourced - $0 would point to all.sh + + if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for + CLEANUP="${SCRIPTNAME}" # cleaning this script will do it + fi + + ssl_init # let some other script do the hard work (initialize, generate certs, ... + + SCRIPTNAME=ssl_dist_stress.sh + echo "$SCRIPTNAME: SSL distributed stress tests ===============================" + +} + +######################### ssl_ds_usage ################################# +# local shell function to explain the usage +######################################################################## +ssl_ds_usage() +{ + echo "Usage: `basename $1`" + echo " -host hostname " + echo " ...host who runs the server, for distributed stress test" + echo " -stress " + echo " ...runs the server sider of the distributed stress test" + echo " -dir unixdirectory " + echo " ...lets the server side of the distributed stress test" + echo " know where to find the scritp to start on the remote side" + echo " -certnum start-end" + echo " ... provides the range of certs for distributed stress test" + echo " for example -certnum 10-20 will connect 10 times" + echo " no blanks in the range string (not 10 - 20)" + echo " valid range ${GLOB_MIN_CERT}-${GLOB_MAX_CERT}" + echo " -? ...prints this text" + exit 1 #does not need to be Exit, very early in script +} + +######################### ssl_ds_eval_opts ############################# +# local shell function to deal with options and parameters +######################################################################## +ssl_ds_eval_opts() +{ + #use $0 not $SCRIPTNAM/dev/null || CLIENT_OK="FALSE" + if [ "$CLIENT_OK" = "FALSE" ] ; then + echo "$SCRIPTNAME `uname -n`: $client can't be reached - skipping" + else + get_certrange $number + echo "$SCRIPTNAME `uname -n`: $RSH $client -l svbld \\ " + echo " \" $CD_QADIR_SSL ;ssl_dist_stress.sh \\" + echo " -host $HOST -certnum $CERTRANGE $IP_PARAM \" " + $RSH $client -l svbld \ + " $CD_QADIR_SSL;ssl_dist_stress.sh -host $HOST -certnum $CERTRANGE $IP_PARAM " & + fi + done + + echo cd "${CLIENTDIR}" + cd "${CLIENTDIR}" + + sleep 500 # give the clients time to finish #FIXME ADJUST + + echo "GET /stop HTTP/1.0\n\n" > stdin.txt #check to make sure it has /r/n + echo "tstclnt -h $HOSTADDR -p 8443 -d ${CLIENTDIR} -n TestUser0 " + echo " -w nss -f < stdin.txt" + tstclnt -h $HOSTADDR -p 8443 -d ${CLIENTDIR} -n TestUser0 \ + -w nss -f < stdin.txt + + html_msg 0 0 "${testname}" + html "
" +} + +############################ get_certrange ############################# +# local shell function to find the range of certs that the next remote +# client is supposed to use (only for server side of the dist stress test +######################################################################## +get_certrange() +{ + rangeOK=`echo $1 | sed -e 's/[0-9][0-9]*/OK/'` + if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o $1 = "OK" ] ; then + range=10 + echo "$SCRIPTNAME `uname -n`: $1 is not a valid number of certs " + echo " defaulting to 10 for $client" + else + range=$1 + if [ $range -gt $GLOB_MAX_CERT ] ; then + range=$GLOB_MAX_CERT + fi + fi + if [ -z "$FROM_CERT" ] ; then # start new on top of the cert stack + FROM_CERT=$GLOB_MAX_CERT + elif [ `expr $FROM_CERT - $range + 1 ` -lt 0 ] ; then + FROM_CERT=$GLOB_MAX_CERT # dont let it fall below 0 on the TO_CERT + + fi + TO_CERT=`expr $FROM_CERT - $range + 1 ` + if [ $TO_CERT -lt 0 ] ; then # it's not that I'm bad in math, I just + TO_CERT=0 # don't trust expr... + fi + CERTRANGE="${TO_CERT}-${FROM_CERT}" + FROM_CERT=`expr ${TO_CERT} - 1 ` #start the next client one below +} + + +################## main ################################################# + +DO_DIST_ST="TRUE" +. ssl.sh +ssl_ds_init $* +if [ -n "$DO_REM_ST" -a "$DO_REM_ST" = "TRUE" ] ; then + ssl_ds_rem_stress + exit 0 #no cleanup on purpose +elif [ -n "$DO_DIST_ST" -a "$DO_DIST_ST" = "TRUE" ] ; then + ssl_ds_dist_stress +fi +ssl_cleanup