]> git.sur5r.net Git - openldap/blob - tests/scripts/test056-monitor
make test056 back-bdb independent
[openldap] / tests / scripts / test056-monitor
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 mkdir -p $TESTDIR $DBDIR1
20
21 echo "Starting slapd on TCP/IP port $PORT..."
22 . $CONFFILTER $BACKEND $MONITORDB < $SCHEMACONF > $CONF1
23 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
24 PID=$!
25 if test $WAIT != 0 ; then
26     echo PID $PID
27     read foo
28 fi
29 KILLPIDS="$PID"
30
31 sleep 1
32
33 echo "Using ldapsearch to check that slapd is running..."
34 for i in 0 1 2 3 4 5; do
35         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
36                 'objectclass=*' > /dev/null 2>&1
37         RC=$?
38         if test $RC = 0 ; then
39                 break
40         fi
41         echo "Waiting 5 seconds for slapd to start..."
42         sleep 5
43 done
44
45 echo "Using ldapsearch to read connection monitor entries..."
46 $LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
47         'objectclass=*' \
48         structuralObjectClass entryDN \
49         monitorConnectionProtocol monitorConnectionOpsReceived \
50         monitorConnectionOpsExecuting monitorConnectionOpsPending \
51         monitorConnectionOpsCompleted monitorConnectionGet \
52         monitorConnectionRead monitorConnectionWrite \
53         monitorConnectionMask monitorConnectionAuthzDN \
54         monitorConnectionListener monitorConnectionLocalAddress \
55         > $SEARCHOUT 2>&1
56 RC=$?
57
58 if test $RC != 0 ; then
59         echo "ldapsearch failed ($RC)!"
60         test $KILLSERVERS != no && kill -HUP $KILLPIDS
61         exit $RC
62 fi
63
64 echo "Filtering ldapsearch results..."
65 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
66
67 echo "Comparing filter output..."
68 $CMP $SEARCHFLT $MONITOROUT1 > $CMPOUT
69
70 if test $? != 0 ; then
71         echo "comparison failed - connection monitor output is not correct"
72         test $KILLSERVERS != no && kill -HUP $KILLPIDS
73         exit 1
74 fi
75
76 echo "Using ldapsearch to read database monitor entries..."
77 $LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -h $LOCALHOST -p $PORT1 \
78         'objectclass=*' \
79         structuralObjectClass entryDN namingContexts readOnly \
80         monitorIsShadow monitorContext \
81         olmBDBEntryCache olmBDBDNCache olmBDBIDLCache \
82         > $SEARCHOUT 2>&1
83 RC=$?
84
85 if test $RC != 0 ; then
86         echo "ldapsearch failed ($RC)!"
87         test $KILLSERVERS != no && kill -HUP $KILLPIDS
88         exit $RC
89 fi
90
91 echo "Filtering ldapsearch results..."
92 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
93
94 TMPMONITOROUT2=$MONITOROUT2
95 case $BACKEND in
96 bdb|hdb)
97         ;;
98 *)
99         TMPMONITOROUT2=$TESTDIR/monitor2.out
100         grep -v "olmBDB" $MONITOROUT2 > $TMPMONITOROUT2
101         ;;
102 esac
103
104 echo "Comparing filter output..."
105 $CMP $SEARCHFLT $TMPMONITOROUT2 > $CMPOUT
106
107 if test $? != 0 ; then
108         echo "comparison failed - database monitor output is not correct"
109         test $KILLSERVERS != no && kill -HUP $KILLPIDS
110         exit 1
111 fi
112
113 echo "Using ldapsearch to read statistics monitor entries..."
114 $LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -h $LOCALHOST -p $PORT1 \
115         '(|(cn=Entries)(cn=PDU)(cn=Referrals))' \
116         structuralObjectClass monitorCounter entryDN \
117         > $SEARCHOUT 2>&1
118 RC=$?
119
120 if test $RC != 0 ; then
121         echo "ldapsearch failed ($RC)!"
122         test $KILLSERVERS != no && kill -HUP $KILLPIDS
123         exit $RC
124 fi
125
126 echo "Filtering ldapsearch results..."
127 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
128
129 echo "Comparing filter output..."
130 $CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT
131
132 if test $? != 0 ; then
133         echo "comparison failed - statistics monitor output is not correct"
134         test $KILLSERVERS != no && kill -HUP $KILLPIDS
135         exit 1
136 fi
137
138 echo "Using ldapsearch to read operation monitor entries..."
139 $LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
140         'objectclass=*' \
141         structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \
142         > $SEARCHOUT 2>&1
143 RC=$?
144
145 if test $RC != 0 ; then
146         echo "ldapsearch failed ($RC)!"
147         test $KILLSERVERS != no && kill -HUP $KILLPIDS
148         exit $RC
149 fi
150
151 echo "Filtering ldapsearch results..."
152 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
153
154 echo "Comparing filter output..."
155 $CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT
156
157 if test $? != 0 ; then
158         echo "comparison failed - operations monitor output is not correct"
159         test $KILLSERVERS != no && kill -HUP $KILLPIDS
160         exit 1
161 fi
162
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164
165 echo ">>>>> Test succeeded"
166
167 test $KILLSERVERS != no && wait
168
169 exit 0
170