]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8616/its8616
ITS#8616 - Regression test
[openldap] / tests / data / regressions / its8616 / its8616
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2018 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $SYNCPROV = syncprovno; then
20         echo "Syncrepl provider overlay not available, test skipped"
21         exit 0
22 fi
23
24 echo ""
25 echo "  This test tracks a case where it was not possible to modify the syncprov overlay configuration"
26 echo "  when the provider is dynamically configured for replication."
27 echo "  See http://www.openldap.org/its/index.cgi/?findid=8616 for more information"
28 echo ""
29
30 PRODIR=$TESTDIR/pro
31 CFPRO=$PRODIR/slapd.d
32
33 mkdir -p $TESTDIR $DBDIR1 $PRODIR $CFPRO
34
35 $SLAPPASSWD -g -n >$CONFIGPWF
36
37 ITS=8616
38 ITSDIR=$DATADIR/regressions/its$ITS
39
40 echo "Starting provider slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-provider.ldif > $CONFLDIF
42 $SLAPADD -F $CFPRO -n 0 -l $CONFLDIF
43 $SLAPD -F $CFPRO -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 PID=$!
45 if test $WAIT != 0 ; then
46         echo PID $PID
47         read foo
48 fi
49 KILLPIDS="$PID"
50
51 sleep 1
52
53 echo "Using ldapsearch to check that provider slapd is running..."
54 for i in 0 1 2 3 4 5; do
55         $LDAPSEARCH -s base -b "" -H $URI1 \
56                 'objectclass=*' > /dev/null 2>&1
57         RC=$?
58         if test $RC = 0 ; then
59                 break
60         fi
61         echo "Waiting 5 seconds for slapd to start..."
62         sleep 5
63 done
64
65 if test $RC != 0 ; then
66         echo "ldapsearch failed ($RC)!"
67         test $KILLSERVERS != no && kill -HUP $KILLPIDS
68         exit $RC
69 fi
70
71 echo "Populating database on provider..."
72 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
73 dn: dc=example,dc=com
74 changetype: add
75 objectClass: domain
76 objectClass: top
77 dc: example
78
79 dn: ou=LDAPRoles,dc=example,dc=com
80 objectClass: top
81 objectClass: organizationalUnit
82 ou: LDAPRoles
83
84 dn: dc=users,dc=example,dc=com
85 changetype: add
86 dc: users
87 objectClass: domain
88 objectClass: top
89
90 dn: uid=johndoe,dc=users,dc=example,dc=com
91 changetype: add
92 objectClass: inetOrgPerson
93 objectClass: top
94 sn: Doe
95 cn: Johndoe
96 uid: johndoe
97
98 dn: cn=replicator,ou=LDAPRoles,dc=example,dc=com
99 objectClass: top
100 objectClass: simpleSecurityObject
101 objectClass: organizationalRole
102 userPassword: secret
103 cn: replicator
104 EOMODS
105
106 RC=$?
107 if test $RC != 0 ; then
108         echo "ldapadd failed ($RC)!"
109         test $KILLSERVERS != no && kill -HUP $KILLPIDS
110         exit $RC
111 fi
112
113 if [ "$SYNCPROV" = syncprovmod ]; then
114         echo "Configuring syncprov module on the provider..."
115         $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
116 dn: cn=module,cn=config
117 objectClass: olcModuleList
118 cn: module
119 olcModulePath: $TESTWD/../servers/slapd/overlays
120 olcModuleLoad: syncprov.la
121 EOF
122         RC=$?
123         if test $RC != 0 ; then
124                 echo "ldapadd failed for moduleLoad ($RC)!"
125                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126                 exit $RC
127         fi
128 fi
129
130 echo "Configuring replication on the provider..."
131 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
132 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
133 changetype: add
134 objectClass: olcOverlayConfig
135 objectClass: olcConfig
136 objectClass: top
137 objectClass: olcSyncprovConfig
138 olcOverlay: {0}syncprov
139 olcSpSessionLog: 10000
140 olcSpCheckpoint: 100 10
141 EOF
142
143 RC=$?
144 if test $RC != 0 ; then
145         echo "ldapmodify failed ($RC)!"
146         test $KILLSERVERS != no && kill -HUP $KILLPIDS
147         exit $RC
148 fi
149
150 sleep 1
151
152 echo "Setting olcSpNoPresent to TRUE on the provider..."
153 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
154 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
155 changetype: modify
156 replace: olcSpNoPresent
157 olcSpNoPresent: TRUE
158 EOF
159
160 RC=$?
161 if test $RC != 0 ; then
162         echo "ldapmodify failed ($RC)!"
163         test $KILLSERVERS != no && kill -HUP $KILLPIDS
164         exit $RC
165 fi
166
167 sleep 1
168
169 echo "Changing olcSpNoPresent to FALSE on the provider..."
170 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
171 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
172 changetype: modify
173 replace: olcSpNoPresent
174 olcSpNoPresent: FALSE
175 EOF
176
177 RC=$?
178 if test $RC != 0 ; then
179         echo "ldapmodify failed ($RC)!"
180         test $KILLSERVERS != no && kill -HUP $KILLPIDS
181         exit $RC
182 fi
183
184 sleep 1
185
186 echo "Changing olcSpNoPresent back to TRUE on the provider..."
187 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
188 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
189 changetype: modify
190 replace: olcSpNoPresent
191 olcSpNoPresent: TRUE
192 EOF
193
194 RC=$?
195 if test $RC != 0 ; then
196         echo "ldapmodify failed ($RC)!"
197         test $KILLSERVERS != no && kill -HUP $KILLPIDS
198         exit $RC
199 fi
200
201 sleep 1
202
203 echo "Setting olcSpReloadHint to TRUE on the provider..."
204 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
205 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
206 changetype: modify
207 replace: olcSpReloadHint
208 olcSpReloadHint: TRUE
209 EOF
210
211 RC=$?
212 if test $RC != 0 ; then
213         echo "ldapmodify failed ($RC)!"
214         test $KILLSERVERS != no && kill -HUP $KILLPIDS
215         exit $RC
216 fi
217
218 sleep 1
219
220 echo "Changing olcSpReloadHint to FALSE on the provider..."
221 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
222 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
223 changetype: modify
224 replace: olcSpReloadHint
225 olcSpReloadHint: FALSE
226 EOF
227
228 RC=$?
229 if test $RC != 0 ; then
230         echo "ldapmodify failed ($RC)!"
231         test $KILLSERVERS != no && kill -HUP $KILLPIDS
232         exit $RC
233 fi
234
235 sleep 1
236
237 echo "Changing olcSpReloadHint back to TRUE on the provider..."
238 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
239 dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
240 changetype: modify
241 replace: olcSpReloadHint
242 olcSpReloadHint: TRUE
243 EOF
244
245 RC=$?
246 if test $RC != 0 ; then
247         echo "ldapmodify failed ($RC)!"
248         test $KILLSERVERS != no && kill -HUP $KILLPIDS
249         exit $RC
250 fi
251
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253
254 echo
255 echo ">>>>> Test succeeded"
256
257 test $KILLSERVERS != no && wait
258
259 exit 0