]> git.sur5r.net Git - openldap/blob - tests/scripts/test033-glue-syncrepl
This test uses syncrepl persist, but ldbm doesn't support that. Exclude it.
[openldap] / tests / scripts / test033-glue-syncrepl
1 #! /bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 1998-2005 The OpenLDAP Foundation.
5 ## All rights reserved.
6 ##
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
9 ## Public License.
10 ##
11 ## A copy of this license is available in the file LICENSE in the
12 ## top-level directory of the distribution or, alternatively, at
13 ## <http://www.OpenLDAP.org/license.html>.
14
15 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
16         echo "Test does not support $BACKEND"
17         exit 0
18 fi
19
20 echo "running defines.sh"
21 . $SRCDIR/scripts/defines.sh
22
23 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C
24
25 echo "Running slapadd to build glued slapd databases..."
26 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
27 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
28 RC=$?
29 if test $RC != 0 ; then
30         echo "slapadd failed ($RC)!"
31         exit $RC
32 fi
33
34 mv $DBDIR1B $DBDIR2B
35 mkdir $DBDIR2A $DBDIR1B
36 cp -pr $DBDIR1C $DBDIR2C
37
38 echo "Starting slapd 1 on TCP/IP port $PORT1..."
39 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 PID=$!
42 if test $WAIT != 0 ; then
43     echo PID $PID
44     read foo
45 fi
46 KILLPIDS="$PID"
47
48 sleep 1
49
50 echo "Using ldapsearch to check that slapd 1 is running..."
51 for i in 0 1 2 3 4 5; do
52         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53                 '(objectclass=*)' > /dev/null 2>&1
54         RC=$?
55         if test $RC = 0 ; then
56                 break
57         fi
58         echo "Waiting 5 seconds for slapd to start..."
59         sleep 5
60 done
61
62 echo "Starting slapd 2 on TCP/IP port $PORT2..."
63 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
64 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
65 PID=$!
66 if test $WAIT != 0 ; then
67     echo PID $PID
68     read foo
69 fi
70 KILLPIDS="$KILLPIDS $PID"
71
72 sleep 1
73
74 echo "Using ldapsearch to check that slapd 2 is running..."
75 for i in 0 1 2 3 4 5; do
76         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
77                 '(objectclass=*)' > /dev/null 2>&1
78         RC=$?
79         if test $RC = 0 ; then
80                 break
81         fi
82         echo "Waiting 5 seconds for slapd to start..."
83         sleep 5
84 done
85
86 echo "Waiting 15 seconds for shadow subtrees to sync..."
87 sleep 15
88
89 for P in $PORT1 $PORT2 ; do
90         echo "Using ldapsearch to read all the entries from port $P..."
91         $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
92                 -S "" '(objectclass=*)' > $SEARCHOUT 2>&1
93         RC=$?
94
95         if test $RC != 0 ; then
96                 echo "ldapsearch failed ($RC)!"
97                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
98                 exit $RC
99         fi
100
101         echo "Filtering ldapsearch results..."
102         . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
103         echo "Filtering original ldif used to create database..."
104         . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
105         echo "Comparing filter output..."
106         $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
107
108         if test $? != 0 ; then
109                 echo "comparison failed - database was not created correctly"
110                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111                 exit 1
112         fi
113 done
114
115 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116
117 echo ">>>>> Test succeeded"
118 exit 0