]> git.sur5r.net Git - openldap/blob - tests/scripts/test011-glue-slapadd
df6afa1d581fa6166bfd97106400af02c9be17ed
[openldap] / tests / scripts / test011-glue-slapadd
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $GLUE = glueno; then 
20         echo "Backend glue overlay not available, test skipped"
21         exit 0
22 fi 
23
24 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C
25
26 echo "Running slapadd to build glued slapd databases..."
27 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
28 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
29 RC=$?
30 if test $RC != 0 ; then
31         echo "slapadd failed ($RC)!"
32         exit $RC
33 fi
34
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
37 PID=$!
38 if test $WAIT != 0 ; then
39     echo PID $PID
40     read foo
41 fi
42 KILLPIDS="$PID"
43
44 echo "Using ldapsearch to retrieve all the entries..."
45 for i in 0 1 2 3 4 5; do
46         $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
47         RC=$?
48         if test $RC = 0 ; then
49                 break
50         fi
51         echo "Waiting 5 seconds for slapd to start..."
52         sleep 5
53 done
54
55 if test $RC != 0 ; then
56         echo "ldapsearch failed ($RC)!"
57         exit $RC
58 fi
59
60 echo "Filtering ldapsearch results..."
61 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
62 echo "Filtering original ldif used to create database..."
63 . $LDIFFILTER < $LDIFGLUED > $LDIFFLT
64 echo "Comparing filter output..."
65 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
66
67 if test $? != 0 ; then
68         echo "comparison failed - database was not created correctly"
69         echo $SEARCHFLT $LDIFFLT
70         $DIFF $SEARCHFLT $LDIFFLT
71         test $KILLSERVERS != no && kill -HUP $KILLPIDS
72         exit 1
73 fi
74
75 echo "Testing sizelimit..."
76 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 -s one -z 2 > $SEARCHOUT 2>&1
77 RC=$?
78 if test $RC = 0 ; then
79         echo "sizelimit not detected at end of search."
80         test $KILLSERVERS != no && kill -HUP $KILLPIDS
81         exit 1
82 fi
83
84 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 -z 9 objectclass=OpenLDAPPerson > $SEARCHOUT 2>&1
85 RC=$?
86 if test $RC = 0 ; then
87         echo "sizelimit not detected at middle of search."
88         test $KILLSERVERS != no && kill -HUP $KILLPIDS
89         exit 1
90 fi
91
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93
94 echo ">>>>> Test succeeded"
95 exit 0