]> git.sur5r.net Git - openldap/blob - tests/scripts/test033-glue-syncrepl
5f2bfbc8f7b34bf7de7b9536ca84a1376a32b2c2
[openldap] / tests / scripts / test033-glue-syncrepl
1 #! /bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 1998-2005 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.
10 ##
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>.
14
15 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
16         echo "Test does not support $BACKEND"
17         exit 0
18 fi
19
20 echo "running defines.sh"
21 . $SRCDIR/scripts/defines.sh
22
23 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B $DBDIR2C
24
25 echo "Starting slapd 1 on TCP/IP port $PORT1..."
26 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1
27 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
28 PID=$!
29 if test $WAIT != 0 ; then
30     echo PID $PID
31     read foo
32 fi
33 KILLPIDS="$PID"
34
35 sleep 1
36
37 echo "Using ldapsearch to check that slapd 1 is running..."
38 for i in 0 1 2 3 4 5; do
39         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
40                 '(objectclass=*)' > /dev/null 2>&1
41         RC=$?
42         if test $RC = 0 ; then
43                 break
44         fi
45         echo "Waiting 5 seconds for slapd to start..."
46         sleep 5
47 done
48
49 echo "Starting slapd 2 on TCP/IP port $PORT2..."
50 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
51 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
52 PID=$!
53 if test $WAIT != 0 ; then
54     echo PID $PID
55     read foo
56 fi
57 KILLPIDS="$KILLPIDS $PID"
58
59 sleep 1
60
61 echo "Using ldapsearch to check that slapd 2 is running..."
62 for i in 0 1 2 3 4 5; do
63         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
64                 '(objectclass=*)' > /dev/null 2>&1
65         RC=$?
66         if test $RC = 0 ; then
67                 break
68         fi
69         echo "Waiting 5 seconds for slapd to start..."
70         sleep 5
71 done
72
73 SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com"
74 SUBTREE2="ou=Groups,dc=example,dc=com"
75
76 for M in 1 2 ; do
77         P=`expr 9010 + $M`
78         echo "Using ldapadd to populate the common root on port $P..."
79         $LDAPADD -D "cn=Manager $M,$BASEDN" -w $PASSWD -h $LOCALHOST -p $P \
80                 -f $LDIFORDERED \
81                 -c -e\!assert="(&(!(entryDN:dnSubtreeMatch:=${SUBTREE1}))(!(entryDN:dnSubtreeMatch:=${SUBTREE2})))" \
82                 > /dev/null 2>&1
83         RC=$?
84         case $RC in
85         0)
86                 echo "ldapadd should have failed ($RC)!"
87                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88                 exit -1
89                 ;;
90         10|32|68)
91                 # FIXME: we should rather get ASSERT, and ignore it;
92                 # see <http://www.openldap.org/lists/openldap-software/200512/msg00250.html>
93                 # for details.
94                 # Fine by now if we get noSuchObject, alreadyExists
95                 # or referrals
96                 ;;
97         *)
98                 echo "ldapadd failed ($RC)!"
99                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100                 exit $RC
101                 ;;
102         esac
103 done
104
105 echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..."
106 $LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
107         -f $LDIFORDERED \
108         -c -e\!assert="(entryDN:dnSubtreeMatch:=${SUBTREE1})" \
109         > /dev/null 2>&1
110 RC=$?
111 case $RC in
112 0)
113         echo "ldapadd should have failed ($RC)!"
114         test $KILLSERVERS != no && kill -HUP $KILLPIDS
115         exit -1
116         ;;
117 10|32|68)
118         # FIXME: we should rather get ASSERT, and ignore it;
119         # see <http://www.openldap.org/lists/openldap-software/200512/msg00250.html>
120         # for details.
121         # Fine by now if we get noSuchObject, alreadyExists
122         # or referrals
123         ;;
124 *)
125         echo "ldapadd failed ($RC)!"
126         test $KILLSERVERS != no && kill -HUP $KILLPIDS
127         exit $RC
128         ;;
129 esac
130
131 echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..."
132 $LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT2 \
133         -f $LDIFORDERED \
134         -c -e\!assert="(entryDN:dnSubtreeMatch:=${SUBTREE2})" \
135         > /dev/null 2>&1
136 RC=$?
137 case $RC in
138 0)
139         echo "ldapadd should have failed ($RC)!"
140         test $KILLSERVERS != no && kill -HUP $KILLPIDS
141         exit -1
142         ;;
143 10|32|68)
144         # FIXME: we should rather get ASSERT, and ignore it;
145         # see <http://www.openldap.org/lists/openldap-software/200512/msg00250.html>
146         # for details.
147         # Fine by now if we get noSuchObject, alreadyExists
148         # or referrals
149         ;;
150 *)
151         echo "ldapadd failed ($RC)!"
152         test $KILLSERVERS != no && kill -HUP $KILLPIDS
153         exit $RC
154         ;;
155 esac
156
157 SLEEP=15
158 echo "Waiting $SLEEP seconds for shadow subtrees to sync..."
159 sleep $SLEEP
160
161 echo "Filtering original ldif used to create database..."
162 . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
163
164 for P in $PORT1 $PORT2 ; do
165         echo "Using ldapsearch to read all the entries from port $P..."
166         $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
167                 -S "" '(objectclass=*)' > "${SEARCHOUT}.${P}" 2>&1
168         RC=$?
169
170         if test $RC != 0 ; then
171                 echo "ldapsearch failed ($RC)!"
172                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173                 exit $RC
174         fi
175
176         echo "Filtering ldapsearch results..."
177         . $LDIFFILTER < "${SEARCHOUT}.${P}" > $SEARCHFLT
178         echo "Comparing filter output..."
179         $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
180
181         if test $? != 0 ; then
182                 echo "comparison failed - database was not created correctly"
183                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184                 exit 1
185         fi
186 done
187
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189
190 echo ">>>>> Test succeeded"
191 exit 0