]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9197 Increase timeouts in test case due to sporadic failures
authorTero Saarni <tero.saarni@est.tech>
Thu, 25 Feb 2021 12:38:45 +0000 (14:38 +0200)
committerTero Saarni <tero.saarni@est.tech>
Thu, 25 Feb 2021 14:56:55 +0000 (16:56 +0200)
tests/scripts/defines.sh
tests/scripts/test079-proxy-timeout

index 0afa1f8c356672ba19f4573e6ee2e62303116e69..b369f52791b99a94df018ca8d7cd2f4ed5cd460e 100755 (executable)
@@ -54,7 +54,7 @@ ACI=${AC_ACI_ENABLED-acino}
 SLEEP0=${SLEEP0-1}
 SLEEP1=${SLEEP1-7}
 SLEEP2=${SLEEP2-15}
-TIMEOUT=${TIMEOUT-4}
+TIMEOUT=${TIMEOUT-8}
 
 # dirs
 PROGDIR=./progs
index e097c0739fb39981faafa44be5978109a13bfdaf..79f19d937bc0a781092801883ee182f5bba42695 100755 (executable)
@@ -73,8 +73,9 @@ sleep $SLEEP0
 # Test 1: Test that shared connections are timed out
 #
 
-NOW=`date +%s`
-echo "Create shared connection towards remote LDAP (time_t now=$NOW timeout=`expr $NOW + $TIMEOUT`)"
+CONN_BEGINS=`date +%s`
+CONN_EXPIRES=`expr $CONN_BEGINS + $TIMEOUT`
+echo "Create shared connection towards remote LDAP (time_t now=$CONN_BEGINS timeout=$CONN_EXPIRES)"
 
 $LDAPSEARCH -b "dc=idle-timeout,$BASEDN" \
         -D "cn=Manager,dc=local,dc=com" \
@@ -102,7 +103,7 @@ fi
 
 # Check that connections are established by searching for olmDbConnURI from Monitor
 
-echo "Checking that proxy has created connections towards backend"
+echo "Checking that proxy has created connections towards backend (time_t now=`date +%s`)"
 
 $LDAPSEARCH -b "cn=Connections,cn=database 2,cn=databases,cn=monitor" -s one -LLL olmDbConnURI \
         -D "cn=Manager,dc=local,dc=com" \
@@ -129,9 +130,10 @@ fi
 # Wait for connections to be closed, either due to
 # - idle-timeout and
 # - conn-ttl
-
+# sleep 2 second overtime for robustness of the test case
 echo "Sleeping until idle-timeout and conn-ttl have passed"
-sleep `expr $TIMEOUT + 1`
+NOW=`date +%s`
+sleep `expr $CONN_EXPIRES - $NOW + 2`
 
 echo "Checking that proxy has closed expired connections towards the remote LDAP server (time_t now=`date +%s`)"
 
@@ -163,8 +165,9 @@ fi
 # Test 2: Test that private connections are timed out
 #
 
-NOW=`date +%s`
-echo "Create private connection towards remote LDAP (time_t now=$NOW timeout=`expr $NOW + $TIMEOUT`)"
+CONN_BEGINS=`date +%s`
+CONN_EXPIRES=`expr $CONN_BEGINS + $TIMEOUT`
+echo "Create private connection towards remote LDAP (time_t now=$CONN_BEGINS timeout=$CONN_EXPIRES)"
 
 # Create fifos that are used to pass searches from the test case to ldapsearch
 rm -f $TESTDIR/ldapsearch1.fifo $TESTDIR/ldapsearch2.fifo
@@ -192,9 +195,11 @@ exec 4>$TESTDIR/ldapsearch2.fifo
 # Trigger LDAP connections towards the proxy by executing a search
 echo 'objectclass=*' >&3
 echo 'objectclass=*' >&4
-sleep 1
 
-echo "Checking that proxy has created connections towards backend"
+# wait for ldapsearches (running as background processes) to execute search operations
+sleep 2
+
+echo "Checking that proxy has created connections towards backend (time_t now=`date +%s`)"
 
 $LDAPSEARCH -b "cn=Connections,cn=database 2,cn=databases,cn=monitor" -s one -LLL olmDbConnURI \
         -D "cn=Manager,dc=local,dc=com" \
@@ -218,9 +223,13 @@ if test $RC != 0 ; then
     exit $RC
 fi
 
-
+# Wait for connections to be closed, either due to
+# - idle-timeout and
+# - conn-ttl
+# sleep 2 second overtime for robustness of the test case
 echo "Sleeping until idle-timeout and conn-ttl have passed"
-sleep `expr $TIMEOUT + 1`
+NOW=`date +%s`
+sleep `expr $CONN_EXPIRES - $NOW + 2`
 
 echo "Checking that proxy has closed expired connections towards the remote LDAP server (time_t now=`date +%s`)"
 
@@ -258,8 +267,9 @@ exec 4>&-
 #
 
 echo "Checking that idle-timeout is reset on activity"
-NOW=`date +%s`
-echo "Create cached connection: idle-timeout timeout starts (time_t now=$NOW, original_timeout=`expr $NOW + $TIMEOUT`)"
+CONN_BEGINS=`date +%s`
+CONN_EXPIRES=`expr $CONN_BEGINS + $TIMEOUT`
+echo "Create cached connection: idle-timeout timeout starts (time_t now=$CONN_BEGINS, original_timeout=$CONN_EXPIRES)"
 $LDAPSEARCH -b "dc=idle-timeout,$BASEDN" \
         -D "cn=Manager,dc=local,dc=com" \
         -H $URI2 \
@@ -272,10 +282,13 @@ if test $RC != 0 ; then
         exit $RC
 fi
 
-# sleep second less than idle-timeout to extend the timeout
-sleep `expr $TIMEOUT - 1`
+# sleep until 2 seconds before idle-timeout, then extend the timeout by executing another search operation
 NOW=`date +%s`
-echo "Do another search to reset the timeout (time_t now=$NOW, new_timeout=`expr $NOW + $TIMEOUT`)"
+sleep `expr $CONN_EXPIRES - $NOW - 2`
+
+CONN_BEGINS=`date +%s`
+CONN_EXPIRES=`expr $CONN_BEGINS + $TIMEOUT`
+echo "Do another search to reset the timeout (time_t now=$CONN_BEGINS, new_timeout=$CONN_EXPIRES)"
 $LDAPSEARCH -b "dc=idle-timeout,$BASEDN" \
         -D "cn=Manager,dc=local,dc=com" \
         -H $URI2 \
@@ -288,7 +301,9 @@ if test $RC != 0 ; then
         exit $RC
 fi
 
-sleep `expr $TIMEOUT - 1`
+# sleep until 2 seconds before new exteneded idle-timeout, check that connection still exist
+NOW=`date +%s`
+sleep `expr $CONN_EXPIRES - $NOW - 2`
 echo "Check that connection is still alive due to idle-timeout reset (time_t now=`date +%s`)"
 $LDAPSEARCH -b "cn=Connections,cn=database 2,cn=databases,cn=monitor" -s one -LLL olmDbConnURI \
         -D "cn=Manager,dc=local,dc=com" \
@@ -301,7 +316,9 @@ if test $RC != 0 ; then
     exit $RC
 fi
 
-sleep 2
+# sleep until 2 seconds after timeout, check that connection does not exist
+NOW=`date +%s`
+sleep `expr $CONN_EXPIRES - $NOW + 2`
 echo "Check that connection is closed after extended idle-timeout has passed (time_t now=`date +%s`)"
 $LDAPSEARCH -b "cn=Connections,cn=database 2,cn=databases,cn=monitor" -s one -LLL olmDbConnURI \
         -D "cn=Manager,dc=local,dc=com" \
@@ -314,7 +331,6 @@ if test $RC != 1 ; then
     exit $RC
 fi
 
-
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 echo ">>>>> Test succeeded"