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