]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its4337/its4337
Happy New Year
[openldap] / tests / data / regressions / its4337 / its4337
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2018 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 $BACKEND != "bdb" ; then
20         echo "BDB backend not available, test skipped"
21         exit 0
22 fi 
23
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3 $TESTDIR/slapd.d
25
26 ITS=4337
27 ITSDIR=$DATADIR/regressions/its$ITS
28
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 &
33 PID=$!
34 if test $WAIT != 0 ; then
35     echo PID $PID
36     read foo
37 fi
38 KILLPIDS="$PID"
39
40 sleep 1
41
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
46         RC=$?
47         if test $RC = 0 ; then
48                 break
49         fi
50         echo "Waiting 5 seconds for slapd to start..."
51         sleep 5
52 done
53
54 if test $RC != 0 ; then
55         echo "ldapsearch failed ($RC)!"
56         test $KILLSERVERS != no && kill -HUP $KILLPIDS
57         exit $RC
58 fi
59
60 cat /dev/null > $TESTOUT
61 cat /dev/null > $SEARCHOUT
62
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
68 RC=$?
69 if test $RC != 0 ; then
70         echo "ldapsearch failed ($RC)!"
71         test $KILLSERVERS != no && kill -HUP $KILLPIDS
72         exit $RC
73 fi
74
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
81 olcDatabase: bdb
82 olcSuffix: dc=com
83 olcDbDirectory: ./testrun/db.1.a
84 EOMODS
85 RC=$?
86 if test $RC != 0 ; then
87         echo "ldapadd failed ($RC)!"
88         test $KILLSERVERS != no && kill -HUP $KILLPIDS
89         exit $RC
90 fi
91
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
97 RC=$?
98 if test $RC != 0 ; then
99         echo "ldapsearch failed ($RC)!"
100         test $KILLSERVERS != no && kill -HUP $KILLPIDS
101         exit $RC
102 fi
103
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
110 olcDatabase: {1}bdb
111 olcSuffix: dc=org
112 olcDbDirectory: ./testrun/db.2.a
113 EOMODS
114 RC=$?
115 if test $RC != 0 ; then
116         echo "ldapadd failed ($RC)!"
117         test $KILLSERVERS != no && kill -HUP $KILLPIDS
118         if test $RC = 53 ; then
119                 echo "TODO"
120                 exit 0
121         fi
122         exit $RC
123 fi
124
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
130 RC=$?
131 if test $RC != 0 ; then
132         echo "ldapsearch failed ($RC)!"
133         test $KILLSERVERS != no && kill -HUP $KILLPIDS
134         exit $RC
135 fi
136
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138
139 LDIF=$ITSDIR/config.out
140
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
147
148 if test $? != 0 ; then
149         echo "Comparison failed"
150         exit 1
151 fi
152
153 echo ">>>>> Test succeeded"
154
155 test $KILLSERVERS != no && wait
156
157 exit 0