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