5 if test $# -ge 1 ; then
9 if test $# -ge 1 ; then
13 if test $# -ge 1 ; then
17 echo "running defines.sh"
18 . $SRCDIR/scripts/defines.sh
24 # - create root entry in slave
26 # - populate over ldap
27 # - perform some modifies and deleted
28 # - retrieve database over ldap and compare against expected results
31 if test ! -x $SLURPD ; then
32 echo ">>>>> $SLURPD is not executable or do not exist."
33 echo ">>>>> Test skipped."
37 echo "Cleaning up in $DBDIR..."
39 echo "Cleaning up in $REPLDIR..."
40 rm -f $REPLDIR/replica/[!C]*
43 echo "Starting master slapd on TCP/IP port $PORT..."
44 . $CONFFILTER $BACKEND < $SUBMASTERCONF > $DBCONF
45 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
47 if test $WAIT != 0 ; then
52 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
53 . $CONFFILTER $BACKEND < $SUBSLAVECONF > $REPLCONF
54 $SLAPD -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 &
56 if test $WAIT != 0 ; then
57 echo SLAVEPID $SLAVEPID
61 echo "Using ldapsearch to check that master slapd is running..."
62 for i in 0 1 2 3 4 5; do
63 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
64 'objectclass=*' > /dev/null 2>&1
66 if test $RC = 1 ; then
67 echo "Waiting 5 seconds for slapd to start..."
72 echo "Using ldapsearch to check that slave slapd is running..."
73 for i in 0 1 2 3 4 5; do
74 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
75 'objectclass=*' > /dev/null 2>&1
77 if test $RC = 1 ; then
78 echo "Waiting 5 seconds for slapd to start..."
83 echo "Starting slurpd..."
84 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
87 echo "Using ldapadd to populate the master directory..."
88 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
89 $LDIFORDERED > /dev/null 2>&1
91 if test $RC != 0 ; then
92 echo "ldapadd failed ($RC)!"
93 kill -INT $PID $SLAVEPID
98 echo "Waiting 15 seconds for slurpd to send changes..."
101 echo "Using ldapmodify to modify master directory..."
104 # Do some modifications
107 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
108 $TESTOUT 2>&1 << EOMODS
109 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
114 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
120 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
122 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
123 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
126 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
127 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
129 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
133 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
137 objectclass: OpenLDAPperson
141 title: Chief Investigator, ITD
142 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
143 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
145 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
146 description: Very odd
147 facsimiletelephonenumber: +1 313 555 7557
148 telephonenumber: +1 313 555 8343
149 mail: gjensen@mailgw.umich.edu
150 homephone: +1 313 555 8844
152 dn: ou=Retired, ou=People, o=University of Michigan, c=US
155 objectclass: organizationalUnit
158 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
162 cn: Rosco P. Coltrane
165 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
167 newrdn: cn=Rosco P. Coltrane
169 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
171 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
176 echo "Waiting 15 seconds for slurpd to send changes..."
179 echo "Using ldapsearch to read all the entries from the master..."
180 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
181 'objectclass=*' > $MASTEROUT 2>&1
183 if test $RC != 0 ; then
184 echo "ldapsearch failed ($RC)!"
185 kill -INT $PID $SLAVEPID
190 echo "Using ldapsearch to read the subtree entries from the master..."
191 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $PORT \
192 'objectclass=*' > $SUBMASTEROUT 2>&1
194 if test $RC != 0 ; then
195 echo "ldapsearch failed ($RC)!"
196 kill -INT $PID $SLAVEPID
201 echo "Using ldapsearch to read all the entries from the slave..."
202 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $SLAVEPORT \
203 'objectclass=*' > $SLAVEOUT 2>&1
205 if test $RC != 0 ; then
206 echo "ldapsearch failed ($RC)!"
207 kill -INT $PID $SLAVEPID
212 kill -INT $PID $SLAVEPID
215 SEARCHOUT=$SUBMASTEROUT
218 echo "Filtering master ldapsearch results..."
219 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
220 echo "Filtering slave ldapsearch results..."
221 . $LDIFFILTER < $LDIF > $LDIFFLT
223 echo "Comparing retrieved entries from master and slave..."
224 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
226 if test $? != 0 ; then
227 echo "test failed - master and slave databases differ"
233 echo "Filtering remaining data"
234 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
236 echo "Stripping slave entries from master output..."
237 $CMP $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
239 echo "Stripping subtree entries from master output..."
240 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
241 | $UNDIFFFILTER > $SUBFLT2
243 echo "Comparing master minus subtree and master minus slave..."
244 $CMP $SUBFLT $SUBFLT2 > $CMPOUT
246 if test $? != 0 ; then
247 echo "test failed - master and slave databases differ"
251 echo ">>>>> Test succeeded"