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