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