]> git.sur5r.net Git - openldap/blob - tests/scripts/test007-replication
ldapmodify/add: Fix -P option
[openldap] / tests / scripts / test007-replication
1 #! /bin/sh
2
3 #
4 # Test replication:
5 # - start master
6 # - start slave
7 # - start slurpd
8 # - populate over ldap
9 # - perform some modifies and deleted
10 # - retrieve database over ldap and compare against expected results
11 #
12
13 if test $# -eq 0 ; then
14         SRCDIR="."
15 else
16         SRCDIR=$1; shift
17 fi
18 if test $# -eq 1 ; then
19         BACKEND=$1; shift
20 fi
21
22 echo "running defines.sh $SRCDIR $BACKEND"
23 . $SRCDIR/scripts/defines.sh
24
25 if test ! -x $SLURPD ; then
26         echo ">>>>> $SLURPD is not executable or do not exist."
27         echo ">>>>> Test skipped."
28         exit 0
29 fi
30
31 echo "Cleaning up in $DBDIR..."
32 rm -f $DBDIR/[!C]*
33 echo "Cleaning up in $REPLDIR..."
34 rm -f $REPLDIR/[!C]*
35
36 echo "Starting master slapd on TCP/IP port $PORT..."
37 $SLAPD -f $MASTERCONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
38 PID=$!
39
40 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
41 $SLAPD -f $SLAVECONF -p $SLAVEPORT -d $LVL $TIMING > $SLAVELOG 2>&1 &
42 SLAVEPID=$!
43
44 echo "Using ldapsearch to check that master slapd is running..."
45 for i in 0 1 2 3 4 5; do
46         $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $PORT \
47                 'cn=Monitor' > /dev/null 2>&1
48         RC=$?
49         if test $RC = 1 ; then
50                 echo "Waiting 5 seconds for slapd to start..."
51                 sleep 5
52         fi
53 done
54
55 echo "Using ldapsearch to check that slave slapd is running..."
56 for i in 0 1 2 3 4 5; do
57         $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $SLAVEPORT \
58                 'cn=Monitor' > /dev/null 2>&1
59         RC=$?
60         if test $RC = 1 ; then
61                 echo "Waiting 5 seconds for slapd to start..."
62                 sleep 5
63         fi
64 done
65
66 echo "Starting slurpd..."
67 $SLURPD -f $MASTERCONF -d 4 -t $REPLDIR > $SLURPLOG 2>&1 &
68 SLURPPID=$!
69
70 echo "Using ldapadd to populate the database..."
71 $LDAPADD -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
72         $LDIFORDERED > /dev/null 2>&1
73 RC=$?
74 if test $RC != 0 ; then
75         echo "ldapadd failed!"
76         kill -HUP $PID $SLAVEPID $SLURPPID
77         exit $RC
78 fi
79
80 echo "Using ldapmodify to modify the database..."
81 #
82 # Do some modifications
83 #
84
85 $LDAPMODIFY -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
86         /dev/null 2>&1 << EOMODS
87 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
88 changetype: modify
89 add: drink
90 drink: Orange Juice
91
92 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
93 changetype: modify
94 replace: multilinedescription
95 multilinedescription: The replaced multiLineDescription $ Blah Woof.
96 -
97 replace: drink
98 drink: Iced Tea
99 drink: Mad Dog 20/20
100
101 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
102 delete: member
103 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
104 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
105 -
106 add: member
107 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
108 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
109
110 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
111 changetype: modify
112 delete: member
113
114 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
115 changetype: add
116 objectclass: top
117 objectclass: person
118 objectclass: organizationalPerson
119 objectclass: newPilotPerson
120 objectclass: umichPerson
121 cn: Gern Jensen
122 title: Chief Investigator, ITD
123 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
124 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
125 uid: gjensen
126 krbname: gjensen@umich.edu
127 nobatchupdates: TRUE
128 onvacation: FALSE
129 drink: Coffee
130 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
131 multilinedescription: Very odd
132 facsimiletelephonenumber: +1 313 555 7557
133 telephonenumber: +1 313 555 8343
134 mail: gjensen@mailgw.umich.edu
135 homephone: +1 313 555 8844
136
137 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
138 changetype: delete
139
140 EOMODS
141
142 echo "Waiting 15 seconds for slurpd to send changes..."
143 sleep 15
144
145 echo "Using ldapsearch to read all the entries from the master..."
146 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
147         'objectclass=*' > $MASTEROUT 2>&1
148
149 if test $RC != 0 ; then
150         echo "ldapsearch failed!"
151         kill -HUP $PID $SLAVEPID $SLURPPID
152         exit $RC
153 fi
154
155 echo "Using ldapsearch to read all the entries from the slave..."
156 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
157         'objectclass=*' > $SLAVEOUT 2>&1
158
159 if test $RC != 0 ; then
160         echo "ldapsearch failed!"
161         kill -HUP $PID $SLAVEPID $SLURPPID
162         exit $RC
163 fi
164
165 kill -HUP $PID $SLAVEPID $SLURPPID
166
167 SEARCHOUT=$MASTEROUT
168 LDIF=$SLAVEOUT
169
170 echo "Filtering ldapsearch results..."
171 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
172 echo "Filtering original ldif used to create database..."
173 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
174
175 echo "Comparing retrieved entries from master and slave..."
176 cmp $SEARCHFLT $LDIFFLT
177
178 if test $? != 0 ; then
179         echo "test failed - master and slave databases differ"
180         exit 1
181 fi
182
183 echo ">>>>> Test succeeded"
184
185
186 exit 0