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