]> git.sur5r.net Git - openldap/blob - tests/scripts/test056-monitor
tests: Add $MAINDB, $INDEXDB for [bhmn]db tests.
[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-2011 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 if test $MONITORDB = "no" ; then 
20         echo "Monitor backend not available, test skipped"
21         exit 0
22 fi 
23
24 mkdir -p $TESTDIR $DBDIR1
25
26 echo "Starting slapd on TCP/IP port $PORT..."
27 . $CONFFILTER $BACKEND $MONITORDB < $SCHEMACONF > $CONF1
28 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
29 PID=$!
30 if test $WAIT != 0 ; then
31     echo PID $PID
32     read foo
33 fi
34 KILLPIDS="$PID"
35
36 sleep 1
37
38 echo "Using ldapsearch to check that slapd is running..."
39 for i in 0 1 2 3 4 5; do
40         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
41                 'objectclass=*' > /dev/null 2>&1
42         RC=$?
43         if test $RC = 0 ; then
44                 break
45         fi
46         echo "Waiting 5 seconds for slapd to start..."
47         sleep 5
48 done
49
50 echo "Using ldapsearch to read connection monitor entries..."
51 $LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
52         'objectclass=*' \
53         structuralObjectClass entryDN \
54         monitorConnectionProtocol monitorConnectionOpsReceived \
55         monitorConnectionOpsExecuting monitorConnectionOpsPending \
56         monitorConnectionOpsCompleted monitorConnectionGet \
57         monitorConnectionRead monitorConnectionWrite \
58         monitorConnectionMask monitorConnectionAuthzDN \
59         monitorConnectionListener monitorConnectionLocalAddress \
60         > $SEARCHOUT 2>&1
61 RC=$?
62
63 if test $RC != 0 ; then
64         echo "ldapsearch failed ($RC)!"
65         test $KILLSERVERS != no && kill -HUP $KILLPIDS
66         exit $RC
67 fi
68
69 # Compare results, ignoring possible difference of IPv4/IPv6 localhost address
70 localrewrite='s/=127\.0\.0\.1:/=LOCAL:/; s/=\[::1\]:/=LOCAL:/'
71 echo "Filtering ldapsearch results..."
72 sed -e "$localrewrite" < $SEARCHOUT | $LDIFFILTER > $SEARCHFLT
73 echo "Filtering expected data..."
74 . $CONFFILTER < $MONITOROUT1 | sed -e "$localrewrite" | $LDIFFILTER > $LDIFFLT
75 echo "Comparing filter output..."
76 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
77
78 if test $? != 0 ; then
79         echo "comparison failed - connection monitor output is not correct"
80         test $KILLSERVERS != no && kill -HUP $KILLPIDS
81         exit 1
82 fi
83
84 echo "Using ldapsearch to read database monitor entries..."
85 $LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -h $LOCALHOST -p $PORT1 \
86         'objectclass=*' \
87         structuralObjectClass entryDN namingContexts readOnly \
88         monitorIsShadow monitorContext \
89         olmBDBEntryCache olmBDBDNCache olmBDBIDLCache \
90         > $SEARCHOUT 2>&1
91 RC=$?
92
93 if test $RC != 0 ; then
94         echo "ldapsearch failed ($RC)!"
95         test $KILLSERVERS != no && kill -HUP $KILLPIDS
96         exit $RC
97 fi
98
99 echo "Filtering ldapsearch results..."
100 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
101
102 TMPMONITOROUT2=$MONITOROUT2
103 if test $MAINDB != maindb ; then
104         TMPMONITOROUT2=$TESTDIR/monitor2.out
105         grep -v "olmBDB" $MONITOROUT2 > $TMPMONITOROUT2
106 fi
107
108 echo "Comparing filter output..."
109 $CMP $SEARCHFLT $TMPMONITOROUT2 > $CMPOUT
110
111 if test $? != 0 ; then
112         echo "comparison failed - database monitor output is not correct"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit 1
115 fi
116
117 echo "Using ldapsearch to read statistics monitor entries..."
118 $LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -h $LOCALHOST -p $PORT1 \
119         '(|(cn=Entries)(cn=PDU)(cn=Referrals))' \
120         structuralObjectClass monitorCounter entryDN \
121         > $SEARCHOUT 2>&1
122 RC=$?
123
124 if test $RC != 0 ; then
125         echo "ldapsearch failed ($RC)!"
126         test $KILLSERVERS != no && kill -HUP $KILLPIDS
127         exit $RC
128 fi
129
130 echo "Filtering ldapsearch results..."
131 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
132
133 echo "Comparing filter output..."
134 $CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT
135
136 if test $? != 0 ; then
137         echo "comparison failed - statistics monitor output is not correct"
138         test $KILLSERVERS != no && kill -HUP $KILLPIDS
139         exit 1
140 fi
141
142 echo "Using ldapsearch to read operation monitor entries..."
143 $LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
144         'objectclass=*' \
145         structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \
146         > $SEARCHOUT 2>&1
147 RC=$?
148
149 if test $RC != 0 ; then
150         echo "ldapsearch failed ($RC)!"
151         test $KILLSERVERS != no && kill -HUP $KILLPIDS
152         exit $RC
153 fi
154
155 echo "Filtering ldapsearch results..."
156 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
157
158 echo "Comparing filter output..."
159 $CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT
160
161 if test $? != 0 ; then
162         echo "comparison failed - operations monitor output is not correct"
163         test $KILLSERVERS != no && kill -HUP $KILLPIDS
164         exit 1
165 fi
166
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
168
169 echo ">>>>> Test succeeded"
170
171 test $KILLSERVERS != no && wait
172
173 exit 0
174