1#! /bin/sh 2# $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2021 The OpenLDAP Foundation. 6## All rights reserved. 7## 8## Redistribution and use in source and binary forms, with or without 9## modification, are permitted only as authorized by the OpenLDAP 10## Public License. 11## 12## A copy of this license is available in the file LICENSE in the 13## top-level directory of the distribution or, alternatively, at 14## <http://www.OpenLDAP.org/license.html>. 15 16echo "running defines.sh" 17. $SRCDIR/scripts/defines.sh 18 19if test $BACKSQL = "sqlno" ; then 20 echo "SQL backend not available, test skipped" 21 exit 0 22fi 23 24if test $RDBMS = "rdbmsno" ; then 25 echo "SQL test not requested, test skipped" 26 exit 0 27fi 28 29if test "x$TESTLOOPS" = "x" ; then 30 TESTLOOPS=5 31fi 32 33if test "x$CHILDREN" = "x" ; then 34 CHILDREN="-j 4" 35else 36 CHILDREN="-j $CHILDREN" 37fi 38 39SQLDATADIR=$TESTDIR/sql-concurrency 40mkdir -p $TESTDIR $SQLDATADIR 41 42echo "Starting slapd on TCP/IP port $PORT1..." 43. $CONFFILTER $BACKEND < $SQLCONF > $CONF1 44$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 45PID=$! 46if test $WAIT != 0 ; then 47 echo PID $PID 48 read foo 49fi 50KILLPIDS="$PID" 51 52echo "Testing SQL backend concurrency..." 53for i in 0 1 2 3 4 5; do 54 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 55 'objectclass=*' > /dev/null 2>&1 56 RC=$? 57 if test $RC = 0 ; then 58 break 59 fi 60 echo "Waiting 5 seconds for slapd to start..." 61 sleep 5 62done 63 64if test $RC != 0 ; then 65 echo "ldapsearch failed ($RC)!" 66 test $KILLSERVERS != no && kill -HUP $KILLPIDS 67 exit $RC 68fi 69 70echo "Using ldapsearch to retrieve all the entries..." 71$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 72 '(objectClass=*)' > $SEARCHOUT 2>&1 73RC=$? 74 75if test $RC != 0 ; then 76 echo "ldapsearch failed ($RC)!" 77 test $KILLSERVERS != no && kill -HUP $KILLPIDS 78 exit $RC 79fi 80 81echo "Filtering original ldif used to create database..." 82$LDIFFILTER < $SEARCHOUT > $LDIFFLT 83 84if test "${RDBMSWRITE}" != "yes"; then 85 echo "write test disabled for ${RDBMS}; set SLAPD_USE_SQLWRITE=yes to enable" 86 cp $SQLCONCURRENCYDIR/do_read* $SQLCONCURRENCYDIR/do_search* \ 87 $SQLCONCURRENCYDIR/do_bind* $SQLDATADIR 88else 89 case ${RDBMS} in 90 # list here the RDBMSes whose mapping allows writes 91 pgsql|ibmdb2) 92 cp $SQLCONCURRENCYDIR/do_* $SQLDATADIR 93 ;; 94 *) 95 echo "write is not supported for ${RDBMS}; performing read-only concurrency test" 96 cp $SQLCONCURRENCYDIR/do_read* $SQLCONCURRENCYDIR/do_search* \ 97 $SQLCONCURRENCYDIR/do_bind* $SQLDATADIR 98 ;; 99 esac 100fi 101 102echo "Using tester for concurrent server access..." 103$SLAPDTESTER -P "$PROGDIR" -d "$SQLDATADIR" \ 104 -H $URI1 -D "$MANAGERDN" -w $PASSWD \ 105 -l $TESTLOOPS $CHILDREN -FF 106RC=$? 107 108if test $RC != 0 ; then 109 echo "slapd-tester failed ($RC)!" 110 test $KILLSERVERS != no && kill -HUP $KILLPIDS 111 exit $RC 112fi 113 114echo "Using ldapsearch to retrieve all the entries..." 115$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 116 '(objectClass=*)' > $SEARCHOUT 2>&1 117RC=$? 118 119test $KILLSERVERS != no && kill -HUP $KILLPIDS 120 121if test $RC != 0 ; then 122 echo "ldapsearch failed ($RC)!" 123 exit $RC 124fi 125 126echo "Filtering ldapsearch results..." 127$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 128echo "Comparing filter output..." 129$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 130 131if test $? != 0 ; then 132 echo "comparison failed - database was not created correctly" 133 exit 1 134fi 135 136echo ">>>>> Test succeeded" 137exit 0 138 139