]> git.sur5r.net Git - openldap/blob - tests/scripts/test033-glue-syncrepl
Tweak slapd startup delays
[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 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C
19
20 echo "Running slapadd to build glued slapd databases..."
21 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
22 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
23 RC=$?
24 if test $RC != 0 ; then
25         echo "slapadd failed ($RC)!"
26         exit $RC
27 fi
28
29 mv $DBDIR1B $DBDIR2B
30 mkdir $DBDIR2A $DBDIR1B
31 cp -pr $DBDIR1C $DBDIR2C
32
33 echo "Starting slapd 1 on TCP/IP port $PORT1..."
34 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1
35 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
36 PID=$!
37 if test $WAIT != 0 ; then
38     echo PID $PID
39     read foo
40 fi
41 KILLPIDS="$PID"
42
43 sleep 1
44
45 echo "Using ldapsearch to check that slapd 1 is running..."
46 for i in 0 1 2 3 4 5; do
47         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
48                 '(objectclass=*)' > /dev/null 2>&1
49         RC=$?
50         if test $RC = 0 ; then
51                 break
52         fi
53         echo "Waiting 5 seconds for slapd to start..."
54         sleep 5
55 done
56
57 echo "Starting slapd 2 on TCP/IP port $PORT2..."
58 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
59 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
60 PID=$!
61 if test $WAIT != 0 ; then
62     echo PID $PID
63     read foo
64 fi
65 KILLPIDS="$KILLPIDS $PID"
66
67 sleep 1
68
69 echo "Using ldapsearch to check that slapd 2 is running..."
70 for i in 0 1 2 3 4 5; do
71         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
72                 '(objectclass=*)' > /dev/null 2>&1
73         RC=$?
74         if test $RC = 0 ; then
75                 break
76         fi
77         echo "Waiting 5 seconds for slapd to start..."
78         sleep 5
79 done
80
81 echo "Waiting 15 seconds for shadow subtrees to sync..."
82 sleep 15
83
84 for P in $PORT1 $PORT2 ; do
85         echo "Using ldapsearch to read all the entries from port $P..."
86         $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
87                 -S "" '(objectclass=*)' > $SEARCHOUT 2>&1
88         RC=$?
89
90         if test $RC != 0 ; then
91                 echo "ldapsearch failed ($RC)!"
92                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93                 exit $RC
94         fi
95
96         echo "Filtering ldapsearch results..."
97         . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
98         echo "Filtering original ldif used to create database..."
99         . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
100         echo "Comparing filter output..."
101         $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
102
103         if test $? != 0 ; then
104                 echo "comparison failed - database was not created correctly"
105                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106                 exit 1
107         fi
108 done
109
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111
112 echo ">>>>> Test succeeded"
113 exit 0