test017-syncreplication-refresh 6.37 KB
Newer Older
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
1
2
#! /bin/sh
# $OpenLDAP$
Kurt Zeilenga's avatar
Kurt Zeilenga committed
3
4
5
6
7
8
9
10
11
12
13
14
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## Copyright 1998-2003 The OpenLDAP Foundation.
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License.
##
## A copy of this license is available in the file LICENSE in the
## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
15

Kurt Zeilenga's avatar
Kurt Zeilenga committed
16
if test "$BACKEND" != "bdb" -a "$BACKEND" != "hdb" -o ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
17
18
19
20
	echo "Test does not support $BACKEND"
	exit 0
fi

Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
21
22
23
echo "running defines.sh"
. $SRCDIR/scripts/defines.sh

24
25
mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3

Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
26
27
28
29
30
31
32
33
34
#
# Test replication:
# - start master
# - start slave
# - populate over ldap
# - perform some modifies and deleted
# - retrieve database over ldap and compare against expected results
#

35
36
37
echo "Starting master slapd on TCP/IP port $PORT1..."
. $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
38
39
40
41
42
PID=$!
if test $WAIT != 0 ; then
    echo PID $PID
    read foo
fi
43
KILLPIDS="$PID"
44

Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
45
46
echo "Using ldapsearch to check that master slapd is running..."
for i in 0 1 2 3 4 5; do
47
	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
48
49
50
51
52
53
54
55
56
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	if test $RC = 0 ; then
		break
	fi
	echo "Waiting 5 seconds for slapd to start..."
	sleep 5
done

57
58
59
60
61
62
if test $RC != 0 ; then
	echo "ldapsearch failed ($RC)!"
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
	exit $RC
fi

63
echo "Using ldapadd to create the context prefix entry in the master..."
64
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
65
66
67
68
	$LDIFORDEREDCP > /dev/null 2>&1
RC=$?
if test $RC != 0 ; then
	echo "ldapadd failed ($RC)!"
69
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
70
71
72
	exit $RC
fi

73
74
75
76
echo "Starting slave slapd on TCP/IP port $PORT2..."
. $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
SLAVEPID=$!
77
if test $WAIT != 0 ; then
78
    echo SLAVEPID $SLAVEPID
79
80
    read foo
fi
81
KILLPIDS="$KILLPIDS $SLAVEPID"
82

Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
83
84
echo "Using ldapsearch to check that slave slapd is running..."
for i in 0 1 2 3 4 5; do
85
	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
86
87
88
89
90
91
92
93
94
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	if test $RC = 0 ; then
		break
	fi
	echo "Waiting 5 seconds for slapd to start..."
	sleep 5
done

95
96
97
98
99
100
if test $RC != 0 ; then
	echo "ldapsearch failed ($RC)!"
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
	exit $RC
fi

Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
101
echo "Using ldapadd to populate the master directory..."
102
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
103
	$LDIFORDEREDNOCP > /dev/null 2>&1
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
104
105
106
RC=$?
if test $RC != 0 ; then
	echo "ldapadd failed ($RC)!"
107
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
108
109
110
	exit $RC
fi

111
112
echo "Waiting 15 seconds for syncrepl to receive changes..."
sleep 15
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
113
114
115
116
117
118
119

echo "Using ldapmodify to modify master directory..."

#
# Do some modifications
#

120
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	$TESTOUT 2>&1 << EOMODS
dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
changetype: modify
add: drink
drink: Orange Juice
-
delete: sn
sn: Jones
-
add: sn
sn: Jones

dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: modify
replace: drink
drink: Iced Tea
drink: Mad Dog 20/20

dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
changetype: modify
141
142
143
delete: uniquemember
uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
144
-
145
146
147
add: uniquemember
uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
changetype: modify
delete: description

dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: add
objectclass: OpenLDAPperson
cn: Gern Jensen
sn: Jensen
uid: gjensen
title: Chief Investigator, ITD
postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
drink: Coffee
homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
description: Very odd
facsimiletelephonenumber: +1 313 555 7557
telephonenumber: +1 313 555 8343
mail: gjensen@mailgw.example.com
homephone: +1 313 555 8844

dn: ou=Retired, ou=People, o=University of Michigan, c=US
changetype: add
objectclass: organizationalUnit
ou: Retired

dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: add
objectclass: OpenLDAPperson
cn: Rosco P. Coltrane
sn: Coltrane
uid: rosco

dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: modrdn
newrdn: cn=Rosco P. Coltrane
deleteoldrdn: 1
newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US

dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: delete

EOMODS

193
194
195
196
197
198
199
200
201
RC=$?
if test $RC != 0 ; then
	echo "ldapmodify failed ($RC)!"
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
	exit $RC
fi

echo "Waiting 15 seconds for syncrepl to receive changes..."
sleep 15
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
202
203

echo "Using ldapsearch to read all the entries from the master..."
204
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
205
206
207
208
209
	'objectclass=*' > $MASTEROUT 2>&1
RC=$?

if test $RC != 0 ; then
	echo "ldapsearch failed at master ($RC)!"
210
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
211
212
213
214
	exit $RC
fi

echo "Using ldapsearch to read all the entries from the slave..."
215
216
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
	'objectclass=*' > $SLAVEOUT 2>&1
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
217
218
219
220
RC=$?

if test $RC != 0 ; then
	echo "ldapsearch failed at slave ($RC)!"
221
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
222
223
224
	exit $RC
fi

225
test $KILLSERVERS != no && kill -HUP $KILLPIDS
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
226

227
228
229
230
echo "Filtering master results..."
. $LDIFFILTER < $MASTEROUT > $MASTERFLT
echo "Filtering slave results..."
. $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
231
232

echo "Comparing retrieved entries from master and slave..."
233
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
234
235
236
237
238
239
240
241

if test $? != 0 ; then
	echo "test failed - master and slave databases differ"
	exit 1
fi

echo ">>>>> Test succeeded"
exit 0