]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test025-limits
fix ITS#4479
[openldap] / tests / scripts / test025-limits
index 7bcc4fcda384e86e5742e2a064d732e5190dcab5..14e9560a36fe1512996f76c4ee49eb212c3220fc 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2006 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,8 @@ if test $WAIT != 0 ; then
 fi
 KILLPIDS="$PID"
 
+sleep 1
+
 echo "Testing slapd searching..."
 for i in 0 1 2 3 4 5; do
        $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
@@ -84,7 +86,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        *)
@@ -107,7 +109,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        *)
@@ -130,13 +132,13 @@ case $RC in
                        if test "$COUNT" -gt "$SIZELIMIT" ; then
                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                               exit $RC
+                               exit 1
                        fi
                        echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -174,13 +176,13 @@ case $RC in
                        if test "$COUNT" -gt "$SIZELIMIT" ; then
                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                               exit $RC
+                               exit 1
                        fi
                        echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -219,7 +221,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        3)
@@ -248,7 +250,7 @@ case $RC in
                else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
@@ -280,13 +282,13 @@ case $RC in
                        if test "$COUNT" -gt "$SIZELIMIT" ; then
                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                               exit $RC
+                               exit 1
                        fi
                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -322,13 +324,13 @@ case $RC in
                        if test "$COUNT" -gt "$SIZELIMIT" ; then
                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                               exit $RC
+                               exit 1
                        fi
                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -364,13 +366,13 @@ case $RC in
                        if test "$COUNT" -gt "$SIZELIMIT" ; then
                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                               exit $RC
+                               exit 1
                        fi
                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -396,23 +398,33 @@ case $RC in
                        if test "$COUNT" -gt "$SIZELIMIT" ; then
                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                               exit $RC
+                               exit 1
                        fi
                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
-               echo "...error: bumped into server-side size limit instead of hard size administrative limit"
-               test $KILLSERVERS != no && kill -HUP $KILLPIDS
-               exit $RC
-       ;;
-       11)
-               echo "...bumped into server-side hard size administrative limit"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...error: bumped into requested ($SIZELIMIT) size limit"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       else
+                               echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
+#      11)
+#              echo "...bumped into server-side hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -434,7 +446,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -446,9 +458,9 @@ case $RC in
                         exit $RC
                fi
        ;;
-       11)
-               echo "...bumped into server-side hard size administrative limit"
-       ;;
+#      11)
+#              echo "...bumped into server-side hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -469,7 +481,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        11)
@@ -498,7 +510,7 @@ case $RC in
                        echo "...error: did not expect ldapsearch success ($RC)!"
                fi
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-               exit $RC
+               exit 1
        ;;
        11)
                echo "...bumped into unchecked administrative limit"
@@ -524,7 +536,7 @@ case $RC in
                        echo "...error: did not expect ldapsearch success ($RC)!"
                fi
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-               exit $RC
+               exit 1
        ;;
        11)
                echo "...bumped into unchecked administrative limit"
@@ -549,7 +561,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -581,7 +593,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -613,7 +625,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -645,7 +657,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -677,7 +689,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -708,7 +720,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                       exit $RC
+                       exit 1
                fi
        ;;
        4)
@@ -771,7 +783,7 @@ case $RC in
                else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        *)
@@ -794,13 +806,13 @@ case $RC in
                         if test "$COUNT" -gt "$SIZELIMIT" ; then
                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                                exit $RC
+                                exit 1
                         fi
                         echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
@@ -839,7 +851,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        3)
@@ -868,7 +880,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                fi
        ;;
        4)
@@ -900,13 +912,13 @@ case $RC in
                         if test "$COUNT" -gt "$SIZELIMIT" ; then
                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                                exit $RC
+                                exit 1
                         fi
                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
@@ -940,13 +952,13 @@ case $RC in
                         if test "$COUNT" -gt "$SIZELIMIT" ; then
                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                                exit $RC
+                                exit 1
                         fi
                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
@@ -980,13 +992,13 @@ case $RC in
                         if test "$COUNT" -gt "$SIZELIMIT" ; then
                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                                exit $RC
+                                exit 1
                         fi
                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
@@ -1024,31 +1036,33 @@ case $RC in
                         if test "$COUNT" -gt "$SIZELIMIT" ; then
                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                                exit $RC
+                                exit 1
                         fi
                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
                if test x"$COUNT" != x ; then
                        if test "$COUNT" = "$SIZELIMIT" ; then
                                echo "...error: bumped into requested ($SIZELIMIT) size limit"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
                        else
-                               echo "...error: got size limit $SIZELIMIT but $COUNT entries"
+                               echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
                        fi
                else
                        echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
-                test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                exit $RC
-       ;;
-       11)
-               echo "...bumped into hard size administrative limit"
        ;;
+#      11)
+#              echo "...bumped into hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -1070,15 +1084,21 @@ case $RC in
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
-               echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
-       ;;
-       11)
-               echo "...bumped into hard size administrative limit"
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
+               else
+                       echo "...error: bumped into size limit but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
+#      11)
+#              echo "...bumped into hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -1099,12 +1119,12 @@ case $RC in
                 else
                         echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
-       11)
-               echo "...bumped into unchecked administrative limit"
-       ;;
+#      11)
+#              echo "...bumped into unchecked administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -1126,7 +1146,7 @@ case $RC in
                         echo "...error: did not expect ldapsearch success ($RC)!"
                 fi
                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                exit $RC
+                exit 1
        ;;
        11)
                echo "...bumped into unchecked administrative limit"
@@ -1155,7 +1175,7 @@ case $RC in
                else
                        echo "...error: did not expect ldapsearch success ($RC)!"
                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
-                        exit $RC
+                        exit 1
                 fi
        ;;
        4)
@@ -1339,7 +1359,56 @@ case $RC in
        ;;
 esac
 
+# ITS#4479
+PAGESIZE=1
+SIZELIMIT=2
+echo "Testing size limit request ($SIZELIMIT) for unlimited ID and pagesize=$PAGESIZE..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test $COUNT = $SIZELIMIT ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries while requesting $SIZELIMIT..."
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 echo ">>>>> Test succeeded"
+
+test $KILLSERVERS != no && wait
+
 exit 0