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