Annotation of ircnowd/src/testsuite/stress-server.sh, Revision 1.1
1.1 ! tomglok 1: #!/bin/sh
! 2: #
! 3: # ngIRCd Test Suite
! 4: # Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
! 5: #
! 6: # This program is free software; you can redistribute it and/or modify
! 7: # it under the terms of the GNU General Public License as published by
! 8: # the Free Software Foundation; either version 2 of the License, or
! 9: # (at your option) any later version.
! 10: # Please read the file COPYING, README and AUTHORS for more information.
! 11: #
! 12:
! 13: # detect source directory
! 14: [ -z "$srcdir" ] && srcdir=`dirname $0`
! 15:
! 16: # parse command line
! 17: [ "$1" -gt 0 ] 2> /dev/null && CLIENTS="$1" || CLIENTS=5
! 18: [ "$2" -gt 0 ] 2> /dev/null && MAX="$2" || MAX=-1
! 19:
! 20: # get our name
! 21: name=`basename $0`
! 22:
! 23: # create directories
! 24: [ -d logs ] || mkdir logs
! 25: [ -d tests ] || mkdir tests
! 26:
! 27: # test for required external tools
! 28: type expect > /dev/null 2>&1
! 29: if [ $? -ne 0 ]; then
! 30: echo "${name}: \"expect\" not found."; exit 77
! 31: fi
! 32: type telnet > /dev/null 2>&1
! 33: if [ $? -ne 0 ]; then
! 34: echo "${name}: \"telnet\" not found."; exit 77
! 35: fi
! 36:
! 37: # hello world! :-)
! 38: echo "stressing server with $CLIENTS clients (be patient!):"
! 39:
! 40: # read in functions
! 41: . ${srcdir}/functions.inc
! 42:
! 43: # create scripts for expect(1)
! 44: no=0
! 45: while [ ${no} -lt $CLIENTS ]; do
! 46: cat ${srcdir}/stress-A.e > tests/${no}.e
! 47: echo "send \"nick test${no}\\r\"" >> tests/${no}.e
! 48: cat ${srcdir}/stress-B.e >> tests/${no}.e
! 49: no=`expr ${no} + 1`
! 50: done
! 51:
! 52: # run first script and check if it succeeds
! 53: echo_n "checking stress script ..."
! 54: expect tests/0.e > logs/stress-0.log 2> /dev/null
! 55: if [ $? -ne 0 ]; then
! 56: echo " failure!"
! 57: exit 1
! 58: else
! 59: echo " ok."
! 60: fi
! 61:
! 62: no=0
! 63: while [ ${no} -lt $CLIENTS ]; do
! 64: expect tests/${no}.e > logs/stress-${no}.log 2> /dev/null &
! 65:
! 66: no=`expr ${no} + 1`
! 67: echo "started client $no/$CLIENTS."
! 68:
! 69: [ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX
! 70: done
! 71:
! 72: echo_n "waiting for clients to complete: ."
! 73: touch logs/check-idle.log
! 74: while true; do
! 75: expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$?
! 76: echo "====================" >> logs/check-idle.log
! 77: [ $res -ne 99 ] && break
! 78:
! 79: # there are still clients connected. Wait ...
! 80: sleep 3
! 81: echo_n "."
! 82: done
! 83:
! 84: [ $res -eq 0 ] && echo " ok." || echo " failure!"
! 85:
! 86: exit $res
! 87:
! 88: # -eof-
CVSweb