]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Test suite: start two servers and test server-server links
authorAlexander Barton <alex@barton.de>
Thu, 13 Nov 2008 21:46:06 +0000 (22:46 +0100)
committerAlexander Barton <alex@barton.de>
Thu, 13 Nov 2008 21:46:06 +0000 (22:46 +0100)
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.

13 files changed:
src/testsuite/.gitignore
src/testsuite/Makefile.am
src/testsuite/README
src/testsuite/ngircd-test.conf [deleted file]
src/testsuite/ngircd-test1.conf [new file with mode: 0644]
src/testsuite/ngircd-test2.conf [new file with mode: 0644]
src/testsuite/server-link-test.e [new file with mode: 0644]
src/testsuite/start-server.sh
src/testsuite/start-server1 [new file with mode: 0755]
src/testsuite/start-server2 [new file with mode: 0755]
src/testsuite/stop-server.sh
src/testsuite/stop-server1 [new file with mode: 0755]
src/testsuite/stop-server2 [new file with mode: 0755]

index 9a2529f25821668478fd6bd6e2e2b34f1dba30a4..fd628e3dc9c5515a7faf1e3a31ed958ad4f8eae3 100644 (file)
@@ -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
index e9a1b1ceea3dcef1fc9d31545c1d822272552cfb..f72453f15e011b2a58a94755f364f346901ebe08 100644 (file)
@@ -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-
index 2a39be0242ae4d043c44a0ee52bfb0e13ee7a93f..8b695a1b4a5cea9eb8d68fc76d1918d125ed4c41 100644 (file)
@@ -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 <name>
        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 [<id>]
 
-       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<id>" (the default
+       for <id> is 1) with configuration file "ngircd-test<id>.conf" and the
+       console output redirected to "ngircd-test<id>.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 [<id>]
 
-       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<id>" 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 [<clientCount> [<maxConcurrent>]]
 
-       ...
+       stress-server.sh starts <clientCount> clients that "stress" the
+       running test server (id 1); but no more than <maxConcurrent> 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 <name>.e and checks
+       its exit code.
+
+test-loop.sh [<loops> [<wait>]]
+
+       This script runs all the tests <loops> times (default: 5) and pauses
+       <wait> seconds (default: 5) betweed runs.
+       It isn't used by "make check" or "make testsuite".
+
+wait-tests.sh [<max>]
+
+       stress-server.sh uses this script to ensure that no more than <max>
+       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-test.conf
deleted file mode 100644 (file)
index 4d918e0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# $Id: ngircd-test.conf,v 1.6 2008/02/17 00:00:13 fw Exp $
-
-[Global]
-       Name = ngircd.test.server
-       Info = ngIRCd Test-Server
-       Ports = 6789
-       MotdFile = ngircd-test.motd
-       AdminEMail = admin@irc.server
-       MaxConnectionsIP = 0
-       OperCanUseMode = yes
-       MaxJoins = 4
-
-[Operator]
-       Name = TestOp
-       Password = 123
-
-[CHANNEL]
-       Name = #InviteChannel
-       Modes = i
-
-[CHANNEL]
-       Name = #FullKeyed
-       Modes = lk
-       MaxUsers = 0
-       Key = Secret
-
-[CHANNEL]
-       Name = #TopicChannel
-       Modes = t
-       Topic = the topic
-       
-[CHANNEL]
-       Name = #SecretChannel
-       Modes = s
-       Topic = A secret Channel
-
-# -eof-
diff --git a/src/testsuite/ngircd-test1.conf b/src/testsuite/ngircd-test1.conf
new file mode 100644 (file)
index 0000000..299bf7c
--- /dev/null
@@ -0,0 +1,43 @@
+# ngIRCd test suite
+# configuration file for test server #2
+
+[Global]
+       Name = ngircd.test.server
+       Info = ngIRCd Test-Server 1
+       Ports = 6789
+       MotdFile = ngircd-test1.motd
+       AdminEMail = admin@irc.server
+       MaxConnectionsIP = 0
+       OperCanUseMode = yes
+       MaxJoins = 4
+
+[Operator]
+       Name = TestOp
+       Password = 123
+
+[Server]
+       Name = ngircd.test.server2
+       MyPassword = pwd1
+       PeerPassword = pwd2
+
+[Channel]
+       Name = #InviteChannel
+       Modes = i
+
+[Channel]
+       Name = #FullKeyed
+       Modes = lk
+       MaxUsers = 0
+       Key = Secret
+
+[Channel]
+       Name = #TopicChannel
+       Modes = t
+       Topic = the topic
+       
+[Channel]
+       Name = #SecretChannel
+       Modes = s
+       Topic = A secret Channel
+
+# -eof-
diff --git a/src/testsuite/ngircd-test2.conf b/src/testsuite/ngircd-test2.conf
new file mode 100644 (file)
index 0000000..3c2829b
--- /dev/null
@@ -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 (file)
index 0000000..3a1c232
--- /dev/null
@@ -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-
index 8d6c650674d183706bd97ff66e69df107c5311b5..15fa3f065bca64709a5d8ccb31a914be6a38562b 100755 (executable)
@@ -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 (executable)
index 0000000..7fb4e94
--- /dev/null
@@ -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 (executable)
index 0000000..2c4ffa6
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# ngIRCd Test Suite
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
+${srcdir}/start-server.sh 2
+
+# -eof-
index 256d512eeb17f7ad1787d71e6e22601561290399..7e6ee4f76b5e5c8afdae76d35fabbc7fee450d7c 100755 (executable)
@@ -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 (executable)
index 0000000..9b56207
--- /dev/null
@@ -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 (executable)
index 0000000..304d174
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# ngIRCd Test Suite
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
+${srcdir}/stop-server.sh 2
+
+# -eof-