Home | History | Annotate | Line # | Download | only in scripts
test056-monitor revision 1.1
      1  1.1  lukem #! /bin/sh
      2  1.1  lukem # OpenLDAP: pkg/ldap/tests/scripts/test056-monitor,v 1.2.2.5 2009/08/17 17:43:01 quanah Exp
      3  1.1  lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4  1.1  lukem ##
      5  1.1  lukem ## Copyright 1998-2008 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 if test $MONITORDB = "no" ; then 
     20  1.1  lukem 	echo "Monitor backend not available, test skipped"
     21  1.1  lukem 	exit 0
     22  1.1  lukem fi 
     23  1.1  lukem 
     24  1.1  lukem mkdir -p $TESTDIR $DBDIR1
     25  1.1  lukem 
     26  1.1  lukem echo "Starting slapd on TCP/IP port $PORT..."
     27  1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $SCHEMACONF > $CONF1
     28  1.1  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     29  1.1  lukem PID=$!
     30  1.1  lukem if test $WAIT != 0 ; then
     31  1.1  lukem     echo PID $PID
     32  1.1  lukem     read foo
     33  1.1  lukem fi
     34  1.1  lukem KILLPIDS="$PID"
     35  1.1  lukem 
     36  1.1  lukem sleep 1
     37  1.1  lukem 
     38  1.1  lukem echo "Using ldapsearch to check that slapd is running..."
     39  1.1  lukem for i in 0 1 2 3 4 5; do
     40  1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     41  1.1  lukem 		'objectclass=*' > /dev/null 2>&1
     42  1.1  lukem 	RC=$?
     43  1.1  lukem 	if test $RC = 0 ; then
     44  1.1  lukem 		break
     45  1.1  lukem 	fi
     46  1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
     47  1.1  lukem 	sleep 5
     48  1.1  lukem done
     49  1.1  lukem 
     50  1.1  lukem echo "Using ldapsearch to read connection monitor entries..."
     51  1.1  lukem $LDAPSEARCH -S "" -b "$CONNECTIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
     52  1.1  lukem 	'objectclass=*' \
     53  1.1  lukem 	structuralObjectClass entryDN \
     54  1.1  lukem 	monitorConnectionProtocol monitorConnectionOpsReceived \
     55  1.1  lukem 	monitorConnectionOpsExecuting monitorConnectionOpsPending \
     56  1.1  lukem 	monitorConnectionOpsCompleted monitorConnectionGet \
     57  1.1  lukem 	monitorConnectionRead monitorConnectionWrite \
     58  1.1  lukem 	monitorConnectionMask monitorConnectionAuthzDN \
     59  1.1  lukem 	monitorConnectionListener monitorConnectionLocalAddress \
     60  1.1  lukem 	> $SEARCHOUT 2>&1
     61  1.1  lukem RC=$?
     62  1.1  lukem 
     63  1.1  lukem if test $RC != 0 ; then
     64  1.1  lukem         echo "ldapsearch failed ($RC)!"
     65  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     66  1.1  lukem         exit $RC
     67  1.1  lukem fi
     68  1.1  lukem 
     69  1.1  lukem # Compare results, ignoring possible difference of IPv4/IPv6 localhost address
     70  1.1  lukem localrewrite='s/=127\.0\.0\.1:/=LOCAL:/; s/=\[::1\]:/=LOCAL:/'
     71  1.1  lukem echo "Filtering ldapsearch results..."
     72  1.1  lukem sed -e "$localrewrite" < $SEARCHOUT   | . $LDIFFILTER > $SEARCHFLT
     73  1.1  lukem echo "Filtering expected data..."
     74  1.1  lukem . $CONFFILTER < $MONITOROUT1 | sed -e "$localrewrite" | . $LDIFFILTER > $LDIFFLT
     75  1.1  lukem echo "Comparing filter output..."
     76  1.1  lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
     77  1.1  lukem 
     78  1.1  lukem if test $? != 0 ; then
     79  1.1  lukem         echo "comparison failed - connection monitor output is not correct"
     80  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     81  1.1  lukem         exit 1
     82  1.1  lukem fi
     83  1.1  lukem 
     84  1.1  lukem echo "Using ldapsearch to read database monitor entries..."
     85  1.1  lukem $LDAPSEARCH -S "" -b "$DATABASESMONITORDN" -h $LOCALHOST -p $PORT1 \
     86  1.1  lukem 	'objectclass=*' \
     87  1.1  lukem 	structuralObjectClass entryDN namingContexts readOnly \
     88  1.1  lukem 	monitorIsShadow monitorContext \
     89  1.1  lukem 	olmBDBEntryCache olmBDBDNCache olmBDBIDLCache \
     90  1.1  lukem 	> $SEARCHOUT 2>&1
     91  1.1  lukem RC=$?
     92  1.1  lukem 
     93  1.1  lukem if test $RC != 0 ; then
     94  1.1  lukem         echo "ldapsearch failed ($RC)!"
     95  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     96  1.1  lukem         exit $RC
     97  1.1  lukem fi
     98  1.1  lukem 
     99  1.1  lukem echo "Filtering ldapsearch results..."
    100  1.1  lukem . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    101  1.1  lukem 
    102  1.1  lukem TMPMONITOROUT2=$MONITOROUT2
    103  1.1  lukem case $BACKEND in
    104  1.1  lukem bdb|hdb)
    105  1.1  lukem 	;;
    106  1.1  lukem *)
    107  1.1  lukem 	TMPMONITOROUT2=$TESTDIR/monitor2.out
    108  1.1  lukem 	grep -v "olmBDB" $MONITOROUT2 > $TMPMONITOROUT2
    109  1.1  lukem 	;;
    110  1.1  lukem esac
    111  1.1  lukem 
    112  1.1  lukem echo "Comparing filter output..."
    113  1.1  lukem $CMP $SEARCHFLT $TMPMONITOROUT2 > $CMPOUT
    114  1.1  lukem 
    115  1.1  lukem if test $? != 0 ; then
    116  1.1  lukem         echo "comparison failed - database monitor output is not correct"
    117  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    118  1.1  lukem         exit 1
    119  1.1  lukem fi
    120  1.1  lukem 
    121  1.1  lukem echo "Using ldapsearch to read statistics monitor entries..."
    122  1.1  lukem $LDAPSEARCH -S "" -b "$STATISTICSMONITORDN" -h $LOCALHOST -p $PORT1 \
    123  1.1  lukem 	'(|(cn=Entries)(cn=PDU)(cn=Referrals))' \
    124  1.1  lukem 	structuralObjectClass monitorCounter entryDN \
    125  1.1  lukem 	> $SEARCHOUT 2>&1
    126  1.1  lukem RC=$?
    127  1.1  lukem 
    128  1.1  lukem if test $RC != 0 ; then
    129  1.1  lukem         echo "ldapsearch failed ($RC)!"
    130  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    131  1.1  lukem         exit $RC
    132  1.1  lukem fi
    133  1.1  lukem 
    134  1.1  lukem echo "Filtering ldapsearch results..."
    135  1.1  lukem . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    136  1.1  lukem 
    137  1.1  lukem echo "Comparing filter output..."
    138  1.1  lukem $CMP $SEARCHFLT $MONITOROUT3 > $CMPOUT
    139  1.1  lukem 
    140  1.1  lukem if test $? != 0 ; then
    141  1.1  lukem         echo "comparison failed - statistics monitor output is not correct"
    142  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    143  1.1  lukem         exit 1
    144  1.1  lukem fi
    145  1.1  lukem 
    146  1.1  lukem echo "Using ldapsearch to read operation monitor entries..."
    147  1.1  lukem $LDAPSEARCH -S "" -b "$OPERATIONSMONITORDN" -h $LOCALHOST -p $PORT1 \
    148  1.1  lukem 	'objectclass=*' \
    149  1.1  lukem 	structuralObjectClass monitorOpInitiated monitorOpCompleted entryDN \
    150  1.1  lukem 	> $SEARCHOUT 2>&1
    151  1.1  lukem RC=$?
    152  1.1  lukem 
    153  1.1  lukem if test $RC != 0 ; then
    154  1.1  lukem         echo "ldapsearch failed ($RC)!"
    155  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    156  1.1  lukem         exit $RC
    157  1.1  lukem fi
    158  1.1  lukem 
    159  1.1  lukem echo "Filtering ldapsearch results..."
    160  1.1  lukem . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    161  1.1  lukem 
    162  1.1  lukem echo "Comparing filter output..."
    163  1.1  lukem $CMP $SEARCHFLT $MONITOROUT4 > $CMPOUT
    164  1.1  lukem 
    165  1.1  lukem if test $? != 0 ; then
    166  1.1  lukem         echo "comparison failed - operations monitor output is not correct"
    167  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    168  1.1  lukem         exit 1
    169  1.1  lukem fi
    170  1.1  lukem 
    171  1.1  lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    172  1.1  lukem 
    173  1.1  lukem echo ">>>>> Test succeeded"
    174  1.1  lukem 
    175  1.1  lukem test $KILLSERVERS != no && wait
    176  1.1  lukem 
    177  1.1  lukem exit 0
    178  1.1  lukem 
    179