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