stress-server.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. #
  3. # ngIRCd Test Suite
  4. # Copyright (c)2002-2004 by Alexander Barton (alex@barton.de)
  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. # $Id: stress-server.sh,v 1.15 2004/09/06 22:04:06 alex Exp $
  13. #
  14. # detect source directory
  15. [ -z "$srcdir" ] && srcdir=`dirname $0`
  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. # get our name
  20. name=`basename $0`
  21. # create directories
  22. mkdir -p logs tests
  23. # test for required external tools
  24. type expect > /dev/null 2>&1
  25. if [ $? -ne 0 ]; then
  26. echo " ${name}: \"expect\" not found."; exit 77
  27. fi
  28. type telnet > /dev/null 2>&1
  29. if [ $? -ne 0 ]; then
  30. echo " ${name}: \"telnet\" not found."; exit 77
  31. fi
  32. # hello world! :-)
  33. echo " stressing server with $CLIENTS clients (be patient!):"
  34. # read in functions
  35. . ${srcdir}/functions.inc
  36. # create scripts for expect(1)
  37. no=0
  38. while [ ${no} -lt $CLIENTS ]; do
  39. cat ${srcdir}/stress-A.e > tests/${no}.e
  40. echo "send \"nick test${no}\\r\"" >> tests/${no}.e
  41. cat ${srcdir}/stress-B.e >> tests/${no}.e
  42. no=`expr ${no} + 1`
  43. done
  44. no=0
  45. while [ ${no} -lt $CLIENTS ]; do
  46. expect tests/${no}.e > logs/stress-${no}.log 2> /dev/null &
  47. no=`expr ${no} + 1`
  48. echo " started client $no/$CLIENTS."
  49. [ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX
  50. done
  51. echo_n " waiting for clients to complete: ."
  52. touch logs/check-idle.log
  53. while true; do
  54. expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$?
  55. echo "====================" >> logs/check-idle.log
  56. [ $res -ne 99 ] && break
  57. # there are still clients connected. Wait ...
  58. sleep 3
  59. echo_n "."
  60. done
  61. [ $res -eq 0 ] && echo " ok." || echo " failure!"
  62. exit $res
  63. # -eof-