]> git.sur5r.net Git - openldap/blob - tests/scripts/test033-glue-syncrepl
Regenerated with new OL_ARG_ENABLE
[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 echo "running defines.sh"
16 . $SRCDIR/scripts/defines.sh
17
18 if test $GLUE = glueno; then 
19         echo "Backend glue overlay not available, test skipped"
20         exit 0
21 fi 
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 echo "Using ldapsearch to check that slapd 1 is running..."
49 for i in 0 1 2 3 4 5; do
50         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
51                 '(objectclass=*)' > /dev/null 2>&1
52         RC=$?
53         if test $RC = 0 ; then
54                 break
55         fi
56         echo "Waiting 5 seconds for slapd to start..."
57         sleep 5
58 done
59
60 echo "Starting slapd 2 on TCP/IP port $PORT2..."
61 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
62 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
63 PID=$!
64 if test $WAIT != 0 ; then
65     echo PID $PID
66     read foo
67 fi
68 KILLPIDS="$KILLPIDS $PID"
69
70 echo "Using ldapsearch to check that slapd 2 is running..."
71 for i in 0 1 2 3 4 5; do
72         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
73                 '(objectclass=*)' > /dev/null 2>&1
74         RC=$?
75         if test $RC = 0 ; then
76                 break
77         fi
78         echo "Waiting 5 seconds for slapd to start..."
79         sleep 5
80 done
81
82 echo "Waiting 15 seconds for shadow subtrees to sync..."
83 sleep 15
84
85 for P in $PORT1 $PORT2 ; do
86         echo "Using ldapsearch to read all the entries from port $P..."
87         $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
88                 -S "" '(objectclass=*)' > $SEARCHOUT 2>&1
89         RC=$?
90
91         if test $RC != 0 ; then
92                 echo "ldapsearch failed ($RC)!"
93                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94                 exit $RC
95         fi
96
97         echo "Filtering ldapsearch results..."
98         . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
99         echo "Filtering original ldif used to create database..."
100         . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
101         echo "Comparing filter output..."
102         $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
103
104         if test $? != 0 ; then
105                 echo "comparison failed - database was not created correctly"
106                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
107                 exit 1
108         fi
109 done
110
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112
113 echo ">>>>> Test succeeded"
114 exit 0