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