Debian Codegraph @

tests/scripts/test056-monitor

raw symbols SCIP
1 #! /bin/shscip-shell filesystem . . `/bin/sh`.
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 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 echoscip-shell system . . echo. "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 mkdirscip-shell system . . mkdir. -p $TESTDIR $DBDIR1
20
21 echoscip-shell system . . echo. "Starting slapd on TCP/IP port $PORT..."
22 . $CONFFILTER $BACKEND < $SCHEMACONF > $CONF1
23 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
24 PID=$!
25 if testscip-shell system . . test. $WAIT != 0 ; then
26 echoscip-shell system . . echo. PID $PID
27 read foo
28 fi
29 KILLPIDS="$PID"
30
31 sleepscip-shell system . . sleep. 1
32
33 echoscip-shell system . . 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 $URI1 \
36 'objectclass=*' > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
37 RC=$?
38 if testscip-shell system . . test. $RC = 0 ; then
39 break
40 fi
41 echoscip-shell system . . echo. "Waiting 5 seconds for slapd to start..."
42 sleepscip-shell system . . sleep. 5
43 done
44
45 echoscip-shell system . . echo. "Using ldapsearch to read connection monitor entries..."
46 $LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -H $URI1 \
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 testscip-shell system . . test. $RC != 0 ; then
59 echoscip-shell system . . echo. "ldapsearch failed ($RC)!"
60 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
61 exit $RC
62 fi
63
64 # Compare results, ignoring possible difference of IPv4/IPv6 localhost address
65 localrewrite='s/=127\.0\.0\.1:/=LOCAL:/; s/=\[::1\]:/=LOCAL:/'
66 echoscip-shell system . . echo. "Filtering ldapsearch results..."
67 sedscip-shell system . . sed. -e "$localrewrite" < $SEARCHOUT | $LDIFFILTER > $SEARCHFLT
68 echoscip-shell system . . echo. "Filtering expected data..."
69 . $CONFFILTER < $MONITOROUT1 | sedscip-shell system . . sed. -e "$localrewrite" | $LDIFFILTER > $LDIFFLT
70 echoscip-shell system . . echo. "Comparing filter output..."
71 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
72
73 if testscip-shell system . . test. $? != 0 ; then
74 echoscip-shell system . . echo. "comparison failed - connection monitor output is not correct"
75 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
76 exit 1
77 fi
78
79 echoscip-shell system . . echo. "Using ldapsearch to read database monitor entries..."
80 $LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -H $URI1 \
81 'objectclass=*' \
82 structuralObjectClass entryDN namingContexts readOnly \
83 monitorIsShadow monitorContext \
84 > $SEARCHOUT 2>&1
85 RC=$?
86
87 if testscip-shell system . . test. $RC != 0 ; then
88 echoscip-shell system . . echo. "ldapsearch failed ($RC)!"
89 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
90 exit $RC
91 fi
92
93 echoscip-shell system . . echo. "Filtering ldapsearch results..."
94 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
95
96 echoscip-shell system . . echo. "Comparing filter output..."
97 $CMP $SEARCHFLT $MONITOROUT2 > $CMPOUT
98
99 if testscip-shell system . . test. $? != 0 ; then
100 echoscip-shell system . . echo. "comparison failed - database monitor output is not correct"
101 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
102 exit 1
103 fi
104
105 echoscip-shell system . . echo. "Using ldapsearch to read statistics monitor entries..."
106 $LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -H $URI1 \
107 '(|(cn=Entries)(cn=PDU)(cn=Referrals))' \
108 structuralObjectClass monitorCounter entryDN \
109 > $SEARCHOUT 2>&1
110 RC=$?
111
112 if testscip-shell system . . test. $RC != 0 ; then
113 echoscip-shell system . . echo. "ldapsearch failed ($RC)!"
114 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
115 exit $RC
116 fi
117
118 echoscip-shell system . . echo. "Filtering ldapsearch results..."
119 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
120
121 echoscip-shell system . . echo. "Comparing filter output..."
122 $CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT
123
124 if testscip-shell system . . test. $? != 0 ; then
125 echoscip-shell system . . echo. "comparison failed - statistics monitor output is not correct"
126 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
127 exit 1
128 fi
129
130 echoscip-shell system . . echo. "Using ldapsearch to read operation monitor entries..."
131 $LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -H $URI1 \
132 'objectclass=*' \
133 structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \
134 > $SEARCHOUT 2>&1
135 RC=$?
136
137 if testscip-shell system . . test. $RC != 0 ; then
138 echoscip-shell system . . echo. "ldapsearch failed ($RC)!"
139 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
140 exit $RC
141 fi
142
143 echoscip-shell system . . echo. "Filtering ldapsearch results..."
144 $LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT
145
146 echoscip-shell system . . echo. "Comparing filter output..."
147 $CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT
148
149 if testscip-shell system . . test. $? != 0 ; then
150 echoscip-shell system . . echo. "comparison failed - operations monitor output is not correct"
151 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
152 exit 1
153 fi
154
155 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
156
157 echoscip-shell system . . echo. ">>>>> Test succeeded"
158
159 testscip-shell system . . test. $KILLSERVERS != no && wait
160
161 exit 0
162