3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2016 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B
26 echo "Running slapadd to build glued slapd databases..."
27 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
28 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
35 rm -rf $DBDIR1A/* $DBDIR1B/*
36 cp -pr $DBDIR1C $DBDIR2C
38 echo "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 &
42 if test $WAIT != 0 ; then
50 echo "Using ldapsearch to check that slapd 1 is running..."
51 for 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
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
62 echo "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 &
66 if test $WAIT != 0 ; then
70 KILLPIDS="$KILLPIDS $PID"
74 echo "Using ldapsearch to check that slapd 2 is running..."
75 for 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
79 if test $RC = 0 ; then
82 echo "Waiting 5 seconds for slapd to start..."
86 SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com"
87 SUBTREE2="ou=Groups,dc=example,dc=com"
89 echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..."
90 $LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
96 echo "ldapadd should have failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 # Fine if we get alreadyExists or referrals
104 echo "ldapadd failed ($RC)!"
105 test $KILLSERVERS != no && kill -HUP $KILLPIDS
110 echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..."
111 $LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT2 \
117 echo "ldapadd should have failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
122 # Fine if we get alreadyExists or referrals
125 echo "ldapadd failed ($RC)!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Waiting $SLEEP1 seconds for shadow subtrees to sync..."
134 echo "Filtering original ldif used to create database..."
135 $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
137 for 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
143 if test $RC != 0 ; then
144 echo "ldapsearch failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Filtering ldapsearch results..."
150 $LDIFFILTER < "${SEARCHOUT}.${P}" > $SEARCHFLT
151 echo "Comparing filter output..."
152 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
154 if test $? != 0 ; then
155 echo "comparison failed - database was not created correctly"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 echo "Testing ldapdelete propagation..."
162 $LDAPDELETE -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 "$BABSDN" \
165 if test $RC != 0 ; then
166 echo "ldapdelete failed ($RC)!"
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
171 # This usually propagates immediately
174 $LDAPSEARCH -H $URI2 -b "$BABSDN" > $TESTOUT 2>&1
176 if test $RC = 0 && test $BACKEND != null ; then
177 echo "ldapsearch should have failed ($RC)!"
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
182 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 echo ">>>>> Test succeeded"
186 test $KILLSERVERS != no && wait