]> git.sur5r.net Git - openldap/blob - tests/scripts/test018-syncreplication-persist
Rework test scripts to use single 'testrun' directory.
[openldap] / tests / scripts / test018-syncreplication-persist
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
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 $PORT4..."
57 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
58 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 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 $PORT4 \
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 20 seconds for syncrepl to receive changes..."
95 sleep 20
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: member
125 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
126 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
127 -
128 add: member
129 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
130 member: 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 echo "Waiting 20 seconds for syncrepl to receive changes..."
177 sleep 20
178
179 echo "Using ldapsearch to read all the entries from the master..."
180 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
181         'objectclass=*' > $MASTEROUT 2>&1
182 RC=$?
183
184 if test $RC != 0 ; then
185         echo "ldapsearch failed at master ($RC)!"
186         test $KILLSERVERS != no && kill -HUP $KILLPIDS
187         exit $RC
188 fi
189
190 echo "Using ldapsearch to read all the entries from the slave..."
191 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
192         'objectclass=*' > $SLAVEOUT 2>&1
193 RC=$?
194
195 if test $RC != 0 ; then
196         echo "ldapsearch failed at slave ($RC)!"
197         test $KILLSERVERS != no && kill -HUP $KILLPIDS
198         exit $RC
199 fi
200
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202
203 echo "Filtering master results..."
204 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
205 echo "Filtering slave results..."
206 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
207
208 echo "Comparing retrieved entries from master and slave..."
209 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
210
211 if test $? != 0 ; then
212         echo "test failed - master and slave databases differ"
213         exit 1
214 fi
215
216 echo ">>>>> Test succeeded"
217 exit 0