summaryrefslogtreecommitdiffstats
path: root/rasmgr/test
diff options
context:
space:
mode:
Diffstat (limited to 'rasmgr/test')
-rw-r--r--rasmgr/test/Makefile46
-rw-r--r--rasmgr/test/Makefile.dep0
-rw-r--r--rasmgr/test/check_opensockets.sh25
-rw-r--r--rasmgr/test/check_opensockets_idleresult.log92
-rw-r--r--rasmgr/test/test_hostcmpbin0 -> 35013 bytes
-rw-r--r--rasmgr/test/test_hostcmp.cc56
-rw-r--r--rasmgr/test/test_hostcmp.sh36
-rw-r--r--rasmgr/test/test_rasmgr.sh103
8 files changed, 358 insertions, 0 deletions
diff --git a/rasmgr/test/Makefile b/rasmgr/test/Makefile
new file mode 100644
index 0000000..6150f87
--- /dev/null
+++ b/rasmgr/test/Makefile
@@ -0,0 +1,46 @@
+#
+# This file is part of rasdaman community.
+#
+# Rasdaman community is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Rasdaman community is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+#
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+# rasdaman GmbH.
+#
+# For more information please see <http://www.rasdaman.org>
+# or contact Peter Baumann via <baumann@rasdaman.com>. # Top Level makefile. This points to the various modules that have to be build
+# and/or deployed
+#
+######################### Definitions ############################
+
+# standard include with general options
+include $(RMANBASE)/Makefile.inc
+
+SRCCXX = test_hostcmp.cc
+
+OBJS = ${SRCCXX:%.cc=%.o}
+MISCCLEAN = test_hostcmp
+
+########################### Targets ##############################
+
+all: test_hostcmp
+
+test_hostcmp: test_hostcmp.o ../hostcmp.o
+ $(PURIFY) $(CXX) $(CXXFLAGS) -o test_hostcmp $^
+
+.PHONY: clean
+clean:
+ -rm $(OBJS) $(MISCCLEAN)
+
+######################## Dependencies ############################
+
diff --git a/rasmgr/test/Makefile.dep b/rasmgr/test/Makefile.dep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rasmgr/test/Makefile.dep
diff --git a/rasmgr/test/check_opensockets.sh b/rasmgr/test/check_opensockets.sh
new file mode 100644
index 0000000..7ec3ab2
--- /dev/null
+++ b/rasmgr/test/check_opensockets.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# check_opensockets.sh: periodically check the number of waiting sockets in the local system
+# parameters:
+# $1 sleep time between checks
+
+export SLEEPTIME=$1
+
+if test "$1" == ""
+then
+ echo usage: $0 sleepseconds
+ exit
+fi
+
+echo "$0: start checking for open (waiting) sockets, in intervals of $SLEEPTIME seconds."
+
+while echo \--- check time: `date` \----------------
+do
+ netstat -na | grep WAIT
+ echo summary: `netstat -na | grep WAIT | wc -l` TIME_WAIT state sockets.
+ sleep $SLEEPTIME
+done
+
+echo $0: done.
+
diff --git a/rasmgr/test/check_opensockets_idleresult.log b/rasmgr/test/check_opensockets_idleresult.log
new file mode 100644
index 0000000..a309b52
--- /dev/null
+++ b/rasmgr/test/check_opensockets_idleresult.log
@@ -0,0 +1,92 @@
+./check_opensockets.sh: start checking for open (waiting) sockets, in intervals of 1 seconds.
+--- check time: Die Jun 3 23:22:34 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:35 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:36 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:37 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:38 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:39 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:40 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:41 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:42 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:43 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:44 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:45 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:46 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:47 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:48 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:50 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:51 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:52 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:53 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:54 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:55 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:56 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:57 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:58 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:22:59 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:00 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:01 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:02 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:03 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:04 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:05 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:06 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:07 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:08 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:09 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:10 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:11 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:12 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:13 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:14 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:15 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:16 CEST 2003 ----------------
+tcp 0 0 127.0.0.1:620 127.0.0.1:686 TIME_WAIT
+--- check time: Die Jun 3 23:23:18 CEST 2003 ----------------
+--- check time: Die Jun 3 23:23:19 CEST 2003 ----------------
+--- check time: Die Jun 3 23:23:20 CEST 2003 ----------------
+--- check time: Die Jun 3 23:23:21 CEST 2003 ----------------
+--- check time: Die Jun 3 23:23:22 CEST 2003 ----------------
+--- check time: Die Jun 3 23:23:23 CEST 2003 ----------------
+--- check time: Die Jun 3 23:23:24 CEST 2003 ----------------
diff --git a/rasmgr/test/test_hostcmp b/rasmgr/test/test_hostcmp
new file mode 100644
index 0000000..774a6c6
--- /dev/null
+++ b/rasmgr/test/test_hostcmp
Binary files differ
diff --git a/rasmgr/test/test_hostcmp.cc b/rasmgr/test/test_hostcmp.cc
new file mode 100644
index 0000000..c88e330
--- /dev/null
+++ b/rasmgr/test/test_hostcmp.cc
@@ -0,0 +1,56 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+/
+/**
+ * SOURCE: test_hostcmp.cc
+ *
+ * MODULE: rasmgr
+ * CLASS:
+ *
+ * SYNOPSIS:
+ * test_hostcmp hostname1 hostname2
+ *
+ * PURPOSE:
+ * test hostname comparison function of rasmgr, Configuration::hostCmp().
+ *
+ * COMMENTS:
+ * None
+ *
+*/
+
+using namespace std;
+
+#include <iostream>
+
+extern int hostCmp( const char *h1, const char *h2 );
+
+int main(int argc, char** argv)
+{
+ if (argc != 3)
+ {
+ cout << "usage: " << argv[0] << " hostname1 hostname2" << endl;
+ return -2;
+ }
+
+ cout << argv[0] << ": hostCmp( " << argv[1] << ", " << argv[2] << " ) -> " << (hostCmp( argv[1], argv[2]) ? "true" : "false") << endl;
+ return 0;
+}
diff --git a/rasmgr/test/test_hostcmp.sh b/rasmgr/test/test_hostcmp.sh
new file mode 100644
index 0000000..c9a99cc
--- /dev/null
+++ b/rasmgr/test/test_hostcmp.sh
@@ -0,0 +1,36 @@
+#!/bin/bash -x
+
+# test_hostcmp: test hostCmp() function of rasmgr
+
+# return codes
+export RC_OK=0
+export RC_ERROR=1
+
+INDENT="+++ "
+TESTPROG=./test_hostcmp
+
+HOST_SHORT=abc
+HOST_LONG=${HOST_SHORT}.def.ghi
+HOST_OTHER=xyz
+
+echo $0: testing rasmgr/rascontrol.
+
+echo $INDENT good cases, equal:
+$TESTPROG $HOST_SHORT $HOST_SHORT
+$TESTPROG $HOST_LONG $HOST_LONG
+$TESTPROG "" ""
+
+echo $INDENT general cases, equal:
+$TESTPROG $HOST_SHORT $HOST_LONG
+$TESTPROG $HOST_LONG $HOST_SHORT
+
+echo $INDENT general cases, NOT equal:
+$TESTPROG $HOST_SHORT $HOST_OTHER
+$TESTPROG $HOST_LONG $HOST_OTHER
+
+echo $INDENT special cases, NOT equal:
+$TESTPROG $HOST_SHORT ""
+$TESTPROG "" $HOST_SHORT
+
+echo $0: done.
+
diff --git a/rasmgr/test/test_rasmgr.sh b/rasmgr/test/test_rasmgr.sh
new file mode 100644
index 0000000..5d4f522
--- /dev/null
+++ b/rasmgr/test/test_rasmgr.sh
@@ -0,0 +1,103 @@
+#!/bin/bash -x
+
+# return codes
+export RC_OK=0
+export RC_ERROR=1
+
+export RASMGR=rasmgr
+export RASMGR_CONF=rasmgr.conf
+export RASMGR_AUTH=rasmgr_auth.dat
+
+# settings demanded by rasmgr
+export RMANHOME=.
+
+echo $0: testing rasmgr/rascontrol.
+
+# start rasmgr
+
+if [ -f nohup.out ]
+then
+ rm nohup.out || (echo "Error: cannot remove old nohup log file, exiting."; exit $RC_ERROR)
+fi
+
+export START_AND_KILL_RASMGR="
+ ( nohup $RASMGR & ; \
+ export RASMGR_PID=\$!; \
+ sleep 4; \
+ kill \$RASMGR_PID; \
+ cat nohup.out; \
+ rm nohup.out \
+ ) \
+ || echo Error: cannot start/terminate/... rasmgr. "
+
+echo $START_AND_KILL_RASMGR
+
+# -- conf file -------------------
+
+# conf file not present
+if [ -f $RASMGR_CONF ]
+then
+ rm $RASMGR_CONF || (echo "Error: cannot remove old $RASMGR_CONF file, exiting."; exit $RC_ERROR)
+fi
+eval $START_AND_KILL_RASMGR
+exit
+
+# empty conf file
+echo >$RASMGR_CONF
+$START_AND_KILL_RASMGR
+
+# conf file not readable
+chmod a-r $RASMGR_CONF
+$START_AND_KILL_RASMGR
+chmod a+rw $RASMGR_CONF
+
+# illegal cmd in conf file
+cat >$RASMGR_CONF <<EOF
+iiiiiiiiiiillegal cmd
+EOF
+$START_AND_KILL_RASMGR
+
+# for further tests, we provide a sane conf file
+cat >$RASMGR_CONF <<EOF
+define dbh melange_host -connect /
+define srv S1 -host `hostname` -type r -port 0x29999901 -dbh melange_host
+define db RASBASE -dbh melange_host
+EOF
+
+# -- auth file -------------------
+rm $RASMGR_AUTH || (echo "Error: cannot remove old $RASMGR_AUTH file, exiting."; exit $RC_ERROR)
+
+# auth file not present
+if [ -f $RASMGR_AUTH ]
+then
+ rm $RASMGR_AUTH || (echo "Error: cannot remove old $RASMGR_AUTH file, exiting."; exit $RC_ERROR)
+fi
+$START_AND_KILL_RASMGR
+
+# empty auth file
+echo >$RASMGR_AUTH
+$START_AND_KILL_RASMGR
+
+# auth file not readable
+chmod a-r $RASMGR_AUTH
+$START_AND_KILL_RASMGR
+chmod a+rw $RASMGR_AUTH
+
+# auth file has illegal contents
+echo iiiiiiiiillegal >$RAMGR_AUTH
+$START_AND_KILL_RASMGR
+
+# auth file has good contents -- let rasmgr generate the default file, then check
+rm $RASMGR_AUTH
+$START_AND_KILL_RASMGR
+$START_AND_KILL_RASMGR
+
+# -- highlander check ------------
+# start an additional rasmgr, see what it tells
+$START_RASMGR
+export SECOND_PID=$!
+$START_AND_KILL_RASMGR
+kill $SECOND_PID
+
+echo $0: done.
+