security/nss/tests/ssl/ssl_dist_stress.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/tests/ssl/ssl_dist_stress.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,313 @@
     1.4 +#! /bin/bash
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +########################################################################
    1.11 +#
    1.12 +# mozilla/security/nss/tests/ssl/ssl_dist_stress.sh
    1.13 +#
    1.14 +# Script to test NSS SSL - distributed stresstest - this script needs to 
    1.15 +# source the regular ssl.sh (for shellfunctions, certs and variables 
    1.16 +# initialisation)
    1.17 +# create certs
    1.18 +# start server
    1.19 +# start itself via rsh on different systems to connect back to the server
    1.20 +# 
    1.21 +#
    1.22 +# needs to work on all Unix and Windows platforms
    1.23 +#
    1.24 +# special strings
    1.25 +# ---------------
    1.26 +#   FIXME ... known problems, search for this string
    1.27 +#   NOTE .... unexpected behavior
    1.28 +#
    1.29 +########################################################################
    1.30 +
    1.31 +############################## ssl_ds_init #############################
    1.32 +# local shell function to initialize this script
    1.33 +########################################################################
    1.34 +ssl_ds_init()
    1.35 +{
    1.36 +  if [ -z "$GLOB_MIN_CERT" ] ; then
    1.37 +      GLOB_MIN_CERT=0
    1.38 +  fi
    1.39 +  if [ -z "$GLOB_MAX_CERT" ] ; then
    1.40 +      GLOB_MAX_CERT=200
    1.41 +  fi
    1.42 +  IP_PARAM=""
    1.43 +  CD_QADIR_SSL=""
    1.44 +
    1.45 +
    1.46 +  if [ -n "$1" ] ; then
    1.47 +      ssl_ds_eval_opts $*
    1.48 +  fi
    1.49 +  SCRIPTNAME=ssl_dist_stress.sh      # sourced - $0 would point to all.sh
    1.50 +
    1.51 +  if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
    1.52 +      CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
    1.53 +  fi
    1.54 +  
    1.55 +  ssl_init  # let some other script do the hard work (initialize, generate certs, ...
    1.56 +
    1.57 +  SCRIPTNAME=ssl_dist_stress.sh
    1.58 +  echo "$SCRIPTNAME: SSL distributed stress tests ==============================="
    1.59 +
    1.60 +}
    1.61 +
    1.62 +######################### ssl_ds_usage #################################
    1.63 +# local shell function to explain the usage
    1.64 +########################################################################
    1.65 +ssl_ds_usage()
    1.66 +{
    1.67 +  echo "Usage: `basename $1`"
    1.68 +  echo "        -host hostname "
    1.69 +  echo "           ...host who runs the server, for distributed stress test"
    1.70 +  echo "        -stress "
    1.71 +  echo "           ...runs the server sider of the distributed stress test"
    1.72 +  echo "        -dir unixdirectory "
    1.73 +  echo "           ...lets the server side of the distributed stress test"
    1.74 +  echo "              know where to find the scritp to start on the remote side"
    1.75 +  echo "        -certnum start-end"
    1.76 +  echo "           ... provides the range of certs for distributed stress test"
    1.77 +  echo "               for example -certnum 10-20 will connect 10 times"
    1.78 +  echo "               no blanks in the range string (not 10 - 20)"
    1.79 +  echo "               valid range ${GLOB_MIN_CERT}-${GLOB_MAX_CERT}"
    1.80 +  echo "        -? ...prints this text"
    1.81 +  exit 1 #does not need to be Exit, very early in script
    1.82 +}
    1.83 +
    1.84 +######################### ssl_ds_eval_opts #############################
    1.85 +# local shell function to deal with options and parameters
    1.86 +########################################################################
    1.87 +ssl_ds_eval_opts()
    1.88 +{
    1.89 +    #use $0 not $SCRIPTNAM<E, too early, SCRIPTNAME not yet set
    1.90 +
    1.91 +  while [ -n "$1" ]
    1.92 +  do
    1.93 +    case $1 in
    1.94 +        -host)
    1.95 +            BUILD_OPT=1
    1.96 +            export BUILD_OPT
    1.97 +            DO_REM_ST="TRUE"
    1.98 +            shift
    1.99 +            SERVERHOST=$1
   1.100 +            HOST=$1
   1.101 +            if [ -z $SERVERHOST ] ; then
   1.102 +                echo "$0 `uname -n`: -host requires hostname"
   1.103 +                ssl_ds_usage
   1.104 +            fi
   1.105 +            echo "$0 `uname -n`: host $HOST ($1)"
   1.106 +            ;;
   1.107 +        -certn*)
   1.108 +            shift
   1.109 +            rangeOK=`echo $1  | sed -e 's/[0-9][0-9]*-[0-9][0-9]*/OK/'`
   1.110 +            MIN_CERT=`echo $1 | sed -e 's/-[0-9][0-9]*//' -e 's/^00*//'`
   1.111 +            MAX_CERT=`echo $1 | sed -e 's/[0-9][0-9]*-//' -e 's/^00*//'`
   1.112 +            if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o \
   1.113 +                         -z "$MIN_CERT" -o -z "$MAX_CERT" -o \
   1.114 +                        "$MIN_CERT" -gt "$MAX_CERT" -o \
   1.115 +                        "$MIN_CERT" -lt "$GLOB_MIN_CERT" -o \
   1.116 +                        "$MAX_CERT" -gt "$GLOB_MAX_CERT" ] ; then
   1.117 +                echo "$0 `uname -n`: -certn range not valid"
   1.118 +                ssl_ds_usage
   1.119 +            fi
   1.120 +            echo "$0 `uname -n`: will use certs from $MIN_CERT to $MAX_CERT"
   1.121 +            ;;
   1.122 +        -server|-stress|-dist*st*)
   1.123 +            BUILD_OPT=1
   1.124 +            export BUILD_OPT
   1.125 +            DO_DIST_ST="TRUE"
   1.126 +            ;;
   1.127 +        -dir|-unixdir|-uxdir|-qadir)
   1.128 +            shift
   1.129 +            UX_DIR=$1
   1.130 +	    #FIXME - we need a default unixdir
   1.131 +            if [ -z "$UX_DIR" ] ; then # -o ! -d "$UX_DIR" ] ; then can't do, Win doesn't know...
   1.132 +                echo "$0 `uname -n`: -dir requires directoryname "
   1.133 +                ssl_ds_usage
   1.134 +            fi
   1.135 +            CD_QADIR_SSL="cd $UX_DIR"
   1.136 +            ;;
   1.137 +        -ip*)
   1.138 +            shift
   1.139 +            IP_ADDRESS=$1
   1.140 +            if [ -z "$IP_ADDRESS" ] ; then
   1.141 +                echo "$0 `uname -n`: -ip requires ip-address "
   1.142 +                ssl_ds_usage
   1.143 +            fi
   1.144 +            USE_IP=TRUE
   1.145 +            IP_PARAM="-ip $IP_ADDRESS"
   1.146 +            ;;
   1.147 +        -h|-help|"-?"|*)
   1.148 +            ssl_ds_usage
   1.149 +            ;;
   1.150 +    esac
   1.151 +    shift
   1.152 +  done
   1.153 +}
   1.154 +
   1.155 +############################## ssl_ds_rem_stress #######################
   1.156 +# local shell function to perform the client part of the SSL stress test
   1.157 +########################################################################
   1.158 +
   1.159 +ssl_ds_rem_stress()
   1.160 +{
   1.161 +  testname="SSL remote part of Stress test (`uname -n`)"
   1.162 +  echo "$SCRIPTNAME `uname -n`: $testname"
   1.163 +
   1.164 +  #cp -r "${CLIENTDIR}" /tmp/ssl_ds.$$ #FIXME
   1.165 +  #cd /tmp/ssl_ds.$$
   1.166 +  #verbose="-v"
   1.167 +
   1.168 +  cd ${CLIENTDIR}
   1.169 +
   1.170 +  CONTINUE=$MAX_CERT
   1.171 +  while [ $CONTINUE -ge $MIN_CERT ]
   1.172 +  do
   1.173 +      echo "strsclnt -D -p ${PORT} -d ${P_R_CLIENTDIR} -w nss -c 1 $verbose  "
   1.174 +      echo "         -n TestUser$CONTINUE ${HOSTADDR} #`uname -n`"
   1.175 +      ${BINDIR}/strsclnt -D -p ${PORT} -d . -w nss -c 1 $verbose  \
   1.176 +               -n "TestUser$CONTINUE" ${HOSTADDR} &
   1.177 +               #${HOSTADDR} &
   1.178 +      CONTINUE=`expr $CONTINUE - 1 `
   1.179 +      #sleep 4 #give process time to start up
   1.180 +  done
   1.181 +
   1.182 +  html_msg 0 0 "${testname}" #FIXME
   1.183 +}
   1.184 +
   1.185 +######################### ssl_ds_dist_stress ###########################
   1.186 +# local shell function to perform the server part of the new, distributed 
   1.187 +# SSL stress test
   1.188 +########################################################################
   1.189 +
   1.190 +ssl_ds_dist_stress()
   1.191 +{
   1.192 +  max_clientlist=" 
   1.193 +               box-200
   1.194 +               washer-200
   1.195 +               dryer-200
   1.196 +               hornet-50
   1.197 +               shabadoo-50
   1.198 +               y2sun2-10
   1.199 +               galileo-10
   1.200 +               shame-10
   1.201 +               axilla-10
   1.202 +               columbus-10
   1.203 +               smarch-10
   1.204 +               nugget-10
   1.205 +               charm-10
   1.206 +               hp64-10
   1.207 +               biggayal-10
   1.208 +               orville-10
   1.209 +               kwyjibo-10
   1.210 +               hbombaix-10
   1.211 +               raven-10
   1.212 +               jordan-10
   1.213 +               phaedrus-10
   1.214 +               louie-10
   1.215 +               trex-10
   1.216 +               compaqtor-10"
   1.217 +
   1.218 +  #clientlist=" huey-2 dewey-2 hornet-2 shabadoo-2" #FIXME ADJUST
   1.219 +  clientlist="  box-200 washer-200 huey-200 dewey-200 hornet-200 shabadoo-200 louie-200"
   1.220 +  #clientlist="  box-2 huey-2 "
   1.221 +  #clientlist="washer-200 huey-200 dewey-200 hornet-200 "
   1.222 +
   1.223 +  html_head "SSL Distributed Stress Test"
   1.224 +
   1.225 +  testname="SSL distributed Stress test"
   1.226 +
   1.227 +  echo cd "${CLIENTDIR}"
   1.228 +  cd "${CLIENTDIR}"
   1.229 +  if [ -z "CD_QADIR_SSL" ] ; then
   1.230 +      CD_QADIR_SSL="cd $QADIR/ssl"
   1.231 +  else
   1.232 +      cp -r $HOSTDIR $HOSTDIR/../../../../../booboo_Solaris8/mozilla/tests_results/security
   1.233 +  fi
   1.234 +
   1.235 +  #sparam=" -t 128 -D -r "
   1.236 +  sparam=" -t 16 -D -r -r -y "
   1.237 +  start_selfserv
   1.238 +
   1.239 +  for c in $clientlist
   1.240 +  do
   1.241 +      client=`echo $c | sed -e "s/-.*//"`
   1.242 +      number=`echo $c | sed -e "s/.*-//"`
   1.243 +      CLIENT_OK="TRUE"
   1.244 +      echo $client
   1.245 +      ping $client >/dev/null || CLIENT_OK="FALSE"
   1.246 +      if [ "$CLIENT_OK" = "FALSE" ] ; then
   1.247 +          echo "$SCRIPTNAME `uname -n`: $client can't be reached - skipping"
   1.248 +      else
   1.249 +          get_certrange $number
   1.250 +          echo "$SCRIPTNAME `uname -n`: $RSH $client -l svbld \\ "
   1.251 +          echo "       \" $CD_QADIR_SSL ;ssl_dist_stress.sh \\"
   1.252 +          echo "            -host $HOST -certnum $CERTRANGE $IP_PARAM \" "
   1.253 +          $RSH $client -l svbld \
   1.254 +               " $CD_QADIR_SSL;ssl_dist_stress.sh -host $HOST -certnum $CERTRANGE $IP_PARAM " &
   1.255 +      fi
   1.256 +  done
   1.257 +
   1.258 +  echo cd "${CLIENTDIR}"
   1.259 +  cd "${CLIENTDIR}"
   1.260 +
   1.261 +  sleep 500 # give the clients time to finish #FIXME ADJUST
   1.262 + 
   1.263 +  echo "GET /stop HTTP/1.0\n\n" > stdin.txt #check to make sure it has /r/n
   1.264 +  echo "tstclnt -h $HOSTADDR -p  8443 -d ${P_R_CLIENTDIR} -n TestUser0 "
   1.265 +  echo "        -w nss -f < stdin.txt"
   1.266 +  ${BINDIR}/tstclnt -h $HOSTADDR -p  8443 -d ${P_R_CLIENTDIR} -n TestUser0 \
   1.267 +	  -w nss -f < stdin.txt
   1.268 +  
   1.269 +  html_msg 0 0 "${testname}"
   1.270 +  html "</TABLE><BR>"
   1.271 +}
   1.272 +
   1.273 +############################ get_certrange #############################
   1.274 +# local shell function to find the range of certs that the next remote 
   1.275 +# client is supposed to use (only for server side of the dist stress test
   1.276 +########################################################################
   1.277 +get_certrange()
   1.278 +{
   1.279 +  rangeOK=`echo $1  | sed -e 's/[0-9][0-9]*/OK/'`
   1.280 +  if [ -z "$rangeOK" -o "$rangeOK" != "OK" -o $1 = "OK" ] ; then
   1.281 +      range=10
   1.282 +      echo "$SCRIPTNAME `uname -n`: $1 is not a valid number of certs "
   1.283 +      echo "        defaulting to 10 for $client"
   1.284 +  else
   1.285 +      range=$1
   1.286 +      if [ $range -gt $GLOB_MAX_CERT ] ; then
   1.287 +          range=$GLOB_MAX_CERT
   1.288 +      fi
   1.289 +  fi
   1.290 +  if [ -z "$FROM_CERT" ] ; then    # start new on top of the cert stack
   1.291 +      FROM_CERT=$GLOB_MAX_CERT
   1.292 +  elif [ `expr $FROM_CERT - $range + 1 ` -lt  0 ] ; then 
   1.293 +          FROM_CERT=$GLOB_MAX_CERT # dont let it fall below 0 on the TO_CERT
   1.294 +
   1.295 +  fi
   1.296 +  TO_CERT=`expr $FROM_CERT - $range + 1 `
   1.297 +  if [ $TO_CERT -lt 0 ] ; then     # it's not that I'm bad in math, I just 
   1.298 +      TO_CERT=0                    # don't trust expr...
   1.299 +  fi
   1.300 +  CERTRANGE="${TO_CERT}-${FROM_CERT}"
   1.301 +  FROM_CERT=`expr ${TO_CERT} - 1 ` #start the next  client one below 
   1.302 +}
   1.303 +
   1.304 +
   1.305 +################## main #################################################
   1.306 +
   1.307 +DO_DIST_ST="TRUE"
   1.308 +. ./ssl.sh
   1.309 +ssl_ds_init $*
   1.310 +if [ -n  "$DO_REM_ST" -a "$DO_REM_ST" = "TRUE" ] ; then
   1.311 +    ssl_ds_rem_stress
   1.312 +    exit 0 #no cleanup on purpose
   1.313 +elif [ -n  "$DO_DIST_ST" -a "$DO_DIST_ST" = "TRUE" ] ; then
   1.314 +    ssl_ds_dist_stress
   1.315 +fi
   1.316 +ssl_cleanup

mercurial