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
138 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
142 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
144 objectclass: OpenLDAPperson
148 title: Chief Investigator, ITD
149 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
150 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
152 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
153 description: Very odd
154 facsimiletelephonenumber: +1 313 555 7557
155 telephonenumber: +1 313 555 8343
156 mail: gjensen@mailgw.umich.edu
157 homephone: +1 313 555 8844
159 dn: ou=Retired, ou=People, o=University of Michigan, c=US
161 objectclass: organizationalUnit
164 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
166 objectclass: OpenLDAPperson
167 cn: Rosco P. Coltrane
170 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
172 newrdn: cn=Rosco P. Coltrane
174 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
176 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
181 echo "Waiting 15 seconds for slurpd to send changes..."
184 echo "Using ldapsearch to read all the entries from the master..."
185 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
186 'objectclass=*' > $MASTEROUT 2>&1
189 if test $RC != 0 ; then
190 echo "ldapsearch failed ($RC)!"
191 kill -INT $PID $SLAVEPID
196 echo "Using ldapsearch to read the subtree entries from the master..."
197 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $PORT \
198 'objectclass=*' > $SUBMASTEROUT 2>&1
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 kill -INT $PID $SLAVEPID
208 echo "Using ldapsearch to read all the entries from the slave..."
209 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $SLAVEPORT \
210 'objectclass=*' > $SLAVEOUT 2>&1
213 if test $RC != 0 ; then
214 echo "ldapsearch failed ($RC)!"
215 kill -INT $PID $SLAVEPID
220 kill -INT $PID $SLAVEPID
223 SEARCHOUT=$SUBMASTEROUT
226 echo "Filtering master ldapsearch results..."
227 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
228 echo "Filtering slave ldapsearch results..."
229 . $LDIFFILTER < $LDIF > $LDIFFLT
231 echo "Comparing retrieved entries from master and slave..."
232 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
234 if test $? != 0 ; then
235 echo "test failed - master and slave databases differ"
241 echo "Filtering remaining data"
242 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
244 echo "Stripping slave entries from master output..."
245 $CMP $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
247 echo "Stripping subtree entries from master output..."
248 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
249 | $UNDIFFFILTER > $SUBFLT2
251 echo "Comparing master minus subtree and master minus slave..."
252 $CMP $SUBFLT $SUBFLT2 > $CMPOUT
254 if test $? != 0 ; then
255 echo "test failed - master and slave databases differ"
259 echo ">>>>> Test succeeded"