3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2014 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $MONITORDB = "no" ; then
20 echo "Monitor backend not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1
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 &
30 if test $WAIT != 0 ; then
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
43 if test $RC = 0 ; then
46 echo "Waiting 5 seconds for slapd to start..."
50 echo "Using ldapsearch to read connection monitor entries..."
51 $LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
53 structuralObjectClass entryDN \
54 monitorConnectionProtocol monitorConnectionOpsReceived \
55 monitorConnectionOpsExecuting monitorConnectionOpsPending \
56 monitorConnectionOpsCompleted monitorConnectionGet \
57 monitorConnectionRead monitorConnectionWrite \
58 monitorConnectionMask monitorConnectionAuthzDN \
59 monitorConnectionListener monitorConnectionLocalAddress \
63 if test $RC != 0 ; then
64 echo "ldapsearch failed ($RC)!"
65 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
78 if test $? != 0 ; then
79 echo "comparison failed - connection monitor output is not correct"
80 test $KILLSERVERS != no && kill -HUP $KILLPIDS
84 echo "Using ldapsearch to read database monitor entries..."
85 $LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -h $LOCALHOST -p $PORT1 \
87 structuralObjectClass entryDN namingContexts readOnly \
88 monitorIsShadow monitorContext \
89 olmBDBEntryCache olmBDBDNCache olmBDBIDLCache \
93 if test $RC != 0 ; then
94 echo "ldapsearch failed ($RC)!"
95 test $KILLSERVERS != no && kill -HUP $KILLPIDS
99 echo "Filtering ldapsearch results..."
100 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
102 TMPMONITOROUT2=$MONITOROUT2
107 TMPMONITOROUT2=$TESTDIR/monitor2.out
108 grep -v "olmBDB" $MONITOROUT2 > $TMPMONITOROUT2
112 echo "Comparing filter output..."
113 $CMP $SEARCHFLT $TMPMONITOROUT2 > $CMPOUT
115 if test $? != 0 ; then
116 echo "comparison failed - database monitor output is not correct"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 echo "Using ldapsearch to read statistics monitor entries..."
122 $LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -h $LOCALHOST -p $PORT1 \
123 '(|(cn=Entries)(cn=PDU)(cn=Referrals))' \
124 structuralObjectClass monitorCounter entryDN \
128 if test $RC != 0 ; then
129 echo "ldapsearch failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 echo "Filtering ldapsearch results..."
135 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
137 echo "Comparing filter output..."
138 $CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT
140 if test $? != 0 ; then
141 echo "comparison failed - statistics monitor output is not correct"
142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146 echo "Using ldapsearch to read operation monitor entries..."
147 $LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
149 structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \
153 if test $RC != 0 ; then
154 echo "ldapsearch failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "Filtering ldapsearch results..."
160 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
162 echo "Comparing filter output..."
163 $CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT
165 if test $? != 0 ; then
166 echo "comparison failed - operations monitor output is not correct"
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 echo ">>>>> Test succeeded"
175 test $KILLSERVERS != no && wait