]> git.sur5r.net Git - openldap/blob - tests/scripts/test011-subtree-repl
this will likely fix the problem with partial replication
[openldap] / tests / scripts / test011-subtree-repl
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "Test disabled."
5 exit 0
6
7 SRCDIR="."
8 if test $# -ge 1 ; then
9         SRCDIR=$1; shift
10 fi
11 BACKEND=bdb
12 if test $# -ge 1 ; then
13         BACKEND=$1; shift
14 fi
15 MONITORDB=no
16 if test $# -ge 1 ; then
17         MONITORDB=$1; shift
18 fi
19 WAIT=0
20 if test $# -ge 1 ; then
21         WAIT=1; shift
22 fi
23
24 echo "running defines.sh"
25 . $SRCDIR/scripts/defines.sh
26
27 #
28 # Test replication:
29 # - start master
30 # - start slave
31 # - create root entry in slave
32 # - start slurpd
33 # - populate over ldap
34 # - perform some modifies and deleted
35 # - retrieve database over ldap and compare against expected results
36 #
37
38 if test ! -x $SLURPD ; then
39         echo ">>>>> $SLURPD is not executable or do not exist."
40         echo ">>>>> Test skipped."
41         exit 0
42 fi
43
44 echo "Cleaning up in $DBDIR..."
45 rm -f $DBDIR/[!C]*
46 echo "Cleaning up in $REPLDIR..."
47 rm -f $REPLDIR/replica/[!C]*
48 rm -f $REPLDIR/[!C]*
49
50 echo "Starting master slapd on TCP/IP port $PORT..."
51 . $CONFFILTER $BACKEND $MONITORDB < $SUBMASTERCONF > $DBCONF
52 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
53 PID=$!
54 if test $WAIT != 0 ; then
55     echo PID $PID
56     read foo
57 fi
58
59 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
60 . $CONFFILTER $BACKEND $MONITORDB < $SUBSLAVECONF > $REPLCONF
61 $SLAPD -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 &
62 SLAVEPID=$!
63 if test $WAIT != 0 ; then
64     echo SLAVEPID $SLAVEPID
65     read foo
66 fi
67
68 echo "Using ldapsearch to check that master slapd is running..."
69 for i in 0 1 2 3 4 5; do
70         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
71                 'objectclass=*' > /dev/null 2>&1
72         RC=$?
73         if test $RC = 0 ; then
74                 break
75         fi
76         echo "Waiting 5 seconds for slapd to start..."
77         sleep 5
78 done
79
80 echo "Using ldapsearch to check that slave slapd is running..."
81 for i in 0 1 2 3 4 5; do
82         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
83                 'objectclass=*' > /dev/null 2>&1
84         RC=$?
85         if test $RC = 0 ; then
86                 break
87         fi
88         echo "Waiting 5 seconds for slapd to start..."
89         sleep 5
90 done
91
92 echo "Starting slurpd..."
93 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
94 SLURPPID=$!
95
96 echo "Using ldapadd to populate the master directory..."
97 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
98         $LDIFORDERED > /dev/null 2>&1
99 RC=$?
100 if test $RC != 0 ; then
101         echo "ldapadd failed ($RC)!"
102         kill -INT $PID $SLAVEPID
103         kill -KILL $SLURPPID
104         exit $RC
105 fi
106
107 echo "Waiting 15 seconds for slurpd to send changes..."
108 sleep 15
109
110 echo "Using ldapmodify to modify master directory..."
111
112 #
113 # Do some modifications
114 #
115
116 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
117         $TESTOUT 2>&1 << EOMODS
118 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
119 changetype: modify
120 add: drink
121 drink: Orange Juice
122
123 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
124 changetype: modify
125 replace: drink
126 drink: Iced Tea
127 drink: Mad Dog 20/20
128
129 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
130 delete: member
131 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
132 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
133 -
134 add: member
135 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
136 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
137 -
138 replace: description
139 description: A very long description, that is very likely to cause line wrapping in a LDIF file
140 -
141
142 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
143 changetype: modify
144 delete: member
145
146 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
147 changetype: add
148 objectclass: OpenLDAPperson
149 cn: Gern Jensen
150 sn: Jensen
151 uid: gjensen
152 title: Chief Investigator, ITD
153 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
154 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
155 drink: Coffee
156 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
157 description: Very odd
158 facsimiletelephonenumber: +1 313 555 7557
159 telephonenumber: +1 313 555 8343
160 mail: gjensen@mailgw.example.com
161 homephone: +1 313 555 8844
162
163 dn: ou=Retired, ou=People, o=University of Michigan, c=US
164 changetype: add
165 objectclass: organizationalUnit
166 ou: Retired
167
168 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
169 changetype: add
170 objectclass: OpenLDAPperson
171 cn: Rosco P. Coltrane
172 sn: Coltrane
173
174 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
175 changetype: modrdn
176 newrdn: cn=Rosco P. Coltrane
177 deleteoldrdn: 1
178 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
179
180 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
181 changetype: delete
182
183 EOMODS
184
185 echo "Waiting 15 seconds for slurpd to send changes..."
186 sleep 15
187
188 echo "Using ldapsearch to read all the entries from the master..."
189 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
190         'objectclass=*' > $MASTEROUT 2>&1
191 RC=$?
192
193 if test $RC != 0 ; then
194         echo "ldapsearch failed ($RC)!"
195         kill -INT $PID $SLAVEPID
196         kill -KILL $SLURPPID
197         exit $RC
198 fi
199
200 echo "Using ldapsearch to read the subtree entries from the master..."
201 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $PORT \
202         'objectclass=*' > $SUBMASTEROUT 2>&1
203 RC=$?
204
205 if test $RC != 0 ; then
206         echo "ldapsearch failed ($RC)!"
207         kill -INT $PID $SLAVEPID
208         kill -KILL $SLURPPID
209         exit $RC
210 fi
211
212 echo "Using ldapsearch to read all the entries from the slave..."
213 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $SLAVEPORT \
214         'objectclass=*' > $SLAVEOUT 2>&1
215 RC=$?
216
217 if test $RC != 0 ; then
218         echo "ldapsearch failed ($RC)!"
219         kill -INT $PID $SLAVEPID
220         kill -KILL $SLURPPID
221         exit $RC
222 fi
223
224 kill -INT $PID $SLAVEPID
225 kill -KILL $SLURPPID
226
227 SEARCHOUT=$SUBMASTEROUT
228 LDIF=$SLAVEOUT
229
230 echo "Filtering master ldapsearch results..."
231 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
232 echo "Filtering slave ldapsearch results..."
233 . $LDIFFILTER < $LDIF > $LDIFFLT
234
235 echo "Comparing retrieved entries from master and slave..."
236 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
237
238 if test $? != 0 ; then
239         echo "test failed - master and slave databases differ"
240         exit 1
241 fi
242
243 SEARCHOUT=$MASTEROUT
244
245 echo "Filtering remaining data"
246 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
247
248 echo "Stripping slave entries from master output..."
249 $DIFF $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
250
251 echo "Stripping subtree entries from master output..."
252 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
253         | $STRIPATTR "description" > $SUBFLT2
254
255 echo "Comparing master minus subtree and master minus slave..."
256 $CMP $SUBFLT $SUBFLT2 > $CMPOUT
257
258 if test $? != 0 ; then
259         echo "test failed - master and slave databases differ"
260         exit 1
261 fi
262
263 echo ">>>>> Test succeeded"
264
265 exit 0