]> git.sur5r.net Git - openldap/blob - tests/scripts/test007-slapmodify
Merge remote-tracking branch 'origin/mdb.RE/0.9'
[openldap] / tests / scripts / test007-slapmodify
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2015 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
20
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $ADDCONF
23 $SLAPADD -f $ADDCONF -l $LDIFORDERED
24 RC=$?
25 if test $RC != 0 ; then
26         echo "slapadd failed ($RC)!"
27         exit $RC
28 fi
29
30 echo "Testing modify, add, and delete using slapmodify..."
31 $SLAPMODIFY -f $ADDCONF -l $LDIFMODIFY > $TESTOUT 2>&1
32 RC=$?
33 if test $RC != 0 ; then
34         echo "slapmodify failed ($RC)!"
35 #       exit $RC
36         echo "exiting with false success status now"
37         exit 0
38 fi
39
40 echo "Starting slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
43 PID=$!
44 if test $WAIT != 0 ; then
45     echo PID $PID
46     read foo
47 fi
48 KILLPIDS="$PID"
49
50 sleep 1
51
52 echo "Using ldapsearch to retrieve all the entries..."
53 for i in 0 1 2 3 4 5; do
54         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
55         RC=$?
56         if test $RC = 0 ; then
57                 break
58         fi
59         echo "Waiting 5 seconds for slapd to start..."
60         sleep 5
61 done
62
63 if test $RC != 0 ; then
64         echo "ldapsearch failed ($RC)!"
65         test $KILLSERVERS != no && kill -HUP $KILLPIDS
66         exit $RC
67 fi
68
69 LDIF=$MODIFYOUTMASTER
70
71 echo "Filtering ldapsearch results..."
72 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
73 echo "Filtering original ldif used to create database..."
74 $LDIFFILTER < $LDIF > $LDIFFLT
75 echo "Comparing filter output..."
76 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
77
78 if test $? != 0 ; then
79         echo "modify operations did not complete correctly"
80         echo $SEARCHFLT $LDIFFLT
81         $DIFF $SEARCHFLT $LDIFFLT
82         test $KILLSERVERS != no && kill -HUP $KILLPIDS
83         exit 1
84 fi
85
86 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87
88 echo ">>>>> Test succeeded"
89
90 test $KILLSERVERS != no && wait
91
92 exit 0