Debian Codegraph @

tests/scripts/test075-dsee-persist

raw
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 OPATTRS="creatorsName createTimestamp modifiersName modifyTimestamp"
20
21 DSADM=`command -v dsadm`
22 if test -z "$DSADM"; then
23 echo "DSEE dsadm not in path, test skipped"
24 exit 0
25 fi
26
27 mkdir -p $TESTDIR $DBDIR4
28
29 #
30 # Test replication:
31 # - start provider
32 # - start consumer
33 # - populate over ldap
34 # - perform some modifies and deleted
35 # - attempt to modify the consumer (referral or chain)
36 # - retrieve database over ldap and compare against expected results
37 #
38
39 DSEEPW=secret21
40 DSEEDN="cn=Directory Manager"
41 DSEEPWF=$TESTDIR/dseepw
42
43 echo "secret21" > $DSEEPWF
44
45 echo "Setting up DSEE provider slapd on TCP/IP port $PORT1..."
46 dsadm create -p $PORT1 -w $DSEEPWF $DBDIR1
47 dsadm start $DBDIR1
48 dsconf create-suffix -c -p $PORT1 -w $DSEEPWF $BASEDN
49 dsconf set-server-prop -p $PORT1 -w $DSEEPWF moddn-enabled:on
50 dsconf set-server-prop -p $PORT1 -w $DSEEPWF retro-cl-enabled:on
51 dsadm restart $DBDIR1
52 PID=`basename $DBDIR1/locks/server/*`
53 KILLPIDS="$PID"
54
55 sleep 1
56
57 echo "Using ldapsearch to check that provider slapd is running..."
58 for i in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base -b "$BASEDN" -H $URI1 \
60 'objectclass=*' > /dev/null 2>&1
61 RC=$?
62 if test $RC = 0 ; then
63 break
64 fi
65 echo "Waiting 5 seconds for slapd to start..."
66 sleep 5
67 done
68
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
72 exit $RC
73 fi
74
75 echo "Starting consumer slapd on TCP/IP port $PORT4..."
76 . $CONFFILTER $BACKEND < $DSEESYNC2CONF > $CONF4
77 $SLAPD -f $CONF4 -h $URI4 -d $LVL > $LOG4 2>&1 &
78 CONSUMERPID=$!
79 if test $WAIT != 0 ; then
80 echo CONSUMERPID $CONSUMERPID
81 read foo
82 fi
83 KILLPIDS="$KILLPIDS $CONSUMERPID"
84
85 sleep 1
86
87 echo "Using ldapsearch to check that consumer slapd is running..."
88 for i in 0 1 2 3 4 5; do
89 $LDAPSEARCH -s base -b "$MONITOR" -H $URI4 \
90 'objectclass=*' > /dev/null 2>&1
91 RC=$?
92 if test $RC = 0 ; then
93 break
94 fi
95 echo "Waiting 5 seconds for slapd to start..."
96 sleep 5
97 done
98
99 if test $RC != 0 ; then
100 echo "ldapsearch failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 exit $RC
103 fi
104
105 # using LDIFDIRSYNCNOCP to avoid custom OpenLDAP schema
106 echo "Using ldapadd to populate the provider directory..."
107 $LDAPADD -D "$DSEEDN" -H $URI1 -w $DSEEPW < \
108 $LDIFDIRSYNCNOCP > /dev/null 2>&1
109 RC=$?
110 if test $RC != 0 ; then
111 echo "ldapadd failed ($RC)!"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 exit $RC
114 fi
115
116 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
117 sleep $SLEEP1
118
119 echo "Using ldapsearch to read all the entries from the provider..."
120 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
121 -D "$DSEEDN" -w "$DSEEPW" \
122 '(objectclass=*)' '*' $OPATTRS > $PROVIDEROUT 2>&1
123 RC=$?
124
125 if test $RC != 0 ; then
126 echo "ldapsearch failed at provider ($RC)!"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 exit $RC
129 fi
130
131 echo "Using ldapsearch to read all the entries from the consumer..."
132 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI4 \
133 '(objectclass=*)' '*' $OPATTRS > $CONSUMEROUT 2>&1
134 RC=$?
135
136 if test $RC != 0 ; then
137 echo "ldapsearch failed at consumer ($RC)!"
138 test $KILLSERVERS != no && kill -HUP $KILLPIDS
139 exit $RC
140 fi
141
142 echo "Filtering provider results..."
143 $LDIFFILTER -s a < $PROVIDEROUT > $PROVIDERFLT
144 echo "Filtering consumer results..."
145 $LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT
146
147 echo "Comparing retrieved entries from provider and consumer..."
148 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
149
150 if test $? != 0 ; then
151 echo "test failed - provider and consumer databases differ"
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 exit 1
154 fi
155
156 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
157 kill -HUP "$PID"
158 wait $PID
159 sleep 10
160 echo "RESTART" >> $LOG1
161 dsadm start $DBDIR1
162 PID=`basename $DBDIR1/locks/server/*`
163 if test $WAIT != 0 ; then
164 echo PID $PID
165 read foo
166 fi
167 KILLPIDS="$PID $CONSUMERPID"
168
169 sleep 1
170
171 echo "Using ldapsearch to check that provider slapd is running..."
172 for i in 0 1 2 3 4 5; do
173 $LDAPSEARCH -s base -b "$BASEDN" -H $URI1 \
174 'objectclass=*' > /dev/null 2>&1
175 RC=$?
176 if test $RC = 0 ; then
177 break
178 fi
179 echo "Waiting 5 seconds for slapd to start..."
180 sleep 5
181 done
182
183 echo "Waiting $SLEEP1 seconds for consumer to reconnect..."
184 sleep $SLEEP1
185
186 if test $RC != 0 ; then
187 echo "ldapsearch failed ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 exit $RC
190 fi
191
192 echo "Using ldapmodify to modify provider directory..."
193
194 #
195 # Do some modifications
196 #
197
198 $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \
199 $TESTOUT 2>&1 << EOMODS
200 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
201 changetype: modify
202 add: carLicense
203 carLicense: Orange Juice
204 -
205 delete: sn
206 sn: Jones
207 -
208 add: sn
209 sn: Jones
210
211 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
212 changetype: modify
213 replace: carLicense
214 carLicense: Iced Tea
215
216 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
217 changetype: modify
218 delete: uniquemember
219 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
220 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
221 -
222 add: uniquemember
223 uniquemember: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
224 uniquemember: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
225
226 dn: cn=All Staff,ou=Groups,dc=example,dc=com
227 changetype: modify
228 delete: description
229
230 dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
231 changetype: add
232 objectclass: inetOrgPerson
233 cn: Gern Jensen
234 sn: Jensen
235 uid: gjensen
236 title: Chief Investigator, ITD
237 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
238 seealso: cn=All Staff,ou=Groups,dc=example,dc=com
239 carLicense: Coffee
240 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
241 description: Very odd
242 facsimiletelephonenumber: +1 313 555 7557
243 facsimiletelephonenumber: +1 313 555 9998
244 facsimiletelephonenumber: +1 313 555 9999
245 telephonenumber: +1 313 555 8343
246 mail: [email protected]
247 homephone: +1 313 555 8844
248
249 # modify attribute with no matching rule (ITS#6458)
250 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
251 changetype: modify
252 replace: facsimiletelephonenumber
253 facsimiletelephonenumber: +1 313 555 9998
254 facsimiletelephonenumber: +1 313 555 9999
255
256 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
257 changetype: modify
258 replace: facsimiletelephonenumber
259 facsimiletelephonenumber: +1 313 555 9998
260 facsimiletelephonenumber: +1 313 555 9999
261 facsimiletelephonenumber: +1 313 555 7557
262
263 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
264 changetype: modify
265 replace: facsimiletelephonenumber
266 facsimiletelephonenumber: +1 313 555 9998
267 facsimiletelephonenumber: +1 313 555 9999
268
269 dn: ou=Retired,ou=People,dc=example,dc=com
270 changetype: add
271 objectclass: organizationalUnit
272 ou: Retired
273
274 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
275 changetype: add
276 objectclass: inetOrgPerson
277 cn: Rosco P. Coltrane
278 sn: Coltrane
279 uid: rosco
280 description: Fat tycoon
281
282 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
283 changetype: modrdn
284 newrdn: cn=Rosco P. Coltrane
285 deleteoldrdn: 1
286 newsuperior: ou=Retired,ou=People,dc=example,dc=com
287
288 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
289 changetype: delete
290
291 dn: ou=testdomain1,dc=example,dc=com
292 changetype: modrdn
293 newrdn: ou=itsdomain1
294 deleteoldrdn: 1
295
296 dn: ou=itsdomain1,dc=example,dc=com
297 changetype: modify
298 replace: description
299 description: Example, Inc. ITS test domain
300
301 dn: ou=testdomain2,dc=example,dc=com
302 changetype: modrdn
303 newrdn: ou=itsdomain2
304 deleteoldrdn: 1
305
306 EOMODS
307
308 RC=$?
309 if test $RC != 0 ; then
310 echo "ldapmodify failed ($RC)!"
311 test $KILLSERVERS != no && kill -HUP $KILLPIDS
312 exit $RC
313 fi
314
315 ## ldappasswd test removed, not supported on DSEE
316
317 echo "Stopping consumer to test recovery..."
318 kill -HUP $CONSUMERPID
319 wait $CONSUMERPID
320
321 echo "Modifying more entries on the provider..."
322 $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW >> \
323 $TESTOUT 2>&1 << EOMODS
324 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
325 changetype: delete
326
327 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
328 changetype: modify
329 add: carLicense
330 carLicense: Mad Dog 20/20
331
332 dn: cn=Rosco P. Coltrane,ou=Retired,ou=People,dc=example,dc=com
333 changetype: add
334 objectclass: inetOrgPerson
335 sn: Coltrane
336 uid: rosco
337 cn: Rosco P. Coltrane
338
339 dn: ou=itsdomain2,dc=example,dc=com
340 changetype: modify
341 replace: description
342 description: Example, Inc. itsdomain2 test domain
343
344 # rename with a newly added newSuperior while the consumer is down (ITS#6472)
345 dn: ou=New Branch,dc=example,dc=com
346 changetype: add
347 objectClass: organizationalUnit
348 ou: New Branch
349
350 dn: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
351 changetype: modrdn
352 newrdn: cn=Dorothy Stevens
353 deleteoldrdn: 0
354 newsuperior: ou=New Branch,dc=example,dc=com
355
356 EOMODS
357
358 RC=$?
359 if test $RC != 0 ; then
360 echo "ldapmodify failed ($RC)!"
361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
362 exit $RC
363 fi
364
365 echo "Restarting consumer..."
366 echo "RESTART" >> $LOG4
367 $SLAPD -f $CONF4 -h $URI4 -d $LVL >> $LOG4 2>&1 &
368 CONSUMERPID=$!
369 if test $WAIT != 0 ; then
370 echo CONSUMERPID $CONSUMERPID
371 read foo
372 fi
373 KILLPIDS="$PID $CONSUMERPID"
374
375 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
376 sleep $SLEEP1
377
378 echo "Using ldapsearch to read all the entries from the provider..."
379 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
380 -D "$DSEEDN" -w "$DSEEPW" \
381 '(objectclass=*)' '*' $OPATTRS > $PROVIDEROUT 2>&1
382 RC=$?
383
384 if test $RC != 0 ; then
385 echo "ldapsearch failed at provider ($RC)!"
386 test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 exit $RC
388 fi
389
390 echo "Using ldapsearch to read all the entries from the consumer..."
391 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI4 \
392 '(objectclass=*)' '*' $OPATTRS > $CONSUMEROUT 2>&1
393 RC=$?
394
395 if test $RC != 0 ; then
396 echo "ldapsearch failed at consumer ($RC)!"
397 test $KILLSERVERS != no && kill -HUP $KILLPIDS
398 exit $RC
399 fi
400
401 echo "Filtering provider results..."
402 $LDIFFILTER -s a < $PROVIDEROUT > $PROVIDERFLT
403 echo "Filtering consumer results..."
404 $LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT
405
406 echo "Comparing retrieved entries from provider and consumer..."
407 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
408
409 if test $? != 0 ; then
410 echo "test failed - provider and consumer databases differ"
411 test $KILLSERVERS != no && kill -HUP $KILLPIDS
412 exit 1
413 fi
414
415 test $KILLSERVERS != no && kill -HUP $KILLPIDS
416
417 echo ">>>>> Test succeeded"
418
419 test $KILLSERVERS != no && wait
420
421 exit 0