3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2016 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
24 CONFDIR=$TESTDIR/slapd.d
28 mkdir -p $TESTDIR $CONFDIR $DBDIR
30 $SLAPPASSWD -g -n >$CONFIGPWF
33 # Test dynamic add/delete of syncprov overlay:
34 # - Create minimal back-conf setup
35 # - Add syncprov overlay to the cn=config database
36 # - Remove the overlay again
39 echo "Starting slapd on TCP/IP port $PORT1... $PWD"
40 . $CONFFILTER $BACKEND $MONITORDB < $DYNAMICCONF > $CONFLDIF
41 $SLAPADD -F $CONFDIR -n 0 -l $CONFLDIF
43 $SLAPD -F ./slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
45 if test $WAIT != 0 ; then
54 echo "Using ldapsearch to check that slapd is running..."
55 for i in 0 1 2 3 4 5; do
56 $LDAPSEARCH -s base -b "" -H $URI1 \
57 'objectclass=*' > /dev/null 2>&1
59 if test $RC = 0 ; then
62 echo "Waiting 5 seconds for slapd to start..."
66 if test $RC != 0 ; then
67 echo "ldapsearch failed ($RC)!"
68 test $KILLSERVERS != no && kill -HUP $KILLPIDS
72 echo "Inserting syncprov overlay ..."
73 if [ "$SYNCPROV" = syncprovmod ]; then
74 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
75 dn: cn=module,cn=config
76 objectClass: olcModuleList
78 olcModulePath: $TESTWD/../servers/slapd/overlays
79 olcModuleLoad: syncprov.la
82 if test $RC != 0 ; then
83 echo "ldapadd failed for moduleLoad ($RC)!"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88 read CONFIGPW < $CONFIGPWF
89 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
90 dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config
92 objectClass: olcOverlayConfig
93 objectClass: olcSyncProvConfig
98 if test $RC != 0 ; then
99 echo "ldapmodify failed for syncrepl config ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Starting a refreshAndPersist search in background"
107 $LDAPSEARCH -D cn=config -H $URI1 -y $CONFIGPWF -bcn=config -E \!sync=rp >/dev/null 2>&1
117 echo "Removing syncprov overlay again ..."
118 $LDAPDELETE -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
119 olcOverlay={0}syncprov,olcDatabase={0}config,cn=config
123 if test $RC != 0 ; then
124 echo "ldapmodify failed for syncrepl config ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 for i in 0 1 2 3 4; do
130 if test -f "$RCOUT" ; then
133 echo "Waiting 2 seconds for RefreshAndPersist search to end ..."
138 if test -f "$RCOUT" ; then
140 SEARCHRC=`cat $RCOUT`
141 echo "Checking return code of backgrounded RefreshAndPersist search ..."
142 if test 52 != "$SEARCHRC" ; then
143 echo "Error: Backgrounded ldapsearch returned the wrong error code: $SEARCHRC"
146 echo "Exit code correct."
149 echo "Backgrounded ldapsearch did not exit after overlay removal."
153 if test $RC != 0 ; then
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 echo "Running a refreshOnly search, should fail..."
159 $LDAPSEARCH -D cn=config -H $URI1 -y $CONFIGPWF -bcn=config -E \!sync=ro > /dev/null 2>&1
162 if test $RC != 12 ; then
163 echo "ldapsearch should have failed with Critical extension is unavailable (12)!"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 echo "Failed with \"Critical extension is unavailable (12)\". Ok."
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 echo ">>>>> Test succeeded"
175 test $KILLSERVERS != no && wait