]> git.sur5r.net Git - openldap/blob - tests/scripts/test011-subtree-repl
added attr strip test
[openldap] / tests / scripts / test011-subtree-repl
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "Test disabled."
5 exit 0
6
7 SRCDIR="."
8 if test $# -ge 1 ; then
9         SRCDIR=$1; shift
10 fi
11 BACKEND=bdb
12 if test $# -ge 1 ; then
13         BACKEND=$1; shift
14 fi
15 MONITORDB=no
16 if test $# -ge 1 ; then
17         MONITORDB=$1; shift
18 fi
19 WAIT=0
20 if test $# -ge 1 ; then
21         WAIT=1; shift
22 fi
23
24 echo "running defines.sh"
25 . $SRCDIR/scripts/defines.sh
26
27 #
28 # Test replication:
29 # - start master
30 # - start slave
31 # - create root entry in slave
32 # - start slurpd
33 # - populate over ldap
34 # - perform some modifies and deleted
35 # - retrieve database over ldap and compare against expected results
36 #
37
38 if test ! -x $SLURPD ; then
39         echo ">>>>> $SLURPD is not executable or do not exist."
40         echo ">>>>> Test skipped."
41         exit 0
42 fi
43
44 echo "Cleaning up in $DBDIR..."
45 rm -f $DBDIR/[!C]*
46 echo "Cleaning up in $REPLDIR..."
47 rm -f $REPLDIR/replica/[!C]*
48 rm -f $REPLDIR/[!C]*
49
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 &
53 PID=$!
54 if test $WAIT != 0 ; then
55     echo PID $PID
56     read foo
57 fi
58
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 &
62 SLAVEPID=$!
63 if test $WAIT != 0 ; then
64     echo SLAVEPID $SLAVEPID
65     read foo
66 fi
67
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
72         RC=$?
73         if test $RC = 0 ; then
74                 break
75         fi
76         echo "Waiting 5 seconds for slapd to start..."
77         sleep 5
78 done
79
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
84         RC=$?
85         if test $RC = 0 ; then
86                 break
87         fi
88         echo "Waiting 5 seconds for slapd to start..."
89         sleep 5
90 done
91
92 echo "Starting slurpd..."
93 $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
94 SLURPPID=$!
95
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
99 RC=$?
100 if test $RC != 0 ; then
101         echo "ldapadd failed ($RC)!"
102         kill -INT $PID $SLAVEPID
103         kill -KILL $SLURPPID
104         exit $RC
105 fi
106
107 echo "Waiting 15 seconds for slurpd to send changes..."
108 sleep 15
109
110 echo "Using ldapmodify to modify master directory..."
111
112 #
113 # Do some modifications
114 #
115
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
119 changetype: modify
120 add: drink
121 drink: Orange Juice
122
123 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
124 changetype: modify
125 replace: drink
126 drink: Iced Tea
127 drink: Mad Dog 20/20
128
129 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
130 delete: member
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
133 -
134 add: member
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
137
138 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
139 changetype: modify
140 delete: member
141
142 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
143 changetype: add
144 objectclass: OpenLDAPperson
145 cn: Gern Jensen
146 sn: Jensen
147 uid: gjensen
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
151 drink: Coffee
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.example.com
157 homephone: +1 313 555 8844
158
159 dn: ou=Retired, ou=People, o=University of Michigan, c=US
160 changetype: add
161 objectclass: organizationalUnit
162 ou: Retired
163
164 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
165 changetype: add
166 objectclass: OpenLDAPperson
167 cn: Rosco P. Coltrane
168 sn: Coltrane
169
170 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
171 changetype: modrdn
172 newrdn: cn=Rosco P. Coltrane
173 deleteoldrdn: 1
174 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
175
176 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
177 changetype: delete
178
179 EOMODS
180
181 echo "Waiting 15 seconds for slurpd to send changes..."
182 sleep 15
183
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
187 RC=$?
188
189 if test $RC != 0 ; then
190         echo "ldapsearch failed ($RC)!"
191         kill -INT $PID $SLAVEPID
192         kill -KILL $SLURPPID
193         exit $RC
194 fi
195
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
199 RC=$?
200
201 if test $RC != 0 ; then
202         echo "ldapsearch failed ($RC)!"
203         kill -INT $PID $SLAVEPID
204         kill -KILL $SLURPPID
205         exit $RC
206 fi
207
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
211 RC=$?
212
213 if test $RC != 0 ; then
214         echo "ldapsearch failed ($RC)!"
215         kill -INT $PID $SLAVEPID
216         kill -KILL $SLURPPID
217         exit $RC
218 fi
219
220 kill -INT $PID $SLAVEPID
221 kill -KILL $SLURPPID
222
223 SEARCHOUT=$SUBMASTEROUT
224 LDIF=$SLAVEOUT
225
226 echo "Filtering master ldapsearch results..."
227 . $LDIFFILTER < $SEARCHOUT | egrep -iv ^description > $SEARCHFLT
228 echo "Filtering slave ldapsearch results..."
229 . $LDIFFILTER < $LDIF > $LDIFFLT
230
231 echo "Comparing retrieved entries from master and slave..."
232 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
233
234 if test $? != 0 ; then
235         echo "test failed - master and slave databases differ"
236         exit 1
237 fi
238
239 SEARCHOUT=$MASTEROUT
240
241 echo "Filtering remaining data"
242 . $LDIFFILTER < $SEARCHOUT | egrep -iv ^description > $SEARCHFLT
243
244 echo "Stripping slave entries from master output..."
245 $CMP $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
246
247 echo "Stripping subtree entries from master output..."
248 . $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
249         | $UNDIFFFILTER | egrep -iv ^description > $SUBFLT2
250
251 echo "Comparing master minus subtree and master minus slave..."
252 $CMP $SUBFLT $SUBFLT2 > $CMPOUT
253
254 if test $? != 0 ; then
255         echo "test failed - master and slave databases differ"
256         exit 1
257 fi
258
259 echo ">>>>> Test succeeded"
260
261 exit 0