From d1fd1a385b02b0d1b7c9fe8cb2ac8e10daefa31a Mon Sep 17 00:00:00 2001 From: Nadezhda Ivanova Date: Fri, 27 Feb 2026 14:59:23 +0200 Subject: [PATCH] ITS#10363 Fixed the broken asyncmeta con-ttl test Fixed the incorrect filespaths, added the correct test statements and added some comments --- tests/data/asyncmeta.1.out | 1 + tests/data/asyncmeta.2.out | 1 + tests/data/asyncmeta.allopen.out | 1 + tests/data/asyncmeta.closed.out | 1 + tests/data/slapd-asyncmeta-conttl.conf | 2 +- tests/scripts/test091-asyncmeta-conttl | 135 +++++++++++++++---------- 6 files changed, 88 insertions(+), 53 deletions(-) diff --git a/tests/data/asyncmeta.1.out b/tests/data/asyncmeta.1.out index 3ac37af2f8..bef1f54bab 100644 --- a/tests/data/asyncmeta.1.out +++ b/tests/data/asyncmeta.1.out @@ -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 + diff --git a/tests/data/asyncmeta.2.out b/tests/data/asyncmeta.2.out index eb1ff44c93..d2c3613d46 100644 --- a/tests/data/asyncmeta.2.out +++ b/tests/data/asyncmeta.2.out @@ -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 + diff --git a/tests/data/asyncmeta.allopen.out b/tests/data/asyncmeta.allopen.out index ddeb91903b..a76ae759ea 100644 --- a/tests/data/asyncmeta.allopen.out +++ b/tests/data/asyncmeta.allopen.out @@ -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 + diff --git a/tests/data/asyncmeta.closed.out b/tests/data/asyncmeta.closed.out index 43fb3fe786..9ab4928bb3 100644 --- a/tests/data/asyncmeta.closed.out +++ b/tests/data/asyncmeta.closed.out @@ -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 + diff --git a/tests/data/slapd-asyncmeta-conttl.conf b/tests/data/slapd-asyncmeta-conttl.conf index e695c3a05c..276fe3795c 100644 --- a/tests/data/slapd-asyncmeta-conttl.conf +++ b/tests/data/slapd-asyncmeta-conttl.conf @@ -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 diff --git a/tests/scripts/test091-asyncmeta-conttl b/tests/scripts/test091-asyncmeta-conttl index 3c33afdddb..0a4f2c6330 100755 --- a/tests/scripts/test091-asyncmeta-conttl +++ b/tests/scripts/test091-asyncmeta-conttl @@ -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