]> git.sur5r.net Git - openldap/blob - tests/scripts/test007-replication
9521a7ba131e60374f61ea9829f7c25d54c4eac5
[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 -s base -b "$MONITOR" -h localhost -p $PORT \
47                 'objectclass=*' > /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 -s base -b "$MONITOR" -h localhost -p $PORT \
58                 'objectclass=*' > /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 master directory..."
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 "Waiting 15 seconds for slurpd to send changes..."
81 sleep 15
82
83 echo "Using ldapmodify to modify slave directory..."
84
85 #
86 # Do some modifications
87 #
88
89 $LDAPMODIFY -v -D "$MANAGERDN" -h localhost -p $SLAVEPORT -w $PASSWD > \
90         $TESTOUT 2>&1 << EOMODS
91 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
92 changetype: modify
93 add: drink
94 drink: Orange Juice
95
96 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
97 changetype: modify
98 replace: multilinedescription
99 multilinedescription: The replaced multiLineDescription $ Blah Woof.
100 -
101 replace: drink
102 drink: Iced Tea
103 drink: Mad Dog 20/20
104
105 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
106 delete: member
107 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
108 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
109 -
110 add: member
111 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
112 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
113
114 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
115 changetype: modify
116 delete: member
117
118 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
119 changetype: add
120 objectclass: top
121 objectclass: person
122 objectclass: organizationalPerson
123 objectclass: newPilotPerson
124 objectclass: umichPerson
125 cn: Gern Jensen
126 title: Chief Investigator, ITD
127 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
128 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
129 uid: gjensen
130 krbname: gjensen@umich.edu
131 nobatchupdates: TRUE
132 onvacation: FALSE
133 drink: Coffee
134 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
135 multilinedescription: Very odd
136 facsimiletelephonenumber: +1 313 555 7557
137 telephonenumber: +1 313 555 8343
138 mail: gjensen@mailgw.umich.edu
139 homephone: +1 313 555 8844
140
141 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
142 changetype: delete
143
144 EOMODS
145
146 echo "Waiting 15 seconds for slurpd to send changes..."
147 sleep 15
148
149 echo "Using ldapsearch to read all the entries from the master..."
150 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
151         'objectclass=*' > $MASTEROUT 2>&1
152
153 if test $RC != 0 ; then
154         echo "ldapsearch failed!"
155         kill -HUP $PID $SLAVEPID $SLURPPID
156         exit $RC
157 fi
158
159 echo "Using ldapsearch to read all the entries from the slave..."
160 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
161         'objectclass=*' > $SLAVEOUT 2>&1
162
163 if test $RC != 0 ; then
164         echo "ldapsearch failed!"
165         kill -HUP $PID $SLAVEPID $SLURPPID
166         exit $RC
167 fi
168
169 kill -HUP $PID $SLAVEPID $SLURPPID
170
171 SEARCHOUT=$MASTEROUT
172 LDIF=$SLAVEOUT
173
174 echo "Filtering ldapsearch results..."
175 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
176 echo "Filtering original ldif used to create database..."
177 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
178
179 echo "Comparing retrieved entries from master and slave..."
180 cmp $SEARCHFLT $LDIFFLT
181
182 if test $? != 0 ; then
183         echo "test failed - master and slave databases differ"
184         exit 1
185 fi
186
187 echo ">>>>> Test succeeded"
188
189
190 exit 0