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