source: trunk/test/testrun_2c.sh@ 137

Last change on this file since 137 was 100, checked in by rainer, 18 years ago

Release 2.3.3; minor testscript and typo fixes.

File size: 7.3 KB
Line 
1#! /bin/sh
2
3#
4# Copyright Rainer Wichmann (2006)
5#
6# License Information:
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21
22SERVER_BUILDOPTS="--quiet $TRUST --enable-xml-log --enable-debug --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST} --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-database=mysql"; export SERVER_BUILDOPTS
23
24CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
25
26MAXTEST=3; export MAXTEST
27
28testrun_threesockets () {
29
30 GPG="$1"
31
32 [ -z "$verbose" ] || {
33 echo;
34 echo Working directory: $PW_DIR; echo MAKE is $MAKE; echo GPG is $GPG;
35 echo;
36 }
37
38 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
39
40 if test -r "Makefile"; then
41 $MAKE distclean
42 fi
43
44 ${TOP_SRCDIR}/configure --with-gpg=${GPG} --with-fp=EF6CEF54701A0AFDB86AF4C31AAD26C80F571F6C --with-checksum=no ${SERVER_BUILDOPTS} >/dev/null 2>&1
45
46 if test x$? = x0; then
47 [ -z "$verbose" ] || log_msg_ok "configure...";
48 $MAKE > /dev/null 2>>test_log
49 if test x$? = x0; then
50 [ -z "$verbose" ] || log_msg_ok "make...";
51 else
52 [ -z "$quiet" ] && log_msg_fail "make...";
53 return 1
54 fi
55 else
56 [ -z "$quiet" ] && log_msg_fail "configure...";
57 return 1
58 fi
59
60 rm -f ./.samhain_file
61 rm -f ./.samhain_log
62 rm -f ./.samhain_lock
63 rm -f ./rc.${SH_LOCALHOST}
64 rm -f ./file.${SH_LOCALHOST}
65
66 cp ${SCRIPTDIR}/testrc_2.in testrc_2
67
68 ORIGINAL="DatabaseSeverity=none"
69 REPLACEMENT="DatabaseSeverity=warn"
70 ex -s $RCFILE <<EOF
71%s/$ORIGINAL/$REPLACEMENT/g
72wq
73EOF
74
75 ORIGINAL="MailSeverity=none"
76 REPLACEMENT="MailSeverity=crit"
77 ex -s $RCFILE <<EOF
78%s/$ORIGINAL/$REPLACEMENT/g
79wq
80EOF
81 return 0
82 }
83
84check_mysql_log () {
85 DATE="$1"
86
87 rm -f test_log_db
88 #
89 echo "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '"${DATE}"';" | mysql --password=samhain -u samhain samhain >test_log_db
90 #
91 egrep "START.*Yule" test_log_db >/dev/null 2>&1
92 if [ $? -ne 0 ]; then
93 [ -z "$verbose" ] || log_msg_fail "Server start";
94 return 1
95 fi
96 egrep "NEW CLIENT" test_log_db >/dev/null 2>&1
97 if [ $? -ne 0 ]; then
98 [ -z "$verbose" ] || log_msg_fail "Client connect";
99 return 1
100 fi
101 egrep "Checking.*/bin" test_log_db >/dev/null 2>&1
102 if [ $? -ne 0 ]; then
103 [ -z "$verbose" ] || log_msg_fail "Client file check";
104 return 1
105 fi
106 egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1
107 if [ $? -ne 0 ]; then
108 [ -z "$verbose" ] || log_msg_fail "Client exit";
109 return 1
110 fi
111 egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1
112 if [ $? -ne 0 ]; then
113 [ -z "$verbose" ] || log_msg_fail "Server exit";
114 return 1
115 fi
116 return 0
117}
118
119testrun2c ()
120{
121 log_start "RUN FULL CLIENT/SERVER W/MYSQL"
122 #
123 if [ -z "$doall" ]; then
124 log_skip 1 $MAXTEST 'Client/server w/mysql (or use --really-all)'
125 log_skip 2 $MAXTEST 'Client/server w/mysql (or use --really-all)'
126 log_skip 3 $MAXTEST 'Client/server w/mysql (or use --really-all)'
127 return 0
128 fi
129 if [ x"$1" = x ]; then
130 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
131 fi
132 MYSQL=`find_path mysql`
133 if [ -z "$MYSQL" ]; then
134 log_skip 1 $MAXTEST "mysql not found";
135 log_skip 2 $MAXTEST "mysql not found";
136 log_skip 3 $MAXTEST "mysql not found";
137 return 1
138 else
139 TEST=`echo "DESCRIBE log;" | mysql --password=samhain -u samhain samhain 2>/dev/null`
140 if [ $? -ne 0 -o -z "$TEST" ]; then
141 log_skip 1 $MAXTEST "mysql not default setup"
142 log_skip 2 $MAXTEST "mysql not default setup"
143 log_skip 3 $MAXTEST "mysql not default setup"
144 return 1
145 fi
146 fi
147 #
148 SH_LOCALHOST=$1; export SH_LOCALHOST
149 #
150 DATE=`date '+%Y-%m-%d %T'`
151 #
152 testrun2a_internal
153 #
154 ORIGINAL="DatabaseSeverity=none"
155 REPLACEMENT="DatabaseSeverity=info"
156 ex -s $RCFILE <<EOF
157%s/$ORIGINAL/$REPLACEMENT/g
158wq
159EOF
160 #
161 do_test_1_a
162 if [ $? -ne 0 ]; then
163 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql";
164 else
165 #
166 check_mysql_log "${DATE}"
167 if [ $? -ne 0 ]; then
168 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql";
169 else
170 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/mysql";
171 fi
172 fi
173 #
174 if [ -f ./yule ]; then
175 ./yule -p info -l info --set-database-severity=info -D >/dev/null 2>>test_log
176 five_sec_sleep
177 netstat -pant 2>/dev/null | grep 49777 | grep yule >/dev/null 2>&1
178 if [ $? -ne 0 ]; then
179 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client/server w/mysql";
180 else
181 NSOCK=`netstat -pand 2>/dev/null | grep STREAM | grep yule | wc -l`
182 if [ $NSOCK -ne 2 ]; then
183 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Three sockets open";
184 netstat -pand 2>/dev/null | grep yule
185 else
186 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Three sockets open";
187 fi
188 fi
189 PID=`cat .samhain_lock`
190 kill $PID
191 else
192 log_fail 2 ${MAXTEST} "Three sockets open";
193 fi
194 #
195 GPG=`find_path gpg`
196 if [ -z "$GPG" ]; then
197 log_skip 3 $MAXTEST 'gpg not found in $PATH'
198 else
199 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
200 if [ $? -ne 0 ]; then
201 log_skip 3 $MAXTEST 'public PGP key 0x0F571F6C not present'
202 else
203 testrun_threesockets "$GPG"
204
205 if [ -f ./yule ]; then
206 ./yule -D >/dev/null 2>>test_log
207 five_sec_sleep
208 netstat -pant 2>/dev/null | grep 49777 | grep yule >/dev/null 2>&1
209 if [ $? -ne 0 ]; then
210 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Three sockets open (gpg)";
211 else
212 NSOCK=`netstat -pand 2>/dev/null | grep STREAM | grep yule | wc -l`
213 if [ $NSOCK -ne 2 ]; then
214 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Three sockets open (gpg)";
215 netstat -pand 2>/dev/null | grep yule
216 else
217 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Three sockets open (gpg)";
218 fi
219 fi
220 PID=`cat .samhain_lock`
221 kill $PID
222 else
223 log_fail 3 ${MAXTEST} "Three sockets open (gpg)";
224 fi
225 fi
226 fi
227 #
228 if [ -n "$cleanup" ]; then
229 rm -f ./rc.${SH_LOCALHOST}
230 rm -f ./file.${SH_LOCALHOST}
231 ALTHOST=`find_hostname`
232 rm -f "./file.${ALTHOST}"
233 rm -f "./rc.${ALTHOST}"
234 fi
235 #
236 log_end "RUN FULL CLIENT/SERVER W/MYSQL"
237}
238
Note: See TracBrowser for help on using the repository browser.