1#! /bin/sh 2# $OpenLDAP$ */ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2011 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 16echo "running defines.sh" 17. $SRCDIR/scripts/defines.sh 18 19if test $SYNCPROV = syncprovno; then 20 echo "Syncrepl provider overlay not available, test skipped" 21 exit 0 22fi 23 24mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B 25 26echo "Running slapadd to build glued slapd databases..." 27. $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1 28$SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1 29RC=$? 30if test $RC != 0 ; then 31 echo "slapadd failed ($RC)!" 32 exit $RC 33fi 34 35rm -rf $DBDIR1A/* $DBDIR1B/* 36cp -pr $DBDIR1C $DBDIR2C 37 38echo "Starting slapd 1 on TCP/IP port $PORT1..." 39. $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1 40$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 41PID=$! 42if test $WAIT != 0 ; then 43 echo PID $PID 44 read foo 45fi 46KILLPIDS="$PID" 47 48sleep 1 49 50echo "Using ldapsearch to check that slapd 1 is running..." 51for i in 0 1 2 3 4 5; do 52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ 53 '(objectclass=*)' > /dev/null 2>&1 54 RC=$? 55 if test $RC = 0 ; then 56 break 57 fi 58 echo "Waiting 5 seconds for slapd to start..." 59 sleep 5 60done 61 62echo "Starting slapd 2 on TCP/IP port $PORT2..." 63. $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2 64$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 & 65PID=$! 66if test $WAIT != 0 ; then 67 echo PID $PID 68 read foo 69fi 70KILLPIDS="$KILLPIDS $PID" 71 72sleep 1 73 74echo "Using ldapsearch to check that slapd 2 is running..." 75for i in 0 1 2 3 4 5; do 76 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \ 77 '(objectclass=*)' > /dev/null 2>&1 78 RC=$? 79 if test $RC = 0 ; then 80 break 81 fi 82 echo "Waiting 5 seconds for slapd to start..." 83 sleep 5 84done 85 86SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com" 87SUBTREE2="ou=Groups,dc=example,dc=com" 88 89echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..." 90$LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \ 91 -f $LDIFORDERED -c \ 92 > /dev/null 2>&1 93RC=$? 94case $RC in 950) 96 echo "ldapadd should have failed ($RC)!" 97 test $KILLSERVERS != no && kill -HUP $KILLPIDS 98 exit -1 99 ;; 10010|68) 101 # Fine if we get alreadyExists or referrals 102 ;; 103*) 104 echo "ldapadd failed ($RC)!" 105 test $KILLSERVERS != no && kill -HUP $KILLPIDS 106 exit $RC 107 ;; 108esac 109 110echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..." 111$LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT2 \ 112 -f $LDIFORDERED -c \ 113 > /dev/null 2>&1 114RC=$? 115case $RC in 1160) 117 echo "ldapadd should have failed ($RC)!" 118 test $KILLSERVERS != no && kill -HUP $KILLPIDS 119 exit -1 120 ;; 12110|68) 122 # Fine if we get alreadyExists or referrals 123 ;; 124*) 125 echo "ldapadd failed ($RC)!" 126 test $KILLSERVERS != no && kill -HUP $KILLPIDS 127 exit $RC 128 ;; 129esac 130 131echo "Waiting $SLEEP1 seconds for shadow subtrees to sync..." 132sleep $SLEEP1 133 134echo "Filtering original ldif used to create database..." 135$LDIFFILTER < $GLUESYNCOUT > $LDIFFLT 136 137for P in $PORT1 $PORT2 ; do 138 echo "Using ldapsearch to read all the entries from port $P..." 139 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \ 140 -S "" '(objectclass=*)' > "${SEARCHOUT}.${P}" 2>&1 141 RC=$? 142 143 if test $RC != 0 ; then 144 echo "ldapsearch failed ($RC)!" 145 test $KILLSERVERS != no && kill -HUP $KILLPIDS 146 exit $RC 147 fi 148 149 echo "Filtering ldapsearch results..." 150 $LDIFFILTER < "${SEARCHOUT}.${P}" > $SEARCHFLT 151 echo "Comparing filter output..." 152 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT 153 154 if test $? != 0 ; then 155 echo "comparison failed - database was not created correctly" 156 test $KILLSERVERS != no && kill -HUP $KILLPIDS 157 exit 1 158 fi 159done 160 161echo "Testing ldapdelete propagation..." 162$LDAPDELETE -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 "$BABSDN" \ 163 > $TESTOUT 2>&1 164RC=$? 165if test $RC != 0 ; then 166 echo "ldapdelete failed ($RC)!" 167 test $KILLSERVERS != no && kill -HUP $KILLPIDS 168 exit $RC 169fi 170 171# This usually propagates immediately 172sleep 1 173 174$LDAPSEARCH -H $URI2 -b "$BABSDN" > $TESTOUT 2>&1 175RC=$? 176if test $RC = 0 && test $BACKEND != null ; then 177 echo "ldapsearch should have failed ($RC)!" 178 test $KILLSERVERS != no && kill -HUP $KILLPIDS 179 exit -1 180fi 181 182test $KILLSERVERS != no && kill -HUP $KILLPIDS 183 184echo ">>>>> Test succeeded" 185 186test $KILLSERVERS != no && wait 187 188exit 0 189