]> git.sur5r.net Git - openldap/blob - tests/scripts/test007-slapmodify
ITS#8291 Enable slapmodify logging in tests
[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-2017 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 -d $LVL -l $LDIFMODIFY > $TESTOUT 2>&1
32 RC=$?
33 if test $RC != 0 ; then
34         echo "slapmodify failed ($RC)!"
35         exit $RC
36 fi
37
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $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 sleep 1
49
50 echo "Using ldapsearch to retrieve all the entries..."
51 for i in 0 1 2 3 4 5; do
52         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
53         RC=$?
54         if test $RC = 0 ; then
55                 break
56         fi
57         echo "Waiting 5 seconds for slapd to start..."
58         sleep 5
59 done
60
61 if test $RC != 0 ; then
62         echo "ldapsearch failed ($RC)!"
63         test $KILLSERVERS != no && kill -HUP $KILLPIDS
64         exit $RC
65 fi
66
67 LDIF=$MODIFYOUTMASTER
68
69 echo "Filtering ldapsearch results..."
70 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
71 echo "Filtering original ldif used to create database..."
72 $LDIFFILTER < $LDIF > $LDIFFLT
73 echo "Comparing filter output..."
74 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
75
76 if test $? != 0 ; then
77         echo "modify operations did not complete correctly"
78         echo $SEARCHFLT $LDIFFLT
79         $DIFF $SEARCHFLT $LDIFFLT
80         test $KILLSERVERS != no && kill -HUP $KILLPIDS
81         exit 1
82 fi
83
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85
86 echo ">>>>> Test succeeded"
87
88 test $KILLSERVERS != no && wait
89
90 exit 0