8 if test $# -ge 1 ; then
12 . $SRCDIR/scripts/args.sh
14 echo "running defines.sh"
15 . $SRCDIR/scripts/defines.sh
21 # - create root entry in slave
23 # - populate over ldap
24 # - perform some modifies and deleted
25 # - retrieve database over ldap and compare against expected results
28 if test ! -x $SLURPD ; then
29 echo ">>>>> $SLURPD is not executable or do not exist."
30 echo ">>>>> Test skipped."
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"
42 echo "Cleaning up in $DBDIR..."
44 echo "Cleaning up in $REPLDIR..."
45 rm -f $REPLDIR/replica/[!C]*
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 &
52 if test $WAIT != 0 ; then
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 &
61 if test $WAIT != 0 ; then
62 echo SLAVEPID $SLAVEPID
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
71 if test $RC = 0 ; then
74 echo "Waiting 5 seconds for slapd to start..."
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
83 if test $RC = 0 ; then
86 echo "Waiting 5 seconds for slapd to start..."
90 echo "Starting slurpd..."
91 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
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
98 if test $RC != 0 ; then
99 echo "ldapadd failed ($RC)!"
100 kill -HUP $PID $SLAVEPID
105 echo "Waiting 15 seconds for slurpd to send changes..."
108 echo "Using ldapmodify to modify master directory..."
111 # Do some modifications
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
127 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
133 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
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
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
143 description: A very long description, that is very likely to cause line wrapping in a LDIF file
146 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
149 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Michi
154 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
156 objectclass: OpenLDAPperson
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
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
171 dn: ou=Retired, ou=People, o=University of Michigan, c=US
173 objectclass: organizationalUnit
176 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
178 objectclass: OpenLDAPperson
179 cn: Rosco P. Coltrane
182 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
184 newrdn: cn=Rosco P. Coltrane
186 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
188 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
193 echo "Waiting 15 seconds for slurpd to send changes..."
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
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 kill -HUP $PID $SLAVEPID
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
213 if test $RC != 0 ; then
214 echo "ldapsearch failed ($RC)!"
215 kill -HUP $PID $SLAVEPID
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
225 if test $RC != 0 ; then
226 echo "ldapsearch failed ($RC)!"
227 kill -HUP $PID $SLAVEPID
232 kill -HUP $PID $SLAVEPID
235 SEARCHOUT=$SUBMASTEROUT
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
244 echo "Comparing retrieved subtree entries from master and sub-slave..."
245 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
247 if test $? != 0 ; then
248 echo "test failed - master and sub-slave subtree databases differ"
254 echo "Filtering remaining data"
255 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
257 echo "Stripping sub-slave entries from master output..."
258 $DIFF $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT1
260 echo "Stripping subtree entries from master output..."
261 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
262 | $STRIPATTR "description" > $SUBFLT2
264 echo "Comparing master minus subtree and master minus sub-slave..."
265 $BCMP $SUBFLT1 $SUBFLT2 > $CMPOUT
267 if test $? != 0 ; then
268 echo "test failed - master and sub-slave databases differ"
272 echo ">>>>> Test succeeded"