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