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 # quick hack to check for awk
45 echo "looking for a POSIX compliant awk"
46 awk -W version >$CMPOUT 2>&1
47 if test $? != 0 ; then
48 echo "This test requires awk"
52 echo "Cleaning up in $DBDIR..."
54 echo "Cleaning up in $REPLDIR..."
55 rm -f $REPLDIR/replica/[!C]*
58 echo "Starting master slapd on TCP/IP port $PORT..."
59 . $CONFFILTER $BACKEND $MONITORDB < $SUBMASTERCONF > $DBCONF
60 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
62 if test $WAIT != 0 ; then
67 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
68 . $CONFFILTER $BACKEND $MONITORDB < $SUBSLAVECONF > $REPLCONF
69 $SLAPD -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 &
71 if test $WAIT != 0 ; then
72 echo SLAVEPID $SLAVEPID
76 echo "Using ldapsearch to check that master slapd is running..."
77 for i in 0 1 2 3 4 5; do
78 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
79 'objectclass=*' > /dev/null 2>&1
81 if test $RC = 0 ; then
84 echo "Waiting 5 seconds for slapd to start..."
88 echo "Using ldapsearch to check that slave slapd is running..."
89 for i in 0 1 2 3 4 5; do
90 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
91 'objectclass=*' > /dev/null 2>&1
93 if test $RC = 0 ; then
96 echo "Waiting 5 seconds for slapd to start..."
100 echo "Starting slurpd..."
101 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
104 echo "Using ldapadd to populate the master directory..."
105 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
106 $LDIFORDERED > /dev/null 2>&1
108 if test $RC != 0 ; then
109 echo "ldapadd failed ($RC)!"
110 kill -INT $PID $SLAVEPID
115 echo "Waiting 15 seconds for slurpd to send changes..."
118 echo "Using ldapmodify to modify master directory..."
121 # Do some modifications
124 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
125 $TESTOUT 2>&1 << EOMODS
126 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
131 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
137 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
139 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
140 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
143 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
144 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
147 description: A very long description, that is very likely to cause line wrapping in a LDIF file
150 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
153 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Michi
158 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
160 objectclass: OpenLDAPperson
164 title: Chief Investigator, ITD
165 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
166 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
168 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
169 description: Very odd
170 facsimiletelephonenumber: +1 313 555 7557
171 telephonenumber: +1 313 555 8343
172 mail: gjensen@mailgw.example.com
173 homephone: +1 313 555 8844
175 dn: ou=Retired, ou=People, o=University of Michigan, c=US
177 objectclass: organizationalUnit
180 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
182 objectclass: OpenLDAPperson
183 cn: Rosco P. Coltrane
186 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
188 newrdn: cn=Rosco P. Coltrane
190 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
192 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
197 echo "Waiting 15 seconds for slurpd to send changes..."
200 echo "Using ldapsearch to read all the entries from the master..."
201 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
202 'objectclass=*' > $MASTEROUT 2>&1
205 if test $RC != 0 ; then
206 echo "ldapsearch failed ($RC)!"
207 kill -INT $PID $SLAVEPID
212 echo "Using ldapsearch to read the subtree entries from the master..."
213 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $PORT \
214 'objectclass=*' > $SUBMASTEROUT 2>&1
217 if test $RC != 0 ; then
218 echo "ldapsearch failed ($RC)!"
219 kill -INT $PID $SLAVEPID
224 echo "Using ldapsearch to read all the entries from the slave..."
225 $LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h $LOCALHOST -p $SLAVEPORT \
226 'objectclass=*' > $SLAVEOUT 2>&1
229 if test $RC != 0 ; then
230 echo "ldapsearch failed ($RC)!"
231 kill -INT $PID $SLAVEPID
236 kill -INT $PID $SLAVEPID
239 SEARCHOUT=$SUBMASTEROUT
242 echo "Filtering master ldapsearch results..."
243 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
244 echo "Filtering slave ldapsearch results..."
245 . $LDIFFILTER < $LDIF > $LDIFFLT
247 echo "Comparing retrieved entries from master and slave..."
248 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
250 if test $? != 0 ; then
251 echo "test failed - master and slave databases differ"
257 echo "Filtering remaining data"
258 . $LDIFFILTER < $SEARCHOUT | $STRIPATTR "description" > $SEARCHFLT
260 echo "Stripping slave entries from master output..."
261 $DIFF $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
263 echo "Stripping subtree entries from master output..."
264 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
265 | $STRIPATTR "description" > $SUBFLT2
267 echo "Comparing master minus subtree and master minus slave..."
268 $BCMP $SUBFLT $SUBFLT2 > $CMPOUT
270 if test $? != 0 ; then
271 echo "test failed - master and slave databases differ"
275 echo ">>>>> Test succeeded"