3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2013 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $BACKLDAP = "ldapno" ; then
20 echo "LDAP backend not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3 $TESTDIR/slapd.d
27 ITSDIR=$DATADIR/regressions/its$ITS
29 echo "Starting slapd on TCP/IP port $PORT1..."
30 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf > $CONF1
31 #$SLAPD -f $CONF1 -F $TESTDIR/slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
32 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
34 if test $WAIT != 0 ; then
42 echo "Using ldapsearch to check that slapd is running..."
43 for i in 0 1 2 3 4 5; do
44 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
45 'objectclass=*' > /dev/null 2>&1
47 if test $RC = 0 ; then
50 echo "Waiting 5 seconds for slapd to start..."
54 if test $RC != 0 ; then
55 echo "ldapsearch failed ($RC)!"
56 test $KILLSERVERS != no && kill -HUP $KILLPIDS
60 cat /dev/null > $TESTOUT
61 cat /dev/null > $SEARCHOUT
63 echo "Searching databases..."
64 echo "# Searching databases __before__ append..." >> $SEARCHOUT
65 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
66 -D "cn=config" -w "config" -b "cn=config" \
67 '(objectClass=olcDatabaseConfig)' >> $SEARCHOUT 2>> $TESTOUT
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Appending a database..."
76 $LDAPADD -v -D "cn=config" -w "config" -h $LOCALHOST -p $PORT1 \
77 >> $TESTOUT 2>&1 << EOMODS
78 dn: olcDatabase=bdb,cn=config
79 objectClass: olcDatabaseConfig
80 objectClass: olcBdbConfig
83 olcDbDirectory: ./testrun/db.1.a
86 if test $RC != 0 ; then
87 echo "ldapadd failed ($RC)!"
88 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 echo "Searching databases..."
93 echo "# Searching databases __after__ append..." >> $SEARCHOUT
94 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
95 -D "cn=config" -w "config" -b "cn=config" \
96 '(objectClass=olcDatabaseConfig)' >> $SEARCHOUT 2>> $TESTOUT
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Inserting a database..."
105 $LDAPADD -v -D "cn=config" -w "config" -h $LOCALHOST -p $PORT1 \
106 >> $TESTOUT 2>&1 << EOMODS
107 dn: olcDatabase={1}bdb,cn=config
108 objectClass: olcDatabaseConfig
109 objectClass: olcBdbConfig
112 olcDbDirectory: ./testrun/db.2.a
115 if test $RC != 0 ; then
116 echo "ldapadd failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 if test $RC = 53 ; then
125 echo "Searching databases..."
126 echo "# Searching databases __after__ insert..." >> $SEARCHOUT
127 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
128 -D "cn=config" -w "config" -b "cn=config" \
129 '(objectClass=olcDatabaseConfig)' >> $SEARCHOUT 2>> $TESTOUT
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
139 LDIF=$ITSDIR/config.out
141 echo "Filtering ldapsearch results..."
142 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
143 echo "Filtering original ldif..."
144 $LDIFFILTER < $LDIF > $LDIFFLT
145 echo "Comparing filter output..."
146 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
148 if test $? != 0 ; then
149 echo "Comparison failed"
153 echo ">>>>> Test succeeded"
155 test $KILLSERVERS != no && wait