]> git.sur5r.net Git - openldap/blob - tests/scripts/test036-meta-concurrency
add concurrency test for back-meta; cleanup previous commit
[openldap] / tests / scripts / test036-meta-concurrency
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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 echo ""
20
21 echo "### this test is currently disabled; enable at own risk ###"
22 exit 0
23
24 if test $BACKMETA = metano ; then 
25         echo "meta backend not available, test skipped"
26         exit 0
27 fi
28
29 rm -rf $TESTDIR
30
31 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
32
33 echo "Starting slapd on TCP/IP port $PORT1..."
34 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $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 echo "Using ldapsearch to check that slapd is running..."
44 for i in 0 1 2 3 4 5; do
45         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
46                 'objectclass=*' > /dev/null 2>&1
47         RC=$?
48         if test $RC = 0 ; then
49                 break
50         fi
51         echo "Waiting 5 seconds for slapd to start..."
52         sleep 5
53 done
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 echo "Using ldapadd to populate the database..."
61 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
62         $LDIFORDERED > $TESTOUT 2>&1
63 RC=$?
64 if test $RC != 0 ; then
65         echo "ldapadd failed ($RC)!"
66         test $KILLSERVERS != no && kill -HUP $KILLPIDS
67         exit $RC
68 fi
69
70 echo "Starting slapd on TCP/IP port $PORT2..."
71 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF2
72 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
73 PID=$!
74 if test $WAIT != 0 ; then
75     echo PID $PID
76     read foo
77 fi
78 KILLPIDS="$KILLPIDS $PID"
79
80 echo "Using ldapsearch to check that slapd is running..."
81 for i in 0 1 2 3 4 5; do
82         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
83                 'objectclass=*' > /dev/null 2>&1
84         RC=$?
85         if test $RC = 0 ; then
86                 break
87         fi
88         echo "Waiting 5 seconds for slapd to start..."
89         sleep 5
90 done
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 "Using ldapadd to populate the database..."
98 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
99         $LDIFMETA >> $TESTOUT 2>&1
100 RC=$?
101 if test $RC != 0 ; then
102         echo "ldapadd failed ($RC)!"
103         test $KILLSERVERS != no && kill -HUP $KILLPIDS
104         exit $RC
105 fi
106
107 cat /dev/null > $SEARCHOUT
108
109 mkdir -p $TESTDIR/$DATADIR
110 METABASEDN="o=Example,c=US"
111 for f in $DATADIR/do_* ; do
112         sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
113 done
114
115 echo "Using tester for concurrent server access..."
116 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT2 -D "cn=Manager,$METABASEDN" -w $PASSWD -l 50 -r 20
117 RC=$?
118
119 if test $RC != 0 ; then
120         echo "slapd-tester failed ($RC)!"
121         test $KILLSERVERS != no && kill -HUP $KILLPIDS
122         exit $RC
123 fi 
124
125 echo "Using ldapsearch to retrieve all the entries..."
126 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT2 \
127                         'objectClass=*' > $SEARCHOUT 2>&1
128 RC=$?
129
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131
132 if test $RC != 0 ; then
133         echo "ldapsearch failed ($RC)!"
134         exit $RC
135 fi
136
137 echo "Filtering ldapsearch results..."
138 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
139 echo "Filtering original ldif used to create database..."
140 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
141 echo "Comparing filter output..."
142 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
143         
144 if test $? != 0 ; then
145         echo "comparison failed - meta search/modification didn't succeed"
146         exit 1
147 fi
148
149 echo ">>>>> Test succeeded"
150 exit 0
151