Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test033-glue-syncrepl
blobe8ee1f89696597821df240425437da5c4ef3dbfb
1 #! /bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 1998-2008 The OpenLDAP Foundation.
5 ## All rights reserved.
6 ##
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
9 ## Public License.
11 ## A copy of this license is available in the file LICENSE in the
12 ## top-level directory of the distribution or, alternatively, at
13 ## <http://www.OpenLDAP.org/license.html>.
15 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
16 echo "Test does not support $BACKEND"
17 exit 0
20 echo "running defines.sh"
21 . $SRCDIR/scripts/defines.sh
23 if test $SYNCPROV = syncprovno; then
24 echo "Syncrepl provider overlay not available, test skipped"
25 exit 0
26 fi
28 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B
30 echo "Running slapadd to build glued slapd databases..."
31 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
32 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
33 RC=$?
34 if test $RC != 0 ; then
35 echo "slapadd failed ($RC)!"
36 exit $RC
39 rm -f $DBDIR1A/* $DBDIR1B/*
40 cp -pr $DBDIR1C $DBDIR2C
42 echo "Starting slapd 1 on TCP/IP port $PORT1..."
43 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1
44 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
45 PID=$!
46 if test $WAIT != 0 ; then
47 echo PID $PID
48 read foo
50 KILLPIDS="$PID"
52 sleep 1
54 echo "Using ldapsearch to check that slapd 1 is running..."
55 for i in 0 1 2 3 4 5; do
56 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
57 '(objectclass=*)' > /dev/null 2>&1
58 RC=$?
59 if test $RC = 0 ; then
60 break
62 echo "Waiting 5 seconds for slapd to start..."
63 sleep 5
64 done
66 echo "Starting slapd 2 on TCP/IP port $PORT2..."
67 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
68 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
69 PID=$!
70 if test $WAIT != 0 ; then
71 echo PID $PID
72 read foo
74 KILLPIDS="$KILLPIDS $PID"
76 sleep 1
78 echo "Using ldapsearch to check that slapd 2 is running..."
79 for i in 0 1 2 3 4 5; do
80 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
81 '(objectclass=*)' > /dev/null 2>&1
82 RC=$?
83 if test $RC = 0 ; then
84 break
86 echo "Waiting 5 seconds for slapd to start..."
87 sleep 5
88 done
90 SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com"
91 SUBTREE2="ou=Groups,dc=example,dc=com"
93 echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..."
94 $LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
95 -f $LDIFORDERED -c \
96 > /dev/null 2>&1
97 RC=$?
98 case $RC in
100 echo "ldapadd should have failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 exit -1
104 10|68)
105 # Fine if we get alreadyExists or referrals
108 echo "ldapadd failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
110 exit $RC
112 esac
114 echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..."
115 $LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT2 \
116 -f $LDIFORDERED -c \
117 > /dev/null 2>&1
118 RC=$?
119 case $RC in
121 echo "ldapadd should have failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 exit -1
125 10|68)
126 # Fine if we get alreadyExists or referrals
129 echo "ldapadd failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 exit $RC
133 esac
135 SLEEP=15
136 echo "Waiting $SLEEP seconds for shadow subtrees to sync..."
137 sleep $SLEEP
139 echo "Filtering original ldif used to create database..."
140 . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
142 for P in $PORT1 $PORT2 ; do
143 echo "Using ldapsearch to read all the entries from port $P..."
144 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
145 -S "" '(objectclass=*)' > "${SEARCHOUT}.${P}" 2>&1
146 RC=$?
148 if test $RC != 0 ; then
149 echo "ldapsearch failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 exit $RC
154 echo "Filtering ldapsearch results..."
155 . $LDIFFILTER < "${SEARCHOUT}.${P}" > $SEARCHFLT
156 echo "Comparing filter output..."
157 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
159 if test $? != 0 ; then
160 echo "comparison failed - database was not created correctly"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 exit 1
164 done
166 echo "Testing ldapdelete propagation..."
167 $LDAPDELETE -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 "$BABSDN" \
168 > $TESTOUT 2>&1
169 RC=$?
170 if test $RC != 0 ; then
171 echo "ldapdelete failed ($RC)!"
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 exit $RC
176 # This usually propagates immediately
177 sleep 1
179 $LDAPSEARCH -H $URI2 -b "$BABSDN" > $TESTOUT 2>&1
180 RC=$?
181 if test $RC = 0 ; then
182 echo "ldapsearch should have failed ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 exit -1
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 echo ">>>>> Test succeeded"
191 test $KILLSERVERS != no && wait
193 exit 0