source: trunk/test/testrun_2d.sh@ 19

Last change on this file since 19 was 19, checked in by rainer, 19 years ago

Rewrite of test suite, checksum for growing logs, fix for minor bug with dead client detection.

File size: 3.2 KB
RevLine 
[1]1#! /bin/sh
2
[19]3SERVER_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=postgresql"; export SERVER_BUILDOPTS
[1]4
[19]5CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$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
[1]6
[19]7check_psql_log () {
8 DATE="$1"
[1]9
[19]10 rm -f test_log_db
11 PGPASSWORD=samhain; export PGPASSWORD
12 psql -U samhain -d samhain -c "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '${DATE}';" >test_log_db
13 #
14 egrep "START.*Yule" test_log_db >/dev/null 2>&1
15 if [ $? -ne 0 ]; then
16 [ -z "$verbose" ] || log_msg_fail "Server start";
17 return 1
[1]18 fi
[19]19 egrep "NEW CLIENT" test_log_db >/dev/null 2>&1
20 if [ $? -ne 0 ]; then
21 [ -z "$verbose" ] || log_msg_fail "Client connect";
22 return 1
23 fi
24 egrep "Checking.*/bin" test_log_db >/dev/null 2>&1
25 if [ $? -ne 0 ]; then
26 [ -z "$verbose" ] || log_msg_fail "Client file check";
27 return 1
28 fi
29 egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1
30 if [ $? -ne 0 ]; then
31 [ -z "$verbose" ] || log_msg_fail "Client exit";
32 return 1
33 fi
34 egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1
35 if [ $? -ne 0 ]; then
36 [ -z "$verbose" ] || log_msg_fail "Server exit";
37 return 1
38 fi
39 return 0
40}
[1]41
[19]42MAXTEST=1; export MAXTEST
[1]43
44testrun2d ()
45{
[19]46 log_start "RUN FULL CLIENT/SERVER W/POSTGRESQL"
47 #
48 if [ -z "$doall" ]; then
49 log_skip 1 $MAXTEST 'Client/server w/postgresql (or use --really-all)'
50 return 0
51 fi
52 if [ x"$1" = x ]; then
53 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
54 fi
55 PSQL=`find_path psql`
56 if [ -z "$PSQL" ]; then
57 log_skip 1 $MAXTEST "psql not found";
58 return 1
59 else
60 PGPASSWORD="samhain"; export PGPASSWORD
61 TEST=`psql -U samhain -d samhain -c "SELECT * FROM log LIMIT 1;" 2>/dev/null`
62 if [ $? -ne 0 -o -z "$TEST" ]; then
63 log_skip 1 $MAXTEST "psql not default setup"
64 return 1
[1]65 fi
[19]66 fi
67 #
68 SH_LOCALHOST=$1; export SH_LOCALHOST
69 #
70 DATE=`date '+%Y-%m-%d %T'`
71 #
72 testrun2a_internal
73 #
74 ORIGINAL="DatabaseSeverity=none"
75 REPLACEMENT="DatabaseSeverity=info"
76 ex $RCFILE <<EOF
77:%s/$ORIGINAL/$REPLACEMENT/g
78:wq
79EOF
80 #
81 do_test_1_a
82 if [ $? -ne 0 ]; then
83 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
84 else
85 #
86 check_psql_log "${DATE}"
87 if [ $? -ne 0 ]; then
88 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
[1]89 else
[19]90 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/postgresql";
[1]91 fi
[19]92 fi
93 #
94 if [ -n "$cleanup" ]; then
95 rm -f ./rc.${SH_LOCALHOST}
96 rm -f ./file.${SH_LOCALHOST}
97 ALTHOST=`find_hostname`
98 rm -f "./file.${ALTHOST}"
99 rm -f "./rc.${ALTHOST}"
100 fi
101 #
102 log_end "RUN FULL CLIENT/SERVER W/POSTGRESQL"
[1]103}
104
Note: See TracBrowser for help on using the repository browser.