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