From b64a6cddd397dd7313900f379e7218d6a4268a0b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 27 Jan 2009 10:09:51 +0000 Subject: [PATCH] ITS#5540 sean-burford-monitor-test-080706.patch --- tests/data/monitor1.out | 31 +++++++ tests/data/monitor2.out | 40 +++++++++ tests/data/monitor3.out | 15 ++++ tests/data/monitor4.out | 66 ++++++++++++++ tests/scripts/test056-monitor | 160 ++++++++++++++++++++++++++++++++++ 5 files changed, 312 insertions(+) create mode 100644 tests/data/monitor1.out create mode 100644 tests/data/monitor2.out create mode 100644 tests/data/monitor3.out create mode 100644 tests/data/monitor4.out create mode 100755 tests/scripts/test056-monitor diff --git a/tests/data/monitor1.out b/tests/data/monitor1.out new file mode 100644 index 0000000000..8b394dfe92 --- /dev/null +++ b/tests/data/monitor1.out @@ -0,0 +1,31 @@ +dn: cn=Connection 1,cn=Connections,cn=Monitor +structuralObjectClass: monitorConnection +monitorConnectionProtocol: 3 +monitorConnectionOpsReceived: 2 +monitorConnectionOpsExecuting: 1 +monitorConnectionOpsPending: 0 +monitorConnectionOpsCompleted: 1 +monitorConnectionGet: 2 +monitorConnectionRead: 2 +monitorConnectionWrite: 0 +monitorConnectionMask: rx +monitorConnectionListener: ldap://localhost:9011/ +monitorConnectionLocalAddress: IP=127.0.0.1:9011 +entryDN: cn=Connection 1,cn=Connections,cn=Monitor + +dn: cn=Connections,cn=Monitor +structuralObjectClass: monitorContainer +entryDN: cn=Connections,cn=Monitor + +dn: cn=Current,cn=Connections,cn=Monitor +structuralObjectClass: monitorCounterObject +entryDN: cn=Current,cn=Connections,cn=Monitor + +dn: cn=Max File Descriptors,cn=Connections,cn=Monitor +structuralObjectClass: monitorCounterObject +entryDN: cn=Max File Descriptors,cn=Connections,cn=Monitor + +dn: cn=Total,cn=Connections,cn=Monitor +structuralObjectClass: monitorCounterObject +entryDN: cn=Total,cn=Connections,cn=Monitor + diff --git a/tests/data/monitor2.out b/tests/data/monitor2.out new file mode 100644 index 0000000000..26e9ce9ecb --- /dev/null +++ b/tests/data/monitor2.out @@ -0,0 +1,40 @@ +dn: cn=Database 0,cn=Databases,cn=Monitor +structuralObjectClass: monitoredObject +monitorIsShadow: FALSE +namingContexts: cn=config +readOnly: FALSE +entryDN: cn=Database 0,cn=Databases,cn=Monitor + +dn: cn=Database 1,cn=Databases,cn=Monitor +structuralObjectClass: monitoredObject +monitorIsShadow: FALSE +namingContexts: o=OpenLDAP Project,l=Internet +readOnly: FALSE +olmBDBEntryCache: 0 +olmBDBDNCache: 0 +olmBDBIDLCache: 0 +entryDN: cn=Database 1,cn=Databases,cn=Monitor + +dn: cn=Database 2,cn=Databases,cn=Monitor +structuralObjectClass: monitoredObject +monitorIsShadow: FALSE +monitorContext: cn=Monitor +readOnly: FALSE +entryDN: cn=Database 2,cn=Databases,cn=Monitor + +dn: cn=Databases,cn=Monitor +structuralObjectClass: monitorContainer +readOnly: FALSE +namingContexts: +namingContexts: cn=config +namingContexts: o=OpenLDAP Project,l=Internet +monitorContext: cn=Monitor +entryDN: cn=Databases,cn=Monitor + +dn: cn=Frontend,cn=Databases,cn=Monitor +structuralObjectClass: monitoredObject +monitorIsShadow: FALSE +namingContexts: +readOnly: FALSE +entryDN: cn=Frontend,cn=Databases,cn=Monitor + diff --git a/tests/data/monitor3.out b/tests/data/monitor3.out new file mode 100644 index 0000000000..b40e98b434 --- /dev/null +++ b/tests/data/monitor3.out @@ -0,0 +1,15 @@ +dn: cn=Entries,cn=Statistics,cn=Monitor +structuralObjectClass: monitorCounterObject +monitorCounter: 12 +entryDN: cn=Entries,cn=Statistics,cn=Monitor + +dn: cn=PDU,cn=Statistics,cn=Monitor +structuralObjectClass: monitorCounterObject +monitorCounter: 18 +entryDN: cn=PDU,cn=Statistics,cn=Monitor + +dn: cn=Referrals,cn=Statistics,cn=Monitor +structuralObjectClass: monitorCounterObject +monitorCounter: 0 +entryDN: cn=Referrals,cn=Statistics,cn=Monitor + diff --git a/tests/data/monitor4.out b/tests/data/monitor4.out new file mode 100644 index 0000000000..f6e82d349e --- /dev/null +++ b/tests/data/monitor4.out @@ -0,0 +1,66 @@ +dn: cn=Abandon,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Abandon,cn=Operations,cn=Monitor + +dn: cn=Add,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Add,cn=Operations,cn=Monitor + +dn: cn=Bind,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 5 +monitorOpCompleted: 5 +entryDN: cn=Bind,cn=Operations,cn=Monitor + +dn: cn=Compare,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Compare,cn=Operations,cn=Monitor + +dn: cn=Delete,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Delete,cn=Operations,cn=Monitor + +dn: cn=Extended,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Extended,cn=Operations,cn=Monitor + +dn: cn=Modify,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Modify,cn=Operations,cn=Monitor + +dn: cn=Modrdn,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 0 +monitorOpCompleted: 0 +entryDN: cn=Modrdn,cn=Operations,cn=Monitor + +dn: cn=Operations,cn=Monitor +structuralObjectClass: monitorContainer +monitorOpInitiated: 14 +monitorOpCompleted: 13 +entryDN: cn=Operations,cn=Monitor + +dn: cn=Search,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 5 +monitorOpCompleted: 4 +entryDN: cn=Search,cn=Operations,cn=Monitor + +dn: cn=Unbind,cn=Operations,cn=Monitor +structuralObjectClass: monitorOperation +monitorOpInitiated: 4 +monitorOpCompleted: 4 +entryDN: cn=Unbind,cn=Operations,cn=Monitor + diff --git a/tests/scripts/test056-monitor b/tests/scripts/test056-monitor new file mode 100755 index 0000000000..35ae2077a7 --- /dev/null +++ b/tests/scripts/test056-monitor @@ -0,0 +1,160 @@ +#! /bin/sh +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2008 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## . + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +mkdir -p $TESTDIR $DBDIR1 + +echo "Starting slapd on TCP/IP port $PORT..." +. $CONFFILTER $BACKEND $MONITORDB < $SCHEMACONF > $CONF1 +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +sleep 1 + +echo "Using ldapsearch to check that slapd is running..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +echo "Using ldapsearch to read connection monitor entries..." +$LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' \ + structuralObjectClass entryDN \ + monitorConnectionProtocol monitorConnectionOpsReceived \ + monitorConnectionOpsExecuting monitorConnectionOpsPending \ + monitorConnectionOpsCompleted monitorConnectionGet \ + monitorConnectionRead monitorConnectionWrite \ + monitorConnectionMask monitorConnectionAuthzDN \ + monitorConnectionListener monitorConnectionLocalAddress \ + > $SEARCHOUT 2>&1 +RC=$? + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + +echo "Comparing filter output..." +$CMP $SEARCHFLT $MONITOROUT1 > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - connection monitor output is not correct" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +echo "Using ldapsearch to read database monitor entries..." +$LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' \ + structuralObjectClass entryDN namingContexts readOnly \ + monitorIsShadow monitorContext \ + olmBDBEntryCache olmBDBDNCache olmBDBIDLCache \ + > $SEARCHOUT 2>&1 +RC=$? + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + +echo "Comparing filter output..." +$CMP $SEARCHFLT $MONITOROUT2 > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - database monitor output is not correct" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +echo "Using ldapsearch to read statistics monitor entries..." +$LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -h $LOCALHOST -p $PORT1 \ + '(|(cn=Entries)(cn=PDU)(cn=Referrals))' \ + structuralObjectClass monitorCounter entryDN \ + > $SEARCHOUT 2>&1 +RC=$? + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + +echo "Comparing filter output..." +$CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - statistics monitor output is not correct" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +echo "Using ldapsearch to read operation monitor entries..." +$LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' \ + structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \ + > $SEARCHOUT 2>&1 +RC=$? + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + +echo "Comparing filter output..." +$CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - operations monitor output is not correct" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +echo ">>>>> Test succeeded" + +test $KILLSERVERS != no && wait + +exit 0 + -- 2.39.5