]> git.sur5r.net Git - openldap/blob - tests/scripts/test017-syncreplication-refresh
1a23bd17b893184659e76613cfa8e4ba1a80eb9e
[openldap] / tests / scripts / test017-syncreplication-refresh
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8
9 . $SRCDIR/scripts/args.sh $*
10
11 echo "running defines.sh"
12 . $SRCDIR/scripts/defines.sh
13
14 #
15 # Test replication:
16 # - start master
17 # - start slave
18 # - populate over ldap
19 # - perform some modifies and deleted
20 # - retrieve database over ldap and compare against expected results
21 #
22
23 echo "Cleaning up in $DBDIR..."
24 rm -f $DBDIR/[!C]*
25 echo "Resetting $R1REPLDIR..."
26 rm -rf $R1REPLDIR
27 mkdir $R1REPLDIR
28
29 SAVE=$BACKEND
30 if test $BACKEND = ldbm; then
31         if test $SYNCREPL = no; then
32                 echo "Sync replication requires back-bdb or back-hdb"
33                 exit 0
34         fi
35         BACKEND=$SYNCREPL
36 fi
37 echo "Starting master slapd on TCP/IP port $PORT..."
38 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
39 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
40 PID=$!
41 if test $WAIT != 0 ; then
42     echo PID $PID
43     read foo
44 fi
45 BACKEND=$SAVE
46
47 echo "Using ldapsearch to check that master slapd is running..."
48 for i in 0 1 2 3 4 5; do
49         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
50                 'objectclass=*' > /dev/null 2>&1
51         RC=$?
52         if test $RC = 0 ; then
53                 break
54         fi
55         echo "Waiting 5 seconds for slapd to start..."
56         sleep 5
57 done
58
59 if test $RC != 0 ; then
60         echo "ldapsearch failed ($RC)!"
61         kill -HUP $PID
62         exit $RC
63 fi
64
65 echo "Using ldapadd to create the context prefix entry in the master..."
66 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
67         $LDIFORDEREDCP > /dev/null 2>&1
68 RC=$?
69 if test $RC != 0 ; then
70         echo "ldapadd failed ($RC)!"
71         kill -HUP $PID
72         exit $RC
73 fi
74
75 echo "Starting slave slapd on TCP/IP port $R1SLAVEPORT..."
76 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $R1REPLCONF
77 $SLAPD -f $R1REPLCONF -h $R1SLAVEURI -d $LVL $TIMING > $R1SLAVELOG 2>&1 &
78 R1SLAVEPID=$!
79 if test $WAIT != 0 ; then
80     echo SLAVEPID $R1SLAVEPID
81     read foo
82 fi
83
84 echo "Using ldapsearch to check that slave slapd is running..."
85 for i in 0 1 2 3 4 5; do
86         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R1SLAVEPORT \
87                 'objectclass=*' > /dev/null 2>&1
88         RC=$?
89         if test $RC = 0 ; then
90                 break
91         fi
92         echo "Waiting 5 seconds for slapd to start..."
93         sleep 5
94 done
95
96 if test $RC != 0 ; then
97         echo "ldapsearch failed ($RC)!"
98         kill -HUP $PID
99         exit $RC
100 fi
101
102 echo "Using ldapadd to populate the master directory..."
103 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
104         $LDIFORDEREDNOCP > /dev/null 2>&1
105 RC=$?
106 if test $RC != 0 ; then
107         echo "ldapadd failed ($RC)!"
108         kill -HUP $PID $R1SLAVEPID
109         exit $RC
110 fi
111
112 echo "Waiting 90 seconds for syncrepl to receive changes..."
113 sleep 90
114
115 echo "Using ldapmodify to modify master directory..."
116
117 #
118 # Do some modifications
119 #
120
121 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
122         $TESTOUT 2>&1 << EOMODS
123 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
124 changetype: modify
125 add: drink
126 drink: Orange Juice
127 -
128 delete: sn
129 sn: Jones
130 -
131 add: sn
132 sn: Jones
133
134 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
135 changetype: modify
136 replace: drink
137 drink: Iced Tea
138 drink: Mad Dog 20/20
139
140 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
141 changetype: modify
142 delete: member
143 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
144 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
145 -
146 add: member
147 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
148 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
149
150 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
151 changetype: modify
152 delete: description
153
154 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
155 changetype: add
156 objectclass: OpenLDAPperson
157 cn: Gern Jensen
158 sn: Jensen
159 uid: gjensen
160 title: Chief Investigator, ITD
161 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
162 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
163 drink: Coffee
164 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
165 description: Very odd
166 facsimiletelephonenumber: +1 313 555 7557
167 telephonenumber: +1 313 555 8343
168 mail: gjensen@mailgw.example.com
169 homephone: +1 313 555 8844
170
171 dn: ou=Retired, ou=People, o=University of Michigan, c=US
172 changetype: add
173 objectclass: organizationalUnit
174 ou: Retired
175
176 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
177 changetype: add
178 objectclass: OpenLDAPperson
179 cn: Rosco P. Coltrane
180 sn: Coltrane
181 uid: rosco
182
183 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
184 changetype: modrdn
185 newrdn: cn=Rosco P. Coltrane
186 deleteoldrdn: 1
187 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
188
189 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
190 changetype: delete
191
192 EOMODS
193
194 echo "Waiting 90 seconds for syncrepl to receive changes..."
195 sleep 90
196
197 echo "Using ldapsearch to read all the entries from the master..."
198 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
199         'objectclass=*' > $MASTEROUT 2>&1
200 RC=$?
201
202 if test $RC != 0 ; then
203         echo "ldapsearch failed at master ($RC)!"
204         kill -HUP $PID $R1SLAVEPID
205         exit $RC
206 fi
207
208 echo "Using ldapsearch to read all the entries from the slave..."
209 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R1SLAVEPORT \
210         'objectclass=*' > $R1SLAVEOUT 2>&1
211 RC=$?
212
213 if test $RC != 0 ; then
214         echo "ldapsearch failed at slave ($RC)!"
215         kill -HUP $PID $R1SLAVEPID
216         exit $RC
217 fi
218
219 kill -HUP $PID $R1SLAVEPID
220
221 SEARCHOUT=$MASTEROUT
222 LDIF=$R1SLAVEOUT
223
224 echo "Filtering ldapsearch results..."
225 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
226 echo "Filtering original ldif used to create database..."
227 . $LDIFFILTER < $LDIF > $R1LDIFFLT
228
229 echo "Comparing retrieved entries from master and slave..."
230 $CMP $SEARCHFLT $R1LDIFFLT > $CMPOUT
231
232 if test $? != 0 ; then
233         echo "test failed - master and slave databases differ"
234         exit 1
235 fi
236
237 echo ">>>>> Test succeeded"
238
239
240 exit 0