8 if test $# -ge 1 ; then
12 if test $# -ge 1 ; then
16 if test $# -ge 1 ; then
20 if test $# -ge 1 ; then
24 echo "running defines.sh"
25 . $SRCDIR/scripts/defines.sh
31 # - create root entry in slave
33 # - populate over ldap
34 # - perform some modifies and deleted
35 # - retrieve database over ldap and compare against expected results
38 if test ! -x $SLURPD ; then
39 echo ">>>>> $SLURPD is not executable or do not exist."
40 echo ">>>>> Test skipped."
44 echo "Cleaning up in $DBDIR..."
46 echo "Cleaning up in $REPLDIR..."
47 rm -f $REPLDIR/replica/[!C]*
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 &
54 if test $WAIT != 0 ; then
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 &
63 if test $WAIT != 0 ; then
64 echo SLAVEPID $SLAVEPID
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
73 if test $RC = 0 ; then
76 echo "Waiting 5 seconds for slapd to start..."
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
85 if test $RC = 0 ; then
88 echo "Waiting 5 seconds for slapd to start..."
92 echo "Starting slurpd..."
93 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
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
100 if test $RC != 0 ; then
101 echo "ldapadd failed ($RC)!"
102 kill -INT $PID $SLAVEPID
107 echo "Waiting 15 seconds for slurpd to send changes..."
110 echo "Using ldapmodify to modify master directory..."
113 # Do some modifications
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
123 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
129 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
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
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
139 description: A very long description, that is very likely to cause line wrapping in a LDIF file
142 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
146 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
148 objectclass: OpenLDAPperson
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
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
163 dn: ou=Retired, ou=People, o=University of Michigan, c=US
165 objectclass: organizationalUnit
168 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
170 objectclass: OpenLDAPperson
171 cn: Rosco P. Coltrane
174 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
176 newrdn: cn=Rosco P. Coltrane
178 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
180 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
185 echo "Waiting 15 seconds for slurpd to send changes..."
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
193 if test $RC != 0 ; then
194 echo "ldapsearch failed ($RC)!"
195 kill -INT $PID $SLAVEPID
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
205 if test $RC != 0 ; then
206 echo "ldapsearch failed ($RC)!"
207 kill -INT $PID $SLAVEPID
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
217 if test $RC != 0 ; then
218 echo "ldapsearch failed ($RC)!"
219 kill -INT $PID $SLAVEPID
224 kill -INT $PID $SLAVEPID
227 SEARCHOUT=$SUBMASTEROUT
230 echo "Filtering master ldapsearch results..."
231 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
232 echo "Filtering slave ldapsearch results..."
233 . $LDIFFILTER < $LDIF > $LDIFFLT
235 echo "Comparing retrieved entries from master and slave..."
236 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
238 if test $? != 0 ; then
239 echo "test failed - master and slave databases differ"
245 echo "Filtering remaining data"
246 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
248 echo "Stripping slave entries from master output..."
249 $DIFF $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
251 echo "Stripping subtree entries from master output..."
252 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
253 | $STRIPATTR "description" > $SUBFLT2
255 echo "Comparing master minus subtree and master minus slave..."
256 $CMP $SUBFLT $SUBFLT2 > $CMPOUT
258 if test $? != 0 ; then
259 echo "test failed - master and slave databases differ"
263 echo ">>>>> Test succeeded"