8 if test $# -ge 1 ; then
12 if test $# -ge 1 ; then
16 if test $# -ge 1 ; then
20 echo "running defines.sh"
21 . $SRCDIR/scripts/defines.sh
27 # - create root entry in slave
29 # - populate over ldap
30 # - perform some modifies and deleted
31 # - retrieve database over ldap and compare against expected results
34 if test ! -x $SLURPD ; then
35 echo ">>>>> $SLURPD is not executable or do not exist."
36 echo ">>>>> Test skipped."
40 echo "Cleaning up in $DBDIR..."
42 echo "Cleaning up in $REPLDIR..."
43 rm -f $REPLDIR/replica/[!C]*
46 echo "Starting master slapd on TCP/IP port $PORT..."
47 . $CONFFILTER $BACKEND < $SUBMASTERCONF > $DBCONF
48 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
50 if test $WAIT != 0 ; then
55 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
56 . $CONFFILTER $BACKEND < $SUBSLAVECONF > $REPLCONF
57 $SLAPD -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 &
59 if test $WAIT != 0 ; then
60 echo SLAVEPID $SLAVEPID
64 echo "Using ldapsearch to check that master slapd is running..."
65 for i in 0 1 2 3 4 5; do
66 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
67 'objectclass=*' > /dev/null 2>&1
69 if test $RC = 1 ; then
70 echo "Waiting 5 seconds for slapd to start..."
75 echo "Using ldapsearch to check that slave slapd is running..."
76 for i in 0 1 2 3 4 5; do
77 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
78 'objectclass=*' > /dev/null 2>&1
80 if test $RC = 1 ; then
81 echo "Waiting 5 seconds for slapd to start..."
86 echo "Starting slurpd..."
87 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
90 echo "Using ldapadd to populate the master directory..."
91 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
92 $LDIFORDERED > /dev/null 2>&1
94 if test $RC != 0 ; then
95 echo "ldapadd failed ($RC)!"
96 kill -INT $PID $SLAVEPID
101 echo "Waiting 15 seconds for slurpd to send changes..."
104 echo "Using ldapmodify to modify master directory..."
107 # Do some modifications
110 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
111 $TESTOUT 2>&1 << EOMODS
112 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
117 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
123 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
125 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
126 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
129 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
130 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
132 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
136 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
140 objectclass: OpenLDAPperson
144 title: Chief Investigator, ITD
145 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
146 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
148 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
149 description: Very odd
150 facsimiletelephonenumber: +1 313 555 7557
151 telephonenumber: +1 313 555 8343
152 mail: gjensen@mailgw.umich.edu
153 homephone: +1 313 555 8844
155 dn: ou=Retired, ou=People, o=University of Michigan, c=US
158 objectclass: organizationalUnit
161 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
165 cn: Rosco P. Coltrane
168 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
170 newrdn: cn=Rosco P. Coltrane
172 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
174 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
179 echo "Waiting 15 seconds for slurpd to send changes..."
182 echo "Using ldapsearch to read all the entries from the master..."
183 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
184 'objectclass=*' > $MASTEROUT 2>&1
186 if test $RC != 0 ; then
187 echo "ldapsearch failed ($RC)!"
188 kill -INT $PID $SLAVEPID
193 echo "Using ldapsearch to read the subtree entries from the master..."
194 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $PORT \
195 'objectclass=*' > $SUBMASTEROUT 2>&1
197 if test $RC != 0 ; then
198 echo "ldapsearch failed ($RC)!"
199 kill -INT $PID $SLAVEPID
204 echo "Using ldapsearch to read all the entries from the slave..."
205 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $SLAVEPORT \
206 'objectclass=*' > $SLAVEOUT 2>&1
208 if test $RC != 0 ; then
209 echo "ldapsearch failed ($RC)!"
210 kill -INT $PID $SLAVEPID
215 kill -INT $PID $SLAVEPID
218 SEARCHOUT=$SUBMASTEROUT
221 echo "Filtering master ldapsearch results..."
222 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
223 echo "Filtering slave ldapsearch results..."
224 . $LDIFFILTER < $LDIF > $LDIFFLT
226 echo "Comparing retrieved entries from master and slave..."
227 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
229 if test $? != 0 ; then
230 echo "test failed - master and slave databases differ"
236 echo "Filtering remaining data"
237 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
239 echo "Stripping slave entries from master output..."
240 $CMP $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
242 echo "Stripping subtree entries from master output..."
243 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
244 | $UNDIFFFILTER > $SUBFLT2
246 echo "Comparing master minus subtree and master minus slave..."
247 $CMP $SUBFLT $SUBFLT2 > $CMPOUT
249 if test $? != 0 ; then
250 echo "test failed - master and slave databases differ"
254 echo ">>>>> Test succeeded"