File 0227-ITS-9197-Increase-timeouts-in-test-case-due-to-spora.patch of Package openldap2.20856

From 67f7f7eecbac11bc0040a4034ef2ea1cd99e617d Mon Sep 17 00:00:00 2001
From: Tero Saarni <tero.saarni@est.tech>
Date: Thu, 25 Feb 2021 14:38:45 +0200
Subject: [PATCH 227/230] ITS#9197 Increase timeouts in test case due to
 sporadic failures

---
 tests/scripts/defines.sh            |  2 +-
 tests/scripts/test079-proxy-timeout | 54 +++++++++++++++++++----------
 2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh
index 273f039cf..fe8bd47c3 100755
--- a/tests/scripts/defines.sh
+++ b/tests/scripts/defines.sh
@@ -50,7 +50,7 @@ THREADS=${AC_THREADS-threadsno}
 SLEEP0=${SLEEP0-1}
 SLEEP1=${SLEEP1-7}
 SLEEP2=${SLEEP2-15}
-TIMEOUT=${TIMEOUT-4}
+TIMEOUT=${TIMEOUT-8}
 
 # dirs
 PROGDIR=./progs
diff --git a/tests/scripts/test079-proxy-timeout b/tests/scripts/test079-proxy-timeout
index e097c0739..79f19d937 100644
--- a/tests/scripts/test079-proxy-timeout
+++ b/tests/scripts/test079-proxy-timeout
@@ -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"
-- 
2.30.1

openSUSE Build Service is sponsored by