14e6df137Slukem#! /bin/sh 2d11b170bStron# $OpenLDAP$ 34e6df137Slukem## This work is part of OpenLDAP Software <http://www.openldap.org/>. 44e6df137Slukem## 5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation. 64e6df137Slukem## All rights reserved. 74e6df137Slukem## 84e6df137Slukem## Redistribution and use in source and binary forms, with or without 94e6df137Slukem## modification, are permitted only as authorized by the OpenLDAP 104e6df137Slukem## Public License. 114e6df137Slukem## 124e6df137Slukem## A copy of this license is available in the file LICENSE in the 134e6df137Slukem## top-level directory of the distribution or, alternatively, at 144e6df137Slukem## <http://www.OpenLDAP.org/license.html>. 154e6df137Slukem 164e6df137Slukemecho "running defines.sh" 174e6df137Slukem. $SRCDIR/scripts/defines.sh 184e6df137Slukem 194e6df137Slukemmkdir -p $TESTDIR $DBDIR1 204e6df137Slukem 214e6df137Slukemecho "Starting slapd on TCP/IP port $PORT..." 22*e670fd5cSchristos. $CONFFILTER $BACKEND < $SCHEMACONF > $CONF1 23*e670fd5cSchristos$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 244e6df137SlukemPID=$! 254e6df137Slukemif test $WAIT != 0 ; then 264e6df137Slukem echo PID $PID 274e6df137Slukem read foo 284e6df137Slukemfi 294e6df137SlukemKILLPIDS="$PID" 304e6df137Slukem 314e6df137Slukemsleep 1 324e6df137Slukem 334e6df137Slukemecho "Using ldapsearch to check that slapd is running..." 344e6df137Slukemfor i in 0 1 2 3 4 5; do 35*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 364e6df137Slukem 'objectclass=*' > /dev/null 2>&1 374e6df137Slukem RC=$? 384e6df137Slukem if test $RC = 0 ; then 394e6df137Slukem break 404e6df137Slukem fi 414e6df137Slukem echo "Waiting 5 seconds for slapd to start..." 424e6df137Slukem sleep 5 434e6df137Slukemdone 444e6df137Slukem 454e6df137Slukemecho "Using ldapsearch to read connection monitor entries..." 46*e670fd5cSchristos$LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -H $URI1 \ 474e6df137Slukem 'objectclass=*' \ 484e6df137Slukem structuralObjectClass entryDN \ 494e6df137Slukem monitorConnectionProtocol monitorConnectionOpsReceived \ 504e6df137Slukem monitorConnectionOpsExecuting monitorConnectionOpsPending \ 514e6df137Slukem monitorConnectionOpsCompleted monitorConnectionGet \ 524e6df137Slukem monitorConnectionRead monitorConnectionWrite \ 534e6df137Slukem monitorConnectionMask monitorConnectionAuthzDN \ 544e6df137Slukem monitorConnectionListener monitorConnectionLocalAddress \ 554e6df137Slukem > $SEARCHOUT 2>&1 564e6df137SlukemRC=$? 574e6df137Slukem 584e6df137Slukemif test $RC != 0 ; then 594e6df137Slukem echo "ldapsearch failed ($RC)!" 604e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 614e6df137Slukem exit $RC 624e6df137Slukemfi 634e6df137Slukem 644e6df137Slukem# Compare results, ignoring possible difference of IPv4/IPv6 localhost address 654e6df137Slukemlocalrewrite='s/=127\.0\.0\.1:/=LOCAL:/; s/=\[::1\]:/=LOCAL:/' 664e6df137Slukemecho "Filtering ldapsearch results..." 67ef2f90d3Sadamsed -e "$localrewrite" < $SEARCHOUT | $LDIFFILTER > $SEARCHFLT 684e6df137Slukemecho "Filtering expected data..." 69ef2f90d3Sadam. $CONFFILTER < $MONITOROUT1 | sed -e "$localrewrite" | $LDIFFILTER > $LDIFFLT 704e6df137Slukemecho "Comparing filter output..." 714e6df137Slukem$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 724e6df137Slukem 734e6df137Slukemif test $? != 0 ; then 744e6df137Slukem echo "comparison failed - connection monitor output is not correct" 754e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 764e6df137Slukem exit 1 774e6df137Slukemfi 784e6df137Slukem 794e6df137Slukemecho "Using ldapsearch to read database monitor entries..." 80*e670fd5cSchristos$LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -H $URI1 \ 814e6df137Slukem 'objectclass=*' \ 824e6df137Slukem structuralObjectClass entryDN namingContexts readOnly \ 834e6df137Slukem monitorIsShadow monitorContext \ 844e6df137Slukem > $SEARCHOUT 2>&1 854e6df137SlukemRC=$? 864e6df137Slukem 874e6df137Slukemif test $RC != 0 ; then 884e6df137Slukem echo "ldapsearch failed ($RC)!" 894e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 904e6df137Slukem exit $RC 914e6df137Slukemfi 924e6df137Slukem 934e6df137Slukemecho "Filtering ldapsearch results..." 94ef2f90d3Sadam$LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT 954e6df137Slukem 964e6df137Slukemecho "Comparing filter output..." 97*e670fd5cSchristos$CMP $SEARCHFLT $MONITOROUT2 > $CMPOUT 984e6df137Slukem 994e6df137Slukemif test $? != 0 ; then 1004e6df137Slukem echo "comparison failed - database monitor output is not correct" 1014e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 1024e6df137Slukem exit 1 1034e6df137Slukemfi 1044e6df137Slukem 1054e6df137Slukemecho "Using ldapsearch to read statistics monitor entries..." 106*e670fd5cSchristos$LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -H $URI1 \ 1074e6df137Slukem '(|(cn=Entries)(cn=PDU)(cn=Referrals))' \ 1084e6df137Slukem structuralObjectClass monitorCounter entryDN \ 1094e6df137Slukem > $SEARCHOUT 2>&1 1104e6df137SlukemRC=$? 1114e6df137Slukem 1124e6df137Slukemif test $RC != 0 ; then 1134e6df137Slukem echo "ldapsearch failed ($RC)!" 1144e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 1154e6df137Slukem exit $RC 1164e6df137Slukemfi 1174e6df137Slukem 1184e6df137Slukemecho "Filtering ldapsearch results..." 119ef2f90d3Sadam$LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT 1204e6df137Slukem 1214e6df137Slukemecho "Comparing filter output..." 1224e6df137Slukem$CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT 1234e6df137Slukem 1244e6df137Slukemif test $? != 0 ; then 1254e6df137Slukem echo "comparison failed - statistics monitor output is not correct" 1264e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 1274e6df137Slukem exit 1 1284e6df137Slukemfi 1294e6df137Slukem 1304e6df137Slukemecho "Using ldapsearch to read operation monitor entries..." 131*e670fd5cSchristos$LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -H $URI1 \ 1324e6df137Slukem 'objectclass=*' \ 1334e6df137Slukem structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \ 1344e6df137Slukem > $SEARCHOUT 2>&1 1354e6df137SlukemRC=$? 1364e6df137Slukem 1374e6df137Slukemif test $RC != 0 ; then 1384e6df137Slukem echo "ldapsearch failed ($RC)!" 1394e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 1404e6df137Slukem exit $RC 1414e6df137Slukemfi 1424e6df137Slukem 1434e6df137Slukemecho "Filtering ldapsearch results..." 144ef2f90d3Sadam$LDIFFILTER -b monitor < $SEARCHOUT > $SEARCHFLT 1454e6df137Slukem 1464e6df137Slukemecho "Comparing filter output..." 1474e6df137Slukem$CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT 1484e6df137Slukem 1494e6df137Slukemif test $? != 0 ; then 1504e6df137Slukem echo "comparison failed - operations monitor output is not correct" 1514e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 1524e6df137Slukem exit 1 1534e6df137Slukemfi 1544e6df137Slukem 1554e6df137Slukemtest $KILLSERVERS != no && kill -HUP $KILLPIDS 1564e6df137Slukem 1574e6df137Slukemecho ">>>>> Test succeeded" 1584e6df137Slukem 1594e6df137Slukemtest $KILLSERVERS != no && wait 1604e6df137Slukem 1614e6df137Slukemexit 0 1624e6df137Slukem 163