]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test053-syncprov-glue
Merge remote branch 'origin/mdb.master'
[openldap] / tests / scripts / test053-syncprov-glue
index ed9d61819f8f6cb2a0e2c70c2f707e96f87f50be..9c419d6bda567b31788075cdd13cee61ceec9ce2 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2008 The OpenLDAP Foundation.
+## Copyright 1998-2012 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -45,11 +45,28 @@ KILLPIDS=
 
 $SLAPPASSWD -g -n >$CONFIGPWF
 
-echo "Initializing producer configurations..."
+if test x"$SYNCMODE" = x ; then
+       SYNCMODE=rp
+fi
+case "$SYNCMODE" in
+       ro)
+               SYNCTYPE="type=refreshOnly interval=00:00:00:03"
+               ;;
+       rp)
+               SYNCTYPE="type=refreshAndPersist"
+               ;;
+       *)
+               echo "unknown sync mode $SYNCMODE"
+               exit 1;
+               ;;
+esac
+
+echo "Initializing provider configurations..."
 $SLAPADD -F $CFPROD -n 0 <<EOF
 dn: cn=config
 objectClass: olcGlobal
 cn: config
+olcServerID: 1
 
 dn: olcDatabase={0}config,cn=config
 objectClass: olcDatabaseConfig
@@ -58,7 +75,7 @@ olcRootPW:< file://$CONFIGPWF
 
 EOF
 
-echo "Initializing producer2 configurations..."
+echo "Initializing provider2 configurations..."
 $SLAPADD -F $CFPRO2 -n 0 <<EOF
 dn: cn=config
 objectClass: olcGlobal
@@ -82,7 +99,7 @@ olcDatabase: {0}config
 olcRootPW:< file://$CONFIGPWF
 EOF
 
-echo "Starting producer slapd on TCP/IP port $PORT1..."
+echo "Starting provider slapd on TCP/IP port $PORT1..."
 cd $PRODDIR
 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
 PID=$!
@@ -93,7 +110,7 @@ fi
 KILLPIDS="$KILLPIDS $PID"
 cd $TESTWD
 sleep 1
-echo "Using ldapsearch to check that producer slapd is running..."
+echo "Using ldapsearch to check that provider slapd is running..."
 for i in 0 1 2 3 4 5; do
        $LDAPSEARCH -s base -b "" -H $URI1 \
                'objectclass=*' > /dev/null 2>&1
@@ -110,9 +127,9 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-echo "Starting producer2 slapd on TCP/IP port $PORT2..."
+echo "Starting provider2 slapd on TCP/IP port $PORT2..."
 cd $PRO2DIR
-$SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG1 2>&1 &
+$SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
 PID=$!
 if test $WAIT != 0 ; then
     echo PID $PID
@@ -121,7 +138,7 @@ fi
 KILLPIDS="$KILLPIDS $PID"
 cd $TESTWD
 sleep 1
-echo "Using ldapsearch to check that producer slapd is running..."
+echo "Using ldapsearch to check that provider slapd is running..."
 for i in 0 1 2 3 4 5; do
        $LDAPSEARCH -s base -b "" -H $URI2 \
                'objectclass=*' > /dev/null 2>&1
@@ -140,7 +157,7 @@ fi
 
 echo "Starting consumer slapd on TCP/IP port $PORT3..."
 cd $CONSDIR
-$SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG2 2>&1 &
+$SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
 PID=$!
 if test $WAIT != 0 ; then
     echo PID $PID
@@ -193,7 +210,7 @@ EOF
 dn: cn=module,cn=config
 objectClass: olcModuleList
 cn: module
-olcModulePath: ../../../servers/slapd/back-$BACKEND
+olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
 olcModuleLoad: back_$BACKEND.la
 EOF
        RC=$?
@@ -204,13 +221,13 @@ EOF
        fi
 done
 
-echo "Adding databases on producer..."
+echo "Adding databases on provider..."
 if [ "$SYNCPROV" = syncprovmod ]; then
        $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
 dn: cn=module,cn=config
 objectClass: olcModuleList
 cn: module
-olcModulePath: ../../../servers/slapd/overlays
+olcModulePath: $TESTWD/../servers/slapd/overlays
 olcModuleLoad: syncprov.la
 
 EOF
@@ -222,12 +239,15 @@ EOF
        fi
 fi
 
+nullExclude="" nullOK=""
+test $BACKEND = null && nullExclude="# " nullOK="OK"
+
 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
 dn: olcDatabase={1}$BACKEND,cn=config
 objectClass: olcDatabaseConfig
-objectClass: olc${BACKEND}Config
+${nullExclude}objectClass: olc${BACKEND}Config
 olcDatabase: {1}$BACKEND
-olcDbDirectory: $PRODDIR/db
+${nullExclude}olcDbDirectory: $PRODDIR/db
 olcSuffix: $BASEDN
 olcRootDN: $MANAGERDN
 olcRootPW: $PASSWD
@@ -235,7 +255,7 @@ olcRootPW: $PASSWD
 EOF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldapadd failed for producer database config1 ($RC)!"
+       echo "ldapadd failed for provider database config1 ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
 fi
@@ -252,9 +272,9 @@ olcOverlay: {1}syncprov
 
 dn: olcDatabase={1}$BACKEND,cn=config
 objectClass: olcDatabaseConfig
-objectClass: olc${BACKEND}Config
+${nullExclude}objectClass: olc${BACKEND}Config
 olcDatabase: {1}$BACKEND
-olcDbDirectory: $PRODDIR/ou1
+${nullExclude}olcDbDirectory: $PRODDIR/ou1
 olcSubordinate: TRUE
 olcSuffix: ou=ou1,$BASEDN
 olcRootDN: $MANAGERDN
@@ -262,18 +282,18 @@ olcRootDN: $MANAGERDN
 EOF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldapadd failed for producer database config ($RC)!"
+       echo "ldapadd failed for provider database config ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
 fi
 
-echo "Adding databases on producer2..."
+echo "Adding databases on provider2..."
 if [ "$SYNCPROV" = syncprovmod ]; then
        $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
 dn: cn=module,cn=config
 objectClass: olcModuleList
 cn: module
-olcModulePath: ../../../servers/slapd/overlays
+olcModulePath: $TESTWD/../servers/slapd/overlays
 olcModuleLoad: syncprov.la
 
 EOF
@@ -288,9 +308,9 @@ fi
 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
 dn: olcDatabase={1}$BACKEND,cn=config
 objectClass: olcDatabaseConfig
-objectClass: olc${BACKEND}Config
+${nullExclude}objectClass: olc${BACKEND}Config
 olcDatabase: {1}$BACKEND
-olcDbDirectory: $PRO2DIR/db
+${nullExclude}olcDbDirectory: $PRO2DIR/db
 olcSuffix: $BASEDN
 olcRootDN: $MANAGERDN
 olcRootPW: $PASSWD
@@ -303,7 +323,7 @@ olcOverlay: {0}syncprov
 EOF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldapadd failed for producer database config ($RC)!"
+       echo "ldapadd failed for provider database config ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
 fi
@@ -312,9 +332,9 @@ echo "Adding databases on consumer..."
 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
 dn: olcDatabase={1}$BACKEND,cn=config
 objectClass: olcDatabaseConfig
-objectClass: olc${BACKEND}Config
+${nullExclude}objectClass: olc${BACKEND}Config
 olcDatabase: {1}$BACKEND
-olcDbDirectory: $CONSDIR/db
+${nullExclude}olcDbDirectory: $CONSDIR/db
 olcSuffix: $BASEDN
 olcRootDN: $MANAGERDN
 
@@ -326,7 +346,7 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-echo "Populating producer..."
+echo "Populating provider..."
 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
 dn: dc=example,dc=com
 objectClass: top
@@ -343,12 +363,12 @@ ou: ou1
 EOF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldapadd failed to populate producer entry ($RC)!"
+       echo "ldapadd failed to populate provider entry ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
 fi
 
-echo "Populating producer2..."
+echo "Populating provider2..."
 $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
 dn: dc=example,dc=com
 objectClass: top
@@ -365,19 +385,19 @@ ou: ou1
 EOF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldapadd failed to populate producer entry ($RC)!"
+       echo "ldapadd failed to populate provider entry ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
 fi
 
-echo "Adding syncrepl on producer..."
+echo "Adding syncrepl on provider..."
 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
 dn: olcDatabase={1}$BACKEND,cn=config
 changetype: modify
 add: olcSyncRepl
 olcSyncRepl: rid=1 provider=$URI2 searchbase="ou=ou1,$BASEDN"
   binddn="$MANAGERDN" bindmethod=simple credentials=$PASSWD
-  type=refreshAndPersist retry="5 5 300 5" timeout=1
+  $SYNCTYPE retry="3 5 300 5" timeout=1
 
 EOF
 RC=$?
@@ -394,7 +414,7 @@ changetype: modify
 add: olcSyncRepl
 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
   binddn="$MANAGERDN" bindmethod=simple credentials=$PASSWD
-  type=refreshAndPersist retry="5 5 300 5" timeout=1
+  $SYNCTYPE retry="3 5 300 5" timeout=1
 
 EOF
 RC=$?
@@ -410,12 +430,12 @@ for i in 0 1 2 3 4 5; do
        RESULT=`$LDAPSEARCH -H $URI3 \
                -s base -b "ou=ou1,$BASEDN" \
                '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
-       if test "x$RESULT" = "xOK" ; then
+       if test "x$RESULT$nullOK" = "xOK" ; then
                RC=0
                break
        fi
-       echo "Waiting 5 seconds for syncrepl to receive changes..."
-       sleep 5
+       echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
+       sleep $SLEEP1
 done
 if test $RC != 0 ; then
        echo "ldapsearch failed ($RC)!"
@@ -423,7 +443,7 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-echo "Using ldapmodify to modify producer2..."
+echo "Using ldapmodify to modify provider2..."
 $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
 dn: ou=ou1,dc=example,dc=com
 changetype: modify
@@ -446,12 +466,12 @@ for i in 0 1 2 3 4 5; do
        RESULT=`$LDAPSEARCH -H $URI3 \
                -s base -b "ou=ou1,$BASEDN" \
                '(description=Modify1)' 2>&1 | awk '/^dn:/ {print "OK"}'`
-       if test "x$RESULT" = "xOK" ; then
+       if test "x$RESULT$nullOK" = "xOK" ; then
                RC=0
                break
        fi
-       echo "Waiting 5 seconds for syncrepl to receive changes..."
-       sleep 5
+       echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
+       sleep $SLEEP1
 done
 if test $RC != 0 ; then
        echo "ldapsearch failed ($RC)!"
@@ -459,20 +479,30 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-type db_stat >/dev/null 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "Could not find db_stat ($RC)!"
+case $BACKEND in bdb | hdb)
+db_stat=
+for path in `echo "$PATH" | sed -e 's/:/ /g'`; do
+       if test -f "$path/db_stat" && \
+               "$path/db_stat" -E -h $PRODDIR/db > /dev/null 2>&1
+       then
+               db_stat="$path/db_stat"
+               break
+       fi
+done
+
+if test -z "$db_stat" ; then
+       echo "Could not find a working db_stat in PATH!"
        lock_bug=1
-elif db_stat -E -h $PRODDIR/db | egrep -q 'HELD .* len:'; then
+elif "$db_stat" -E -h $PRODDIR/db | egrep -q 'HELD .* len:'; then
        echo "WARNING: Glue lock bug hit, next modify could deadlock"
        lock_bug=2
 else
        echo "Glue lock bug not found :-)"
        lock_bug=0
 fi
+esac
 
-echo "Using ldapmodify to modify glue suffix on producer..."
+echo "Using ldapmodify to modify glue suffix on provider..."
 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
 dn: dc=example,dc=com
 changetype: modify