From 7ad167f4c43948f19125123a27dbe68a93e863b8 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Thu, 13 Nov 2008 22:46:06 +0100 Subject: [PATCH] Test suite: start two servers and test server-server links I changed the test suite to start two test servers (on port 6789 and 6790), so server-server links can be tested as well for which I included the new test script "server-link-test.e". In addition the documentation of the test suite (src/testsuite/README) has been updated and is more complete now. --- src/testsuite/.gitignore | 10 ++- src/testsuite/Makefile.am | 28 +++++--- src/testsuite/README | 65 +++++++++++++------ .../{ngircd-test.conf => ngircd-test1.conf} | 20 ++++-- src/testsuite/ngircd-test2.conf | 25 +++++++ src/testsuite/server-link-test.e | 52 +++++++++++++++ src/testsuite/start-server.sh | 24 ++++--- src/testsuite/start-server1 | 7 ++ src/testsuite/start-server2 | 7 ++ src/testsuite/stop-server.sh | 13 ++-- src/testsuite/stop-server1 | 7 ++ src/testsuite/stop-server2 | 7 ++ 12 files changed, 213 insertions(+), 52 deletions(-) rename src/testsuite/{ngircd-test.conf => ngircd-test1.conf} (62%) create mode 100644 src/testsuite/ngircd-test2.conf create mode 100644 src/testsuite/server-link-test.e create mode 100755 src/testsuite/start-server1 create mode 100755 src/testsuite/start-server2 create mode 100755 src/testsuite/stop-server1 create mode 100755 src/testsuite/stop-server2 diff --git a/src/testsuite/.gitignore b/src/testsuite/.gitignore index 9a2529f2..fd628e3d 100644 --- a/src/testsuite/.gitignore +++ b/src/testsuite/.gitignore @@ -1,4 +1,5 @@ -T-ngircd +T-ngircd1 +T-ngircd2 channel-test connect-test invite-test @@ -8,8 +9,11 @@ message-test misc-test mode-test opless-channel-test +server-link-test who-test -ngircd-test.log -ngircd-test.motd +ngircd-test1.log +ngircd-test2.log +ngircd-test1.motd +ngircd-test2.motd logs tests diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.am index e9a1b1ce..f72453f1 100644 --- a/src/testsuite/Makefile.am +++ b/src/testsuite/Makefile.am @@ -1,6 +1,6 @@ # # ngIRCd -- The Next Generation IRC Daemon -# Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) +# Copyright (c)2001-2008 Alexander Barton (alex@barton.de) # # Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen # der GNU General Public License (GPL), wie von der Free Software Foundation @@ -9,8 +9,6 @@ # Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. # -# $Id: Makefile.am,v 1.18 2008/02/17 13:26:42 alex Exp $ -# AUTOMAKE_OPTIONS = ../portab/ansi2knr @@ -22,14 +20,16 @@ EXTRA_DIST = \ test-loop.sh wait-tests.sh \ channel-test.e connect-test.e check-idle.e invite-test.e \ join-test.e kick-test.e message-test.e misc-test.e mode-test.e \ - opless-channel-test.e who-test.e stress-A.e stress-B.e \ - ngircd-test.conf + opless-channel-test.e server-link-test.e who-test.e \ + stress-A.e stress-B.e \ + start-server1 stop-server1 ngircd-test1.conf \ + start-server2 stop-server2 ngircd-test2.conf all: clean-local: - rm -rf logs tests *-test ngircd-test.log ngircd-test.motd \ - T-ngircd procs.tmp + rm -rf logs tests *-test ngircd-test*.log procs.tmp \ + T-ngircd1 ngircd-test1.motd T-ngircd2 ngircd-test2.motd maintainer-clean-local: rm -f Makefile Makefile.in @@ -37,7 +37,8 @@ maintainer-clean-local: check_SCRIPTS = ngircd-TEST-Binary tests.sh ngircd-TEST-Binary: - cp ../ngircd/ngircd T-ngircd + cp ../ngircd/ngircd T-ngircd1 + cp ../ngircd/ngircd T-ngircd2 [ -f getpid.sh ] || ln -s $(srcdir)/getpid.sh . connect-test: tests.sh @@ -76,12 +77,17 @@ opless-channel-test: tests.sh rm -f opless-channel-test ln -s $(srcdir)/tests.sh opless-channel-test +server-link-test: tests.sh + rm -f server-link-test + ln -s $(srcdir)/tests.sh server-link-test + who-test: tests.sh rm -f who-test ln -s $(srcdir)/tests.sh who-test -TESTS = start-server.sh \ +TESTS = start-server1 \ connect-test \ + start-server2 \ channel-test \ invite-test \ join-test \ @@ -91,7 +97,9 @@ TESTS = start-server.sh \ mode-test \ opless-channel-test \ who-test \ + server-link-test \ + stop-server2 \ stress-server.sh \ - stop-server.sh + stop-server1 # -eof- diff --git a/src/testsuite/README b/src/testsuite/README index 2a39be02..8b695a1b 100644 --- a/src/testsuite/README +++ b/src/testsuite/README @@ -1,7 +1,7 @@ ngIRCd - Next Generation IRC Server - (c)2001-2004 by Alexander Barton, + (c)2001-2008 Alexander Barton, alex@barton.de, http://www.barton.de/ ngIRCd is free software and published under the @@ -17,14 +17,20 @@ The purpose of the "test suite" contained in this directory is to detect bugs and incompatibilities in ngIRCd introduced during coding and after building ngIRCd on a specific platform. -To run the "standard" tests call "make check". It will build ngIRCd (if -required) and run some tests on it. These tests should be portable and run -on all supported platforms without errors. +To run the "standard" tests call "make check" (which runs "make check" in +all the source directories, testing the "portab" library as well for example) +or "make testsuite" (which only runs the tests in this directory). Both will +build ngIRCd (if required) and run some tests on it. These tests should be +portable and run on all supported platforms without errors. -Please note: most tests of this suite depend on the external tools expect(1) +NOTE #1: most tests of this suite depend on the external tools expect(1) and telnet(1), so make sure you have them installed. If not, the tests will not fail but simply be skipped. +NOTE #2: the two test servers started by this test suite are configured to +run on port 6789 and 6790; so it will fail if one or both of these ports +are already used by some other daemons! + II. Shell Scripts ~~~~~~~~~~~~~~~~ @@ -35,26 +41,43 @@ getpid.sh the given name in a portable manner. The result is echoed on the console. It is a helper script for some other scripts of this suite. -start-server.sh +start-server.sh [] - start-server.sh starts up the test binary, "T-ngircd". It makes sure - that getpid.sh is available and working, and that no other instance - of the test binary is already running. + start-server.sh starts up the test binary, "T-ngircd" (the default + for is 1) with configuration file "ngircd-test.conf" and the + console output redirected to "ngircd-test.log". + The script first makes sure that getpid.sh is available and working, + and that no other instance of the test binary is already running. The exit code is 0 if the test binary could be started. -stop-server.sh +stop-server.sha [] - This script uses getpid.sh to detect a running test binary "T-ngircd" - and then shuts it down using the TERM signal. + This script uses getpid.sh to detect a running test binary + "T-ngircd" and then shuts it down using the TERM signal. The exit code is 0 if the test binary could be stopped. -stress-server.sh +stress-server.sh [ []] - ... + stress-server.sh starts clients that "stress" the + running test server (id 1); but no more than clients + are started at the same moment. tests.sh - ... + Most of the tests scripts are symlinked to tests.sh, which in turn + uses expect(1) to run the respective script .e and checks + its exit code. + +test-loop.sh [ []] + + This script runs all the tests times (default: 5) and pauses + seconds (default: 5) betweed runs. + It isn't used by "make check" or "make testsuite". + +wait-tests.sh [] + + stress-server.sh uses this script to ensure that no more than + clients are connected to the test server (id 1). III. Scripts for expect(1) @@ -63,10 +86,14 @@ III. Scripts for expect(1) channel-test.e check-idle.e connect-test.e +invite-test.e +join-test.e +kick-test.e +message-test.e +misc-test.e mode-test.e +opless-channel-test.e +server-link-test.e stress-A.e stress-B.e - - --- -$Id: README,v 1.1 2004/09/04 13:58:31 alex Exp $ +who-test.e diff --git a/src/testsuite/ngircd-test.conf b/src/testsuite/ngircd-test1.conf similarity index 62% rename from src/testsuite/ngircd-test.conf rename to src/testsuite/ngircd-test1.conf index 4d918e0e..299bf7ca 100644 --- a/src/testsuite/ngircd-test.conf +++ b/src/testsuite/ngircd-test1.conf @@ -1,10 +1,11 @@ -# $Id: ngircd-test.conf,v 1.6 2008/02/17 00:00:13 fw Exp $ +# ngIRCd test suite +# configuration file for test server #2 [Global] Name = ngircd.test.server - Info = ngIRCd Test-Server + Info = ngIRCd Test-Server 1 Ports = 6789 - MotdFile = ngircd-test.motd + MotdFile = ngircd-test1.motd AdminEMail = admin@irc.server MaxConnectionsIP = 0 OperCanUseMode = yes @@ -14,22 +15,27 @@ Name = TestOp Password = 123 -[CHANNEL] +[Server] + Name = ngircd.test.server2 + MyPassword = pwd1 + PeerPassword = pwd2 + +[Channel] Name = #InviteChannel Modes = i -[CHANNEL] +[Channel] Name = #FullKeyed Modes = lk MaxUsers = 0 Key = Secret -[CHANNEL] +[Channel] Name = #TopicChannel Modes = t Topic = the topic -[CHANNEL] +[Channel] Name = #SecretChannel Modes = s Topic = A secret Channel diff --git a/src/testsuite/ngircd-test2.conf b/src/testsuite/ngircd-test2.conf new file mode 100644 index 00000000..3c2829bc --- /dev/null +++ b/src/testsuite/ngircd-test2.conf @@ -0,0 +1,25 @@ +# ngIRCd test suite +# configuration file for test server #2 + +[Global] + Name = ngircd.test.server2 + Info = ngIRCd Test-Server 2 + Ports = 6790 + MotdFile = ngircd-test2.motd + AdminEMail = admin@irc.server2 + MaxConnectionsIP = 0 + OperCanUseMode = yes + MaxJoins = 4 + +[Operator] + Name = TestOp + Password = 123 + +[Server] + Name = ngircd.test.server + Host = localhost + Port = 6789 + MyPassword = pwd2 + PeerPassword = pwd1 + +# -eof- diff --git a/src/testsuite/server-link-test.e b/src/testsuite/server-link-test.e new file mode 100644 index 00000000..3a1c232d --- /dev/null +++ b/src/testsuite/server-link-test.e @@ -0,0 +1,52 @@ +# ngIRCd test suite +# server-server link test + +spawn telnet localhost 6790 +expect { + timeout { exit 1 } + "Connected" +} + +send "nick nick\r" +send "user user . . :User\r" +expect { + timeout { exit 1 } + "376" +} + +send "version ngircd.test.server2\r" +expect { + timeout { exit 1 } + ":ngircd.test.server2 351" +} +send "version ngircd.test.server\r" +expect { + timeout { exit 1 } + ":ngircd.test.server 351" +} + +send "whois ngircd.test.server nick\r" +expect { + timeout { exit 1 } + ":ngircd.test.server 318" +} + +send "admin ngircd.test.server\r" +expect { + timeout { exit 1 } + ":ngircd.test.server 259 nick :admin@irc.server" +} + +send "links\r" +expect { + timeout { exit 1 } + "364 nick ngircd.test.server ngircd.test.server2 :1" +} + +send "quit\r" +expect { + timeout { exit 1 } + "ERROR" +} + +# -eof- diff --git a/src/testsuite/start-server.sh b/src/testsuite/start-server.sh index 8d6c6506..15fa3f06 100755 --- a/src/testsuite/start-server.sh +++ b/src/testsuite/start-server.sh @@ -1,16 +1,21 @@ #!/bin/sh # ngIRCd Test Suite -# $Id: start-server.sh,v 1.14 2004/09/06 22:04:06 alex Exp $ [ -z "$srcdir" ] && srcdir=`dirname $0` # read in functions . ${srcdir}/functions.inc -echo_n " starting server ..." +if [ -n "$1" ]; then + id="$1"; shift +else + id="1" +fi + +echo_n " starting server ${id} ..." -# remove old logfiles -rm -rf logs *.log +# remove old logfiles, if this is the first server (ID 1) +[ "$id" = "1" ] && rm -rf logs *.log # check weather getpid.sh returns valid PIDs. If not, don't start up the # test-server, because we won't be able to kill it at the end of the test. @@ -21,21 +26,22 @@ if [ $? -ne 0 ]; then fi # check if there is a test-server already running -./getpid.sh T-ngircd > /dev/null 2>&1 +./getpid.sh T-ngircd${id} >/dev/null 2>&1 if [ $? -eq 0 ]; then - echo " failure: test-server already running!" + echo " failure: test-server ${id} already running!" exit 1 fi # generate MOTD for test-server -echo "This is an ngIRCd Test Server" > ngircd-test.motd +echo "This is an ngIRCd Test Server" > ngircd-test${id}.motd # starting up test-server ... -./T-ngircd -np -f ${srcdir}/ngircd-test.conf $* > ngircd-test.log 2>&1 & +./T-ngircd${id} -n -f ${srcdir}/ngircd-test${id}.conf $* \ + >ngircd-test${id}.log 2>&1 & sleep 1 # validate running test-server -pid=`./getpid.sh T-ngircd` +pid=`./getpid.sh T-ngircd${id}` [ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1; r=$? [ $r -eq 0 ] && echo " ok." || echo " failure!" diff --git a/src/testsuite/start-server1 b/src/testsuite/start-server1 new file mode 100755 index 00000000..7fb4e94c --- /dev/null +++ b/src/testsuite/start-server1 @@ -0,0 +1,7 @@ +#!/bin/sh +# ngIRCd Test Suite + +[ -z "$srcdir" ] && srcdir=`dirname $0` +${srcdir}/start-server.sh 1 + +# -eof- diff --git a/src/testsuite/start-server2 b/src/testsuite/start-server2 new file mode 100755 index 00000000..2c4ffa6b --- /dev/null +++ b/src/testsuite/start-server2 @@ -0,0 +1,7 @@ +#!/bin/sh +# ngIRCd Test Suite + +[ -z "$srcdir" ] && srcdir=`dirname $0` +${srcdir}/start-server.sh 2 + +# -eof- diff --git a/src/testsuite/stop-server.sh b/src/testsuite/stop-server.sh index 256d512e..7e6ee4f7 100755 --- a/src/testsuite/stop-server.sh +++ b/src/testsuite/stop-server.sh @@ -1,16 +1,21 @@ #!/bin/sh # ngIRCd Test Suite -# $Id: stop-server.sh,v 1.13 2004/09/06 22:04:06 alex Exp $ [ -z "$srcdir" ] && srcdir=`dirname $0` # read in functions . ${srcdir}/functions.inc -echo_n " stopping server ..." +if [ -n "$1" ]; then + id="$1"; shift +else + id="1" +fi + +echo_n " stopping server ${id} ..." # stop test-server ... -pid=`./getpid.sh T-ngircd` +pid=`./getpid.sh T-ngircd${id}` if [ -z "$pid" ]; then echo " failure: no running server found!?" exit 1 @@ -26,7 +31,7 @@ for i in 1 2 3 4 5; do fi sleep 1 done -echo " failure: server still running!?" +echo " failure: server ${id} still running!?" exit 1 # -eof- diff --git a/src/testsuite/stop-server1 b/src/testsuite/stop-server1 new file mode 100755 index 00000000..9b562076 --- /dev/null +++ b/src/testsuite/stop-server1 @@ -0,0 +1,7 @@ +#!/bin/sh +# ngIRCd Test Suite + +[ -z "$srcdir" ] && srcdir=`dirname $0` +${srcdir}/stop-server.sh 1 + +# -eof- diff --git a/src/testsuite/stop-server2 b/src/testsuite/stop-server2 new file mode 100755 index 00000000..304d1749 --- /dev/null +++ b/src/testsuite/stop-server2 @@ -0,0 +1,7 @@ +#!/bin/sh +# ngIRCd Test Suite + +[ -z "$srcdir" ] && srcdir=`dirname $0` +${srcdir}/stop-server.sh 2 + +# -eof- -- 2.39.2