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