Debian Codegraph @

tests/scripts/lloadd/test000-rootdse

raw
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 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 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
20
21 $SLAPPASSWD -g -n >$CONFIGPWF
22 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
23
24 echo "Starting slapd on TCP/IP port $PORT2..."
25 . $CONFFILTER $BACKEND < $SCHEMACONF > $CONF2
26 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
27 PID=$!
28 if test $WAIT != 0 ; then
29 echo PID $PID
30 read foo
31 fi
32 KILLPIDS="$PID"
33
34 echo "Starting a second slapd on TCP/IP port $PORT3..."
35 sed -e "s,$DBDIR1,$DBDIR2," < $CONF2 > $CONF3
36 $SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
37 PID=$!
38 if test $WAIT != 0 ; then
39 echo PID $PID
40 read foo
41 fi
42 KILLPIDS="$KILLPIDS $PID"
43
44 echo "Starting a third slapd on TCP/IP port $PORT4..."
45 sed -e "s,$DBDIR1,$DBDIR3," < $CONF2 > $CONF4
46 $SLAPD -f $CONF4 -h $URI4 -d $LVL > $LOG4 2>&1 &
47 PID=$!
48 if test $WAIT != 0 ; then
49 echo PID $PID
50 read foo
51 fi
52 KILLPIDS="$KILLPIDS $PID"
53
54 echo "Starting lloadd on TCP/IP port $PORT1..."
55 . $CONFFILTER $BACKEND < $LLOADDANONCONF > $CONF1.lloadd
56 if test $AC_lloadd = lloaddyes; then
57 $LLOADD -f $CONF1.lloadd -h $URI1 -d $LVL > $LOG1 2>&1 &
58 else
59 . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd
60 # FIXME: this won't work on Windows, but lloadd doesn't support Windows yet
61 $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 &
62 fi
63 PID=$!
64 if test $WAIT != 0 ; then
65 echo PID $PID
66 read foo
67 fi
68 KILLPIDS="$KILLPIDS $PID"
69
70 sleep $SLEEP0
71
72 echo "Using ldapsearch to retrieve the root DSE..."
73 for i in 0 1 2 3 4 5; do
74 $LDAPSEARCH -b "" -s base -H $URI1 \
75 '@extensibleObject' > $SEARCHOUT 2>&1
76 RC=$?
77 if test $RC = 0 ; then
78 break
79 fi
80 echo "Waiting $SLEEP1 seconds for lloadd to start..."
81 sleep $SLEEP1
82 done
83
84 if test $RC = 0 ; then
85 echo "Using ldapsearch to retrieve the cn=Subschema..."
86 $LDAPSEARCH -b "cn=Subschema" -s base -H $URI1 \
87 '(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
88 >> $SEARCHOUT 2>&1
89 RC=$?
90
91 fi
92
93 if test $RC = 0 ; then
94 echo "Using ldapsearch to retrieve the cn=Monitor..."
95 $LDAPSEARCH -b "cn=Monitor" -s base -H $URI1 \
96 '@monitor' >> $SEARCHOUT 2>&1
97 RC=$?
98 fi
99
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101
102 count=3
103 if test $RC != 0 ; then
104 echo ">>>>> Test failed"
105 else
106 RC=`grep '^dn:' $SEARCHOUT | wc -l`
107 if test $RC != $count ; then
108 echo ">>>>> Test failed: expected $count entries, got" $RC
109 RC=1
110 else
111 echo ">>>>> Test succeeded"
112 RC=0
113 fi
114 fi
115
116 test $KILLSERVERS != no && wait
117
118 exit $RC