]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10363 Fixed the broken asyncmeta con-ttl test
authorNadezhda Ivanova <nivanova@symas.com>
Fri, 27 Feb 2026 12:59:23 +0000 (14:59 +0200)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 12 Mar 2026 15:33:50 +0000 (15:33 +0000)
Fixed the incorrect filespaths, added the correct test statements
and added some comments

tests/data/asyncmeta.1.out
tests/data/asyncmeta.2.out
tests/data/asyncmeta.allopen.out
tests/data/asyncmeta.closed.out
tests/data/slapd-asyncmeta-conttl.conf
tests/scripts/test091-asyncmeta-conttl

index 3ac37af2f8249ae23e564cbbb68cf0d4c98e8659..bef1f54bab507fed5f38dd9cca8967c03589f032 100644 (file)
@@ -5,3 +5,4 @@ olmTargetConnFlags: closed
 dn: cn=Target Connection 2,cn=Connection Group 1,cn=Connections,cn=database 1,
  cn=databases,cn=monitor
 olmTargetConnFlags: closed
+
index eb1ff44c93c73ebbfa48cc60bcabab6744f394f8..d2c3613d46d04c3026084711e818f07138f1da3f 100644 (file)
@@ -5,3 +5,4 @@ olmTargetConnFlags: closed
 dn: cn=Target Connection 2,cn=Connection Group 2,cn=Connections,cn=database 1,
  cn=databases,cn=monitor
 olmTargetConnFlags: closed
+
index ddeb91903b569f09d661ebec7ab946e770b23cb1..a76ae759ea0767d9c499185cff4e503b73d913a5 100644 (file)
@@ -29,3 +29,4 @@ olmTargetConnFlags: anonymous,initialized
 dn: cn=Target Connection 2,cn=Connection Group 3,cn=Connections,cn=database 1,
  cn=databases,cn=monitor
 olmTargetConnFlags: anonymous,initialized
+
index 43fb3fe786e5035f5ec990f9be4a199576eb657d..9ab4928bb33fb779318628428c0f55baa53fa427 100644 (file)
@@ -21,3 +21,4 @@ olmTargetConnFlags: closed
 dn: cn=Target Connection 2,cn=Connection Group 3,cn=Connections,cn=database 1,
  cn=databases,cn=monitor
 olmTargetConnFlags: closed
+
index e695c3a05c703d3a54ce29e23880c9c3e75e817c..276fe3795c847d73849268dae276abce756001a4 100644 (file)
@@ -46,7 +46,7 @@ network-timeout 500
 #max-timeout-ops 50
 #max-pending-ops 128
 max-target-conns 3
-conn-ttl 10s 5s
+conn-ttl 6s 6s
 
 monitoring on
 
index 3c33afdddb94974eb85c448750b8bbc09f43cca7..0a4f2c63300d340a7a928c013ef860af2f12e144 100755 (executable)
@@ -45,7 +45,7 @@ if test $WAIT != 0 ; then
 fi
 KILLPIDS="$PID"
 
-sleep 1
+sleep $SLEEP0
 
 echo "Using ldapsearch to check that slapd is running..."
 for i in 0 1 2 3 4 5; do
@@ -55,8 +55,8 @@ for i in 0 1 2 3 4 5; do
        if test $RC = 0 ; then
                break
        fi
-       echo "Waiting 5 seconds for slapd to start..."
-       sleep 5
+       echo "Waiting $SLEEP1 seconds for slapd to start..."
+       sleep $SLEEP1
 done
 if test $RC != 0 ; then
        echo "ldapsearch failed ($RC)!"
@@ -84,7 +84,7 @@ if test $WAIT != 0 ; then
 fi
 KILLPIDS="$KILLPIDS $PID"
 
-sleep 1
+sleep $SLEEP0
 
 echo "Using ldapsearch to check that slapd is running..."
 for i in 0 1 2 3 4 5; do
@@ -94,8 +94,8 @@ for i in 0 1 2 3 4 5; do
        if test $RC = 0 ; then
                break
        fi
-       echo "Waiting 5 seconds for slapd to start..."
-       sleep 5
+       echo "Waiting $SLEEP1 seconds for slapd to start..."
+       sleep $SLEEP1
 done
 if test $RC != 0 ; then
        echo "ldapsearch failed ($RC)!"
@@ -123,7 +123,7 @@ if test $WAIT != 0 ; then
 fi
 KILLPIDS="$KILLPIDS $PID"
 
-sleep 1
+sleep $SLEEP0
 
 echo "Using ldapsearch to check that slapd is running..."
 for i in 0 1 2 3 4 5; do
@@ -133,8 +133,8 @@ for i in 0 1 2 3 4 5; do
        if test $RC = 0 ; then
                break
        fi
-       echo "Waiting 5 seconds for slapd to start..."
-       sleep 5
+       echo "Waiting $SLEEP1 seconds for slapd to start..."
+       sleep $SLEEP1
 done
 if test $RC != 0 ; then
        echo "ldapsearch failed ($RC)!"
@@ -162,10 +162,14 @@ if test $RC != 0 ; then
 fi
 echo "Filtering ldapsearch results..."
 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.closed.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.closed.out > $LDIFFLT
 echo "Comparing filter output..."
 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-
+if test $? != 0 ; then
+       echo "Comparison failed - the connections are not closed"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
 #run 3 searches
 for i in 0 1 2; do
        BASEDN="o=Example,c=US"
@@ -173,11 +177,6 @@ for i in 0 1 2; do
        echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
        $LDAPSEARCH -S "" -H $URI3 -b "$BASEDN" >> $SEARCHOUT 2>&1
        RC=$?
-       #if test $RC != 0 ; then
-       #       echo "Search failed ($RC)!"
-       #       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       #       exit $RC
-       #fi
        case $RC in
                0)
                ;;
@@ -192,15 +191,13 @@ for i in 0 1 2; do
                        exit $RC
                        ;;
        esac
-       sleep 2
 done
 # search cn=monitor - no connections should be closed yet
-SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
+sleep $SLEEP0
 echo "Verifying that all target connections are open..."
 cat /dev/null > $SEARCHOUT
 
 echo " base=\"$SEARCHDN\"..."
-echo "#        base=\"$SEARCHDN\"..." >> $SEARCHOUT
 $LDAPSEARCH  -H $URI3 \
                         -b "$SEARCHDN" \
                         'olmTargetConnFlags' >> $SEARCHOUT 2>&1
@@ -212,20 +209,27 @@ if test $RC != 0 ; then
 fi
 echo "Filtering ldapsearch results..."
 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.allopen.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.allopen.out > $LDIFFLT
+
 echo "Comparing filter output..."
 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-
-# wait 6 seconds and search cn=monitor - connection group 1 is closed
+if test $? != 0 ; then
+       echo "Comparison failed - the connections are not open"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+# wait 7 seconds (the con ttl time + 1) and search cn=monitor
+# connection group 1 should be closed
+echo "Waiting for the time-to-live time..."
+sleep $SLEEP1
 SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
 echo "Verifying that connection group 1 is closed..."
-sleep 5
 cat /dev/null > $SEARCHOUT
 
-echo " base=\"$SEARCHDN\"..."
+echo " base=\"cn=Connection Group 1,$SEARCHDN\"..."
 echo "#        base=\"$SEARCHDN\"..." >> $SEARCHOUT
 $LDAPSEARCH  -H $URI3 \
-                        -b "$SEARCHDN" \
+                        -b "cn=Connection Group 1,$SEARCHDN" \
                         "olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
 RC=$?
 if test $RC != 0 ; then
@@ -235,16 +239,22 @@ if test $RC != 0 ; then
 fi
 echo "Filtering ldapsearch results..."
 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.1.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.1.out > $LDIFFLT
 echo "Comparing filter output..."
 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
+if test $? != 0 ; then
+       echo "Comparison failed - connection group 1 is not closed"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+# wait 7 seconds (the con ttl interval + 1) and search cn=monitor
+# connection group 2 should be closed
+echo "Waiting for the connection reset interval..."
+sleep $SLEEP1
 echo "Verifying that target connection group 2 is closed..."
-sleep 6
 cat /dev/null > $SEARCHOUT
 
-echo " base=\"$SEARCHDN\"..."
-echo "#        base=\"$SEARCHDN\"..." >> $SEARCHOUT
+echo " base=\"cn=Connection Group 2,$SEARCHDN\"..."
 $LDAPSEARCH  -H $URI3 \
                         -b "cn=Connection Group 2,$SEARCHDN" \
                         "olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
@@ -257,33 +267,54 @@ fi
 
 echo "Filtering ldapsearch results..."
 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.2.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.2.out > $LDIFFLT
 echo "Comparing filter output..."
 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-
-SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
-echo "Verifying that all target connections are closed..."
-# wait 6 seconds, search, all connections should be closed
-sleep 6
-cat /dev/null > $SEARCHOUT
-
-echo " base=\"$SEARCHDN\"..."
-echo "#        base=\"$SEARCHDN\"..." >> $SEARCHOUT
-$LDAPSEARCH  -H $URI3 \
-                        -b "$SEARCHDN" \
-                        "olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "Unable to read monitor ($RC)!"
+if test $? != 0 ; then
+       echo "Comparison failed - connection group 2 is not closed"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
+       exit 1
 fi
-echo "Filtering ldapsearch results..."
-$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.closed.out > $LDIFFLT
-echo "Comparing filter output..."
-$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+# wait 7 seconds (the con ttl interval + 1) and search cn=monitor
+# all connections should be closed
+# sometimes the timeout loop may be delayed, so we give it a couple of
+# retries before giving up
+echo "Waiting for the connection reset interval..."
+sleep $SLEEP1
+echo "Verifying that all target connections are closed..."
+for i in 0 1 2; do
+       cat /dev/null > $SEARCHOUT
 
+       echo "  base=\"$SEARCHDN\"..."
+       echo "#         base=\"$SEARCHDN\"..." >> $SEARCHOUT
+       $LDAPSEARCH  -H $URI3 \
+                                -b "$SEARCHDN" \
+                                "olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
+       RC=$?
+       if test $RC != 0 ; then
+               echo "Unable to read monitor ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+       echo "Filtering ldapsearch results..."
+       $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+       $LDIFFILTER < $DATADIR/asyncmeta.closed.out > $LDIFFLT
+       echo "Comparing filter output..."
+       $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+       if test $? != 0 ; then
+               if test $i != 2 ; then
+                       echo "Comparison failed - the connections are  not closed, retrying in $SLEEP0 seconds..."
+                       sleep $SLEEP0
+               else
+                       echo "Comparison failed - the connections are  not closed, test failed"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       else
+               echo "Comparison successfull, all connections are closed"
+               break
+       fi
+done
 cat /dev/null > $SEARCHOUT
 
 test $KILLSERVERS != no && kill -HUP $KILLPIDS