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