3 # Copyright (c) 2006 - 2007 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # 3. Neither the name of the Institute nor the names of its contributors
19 # may be used to endorse or promote products derived from this software
20 # without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 # If there is no useful db support compile in, disable test
42 ../db/have-db || exit 77
44 # Dont run this test in AFS, since it lacks support for AF_UNIX
45 expr "X`/bin/pwd || pwd`" : "X/afs/.*" > /dev/null 2>/dev/null && exit 77
51 cache="FILE:${objdir}/cache.krb5"
52 keytabfile=${objdir}/iprop.keytab
53 keytab="FILE:${keytabfile}"
55 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
56 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -r $R"
57 ipropdslave="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-slave"
58 ipropdmaster="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-master"
59 iproplog="${TESTS_ENVIRONMENT} ../../lib/kadm5/iprop-log"
61 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
63 KRB5_CONFIG="${objdir}/krb5.conf"
75 echo Creating database
78 --realm-max-ticket-life=1day \
79 --realm-max-renewable-life=1month \
82 ${kadmin} -l add -p foo --use-defaults user@${R} || exit 1
84 ${kadmin} -l add --random-key --use-defaults iprop/localhost@${R} || exit 1
85 ${kadmin} -l ext -k ${keytab} iprop/localhost@${R} || exit 1
86 ${kadmin} -l add --random-key --use-defaults iprop/slave@${R} || exit 1
87 ${kadmin} -l ext -k ${keytab} iprop/slave@${R} || exit 1
89 echo foo > ${objdir}/foopassword
97 trap "echo 'killing ipropd s + m + kdc'; kill \${ipdm} \${ipds} \${kdcpid} >/dev/null 2>/dev/null; tail messages.log ; tail iprop-stats; exit 1;" EXIT
103 sh ${srcdir}/wait-kdc.sh || exit 1
105 echo "starting master"
106 ${ipropdmaster} --hostname=localhost -k ${keytab} \
107 --database=${objdir}/current-db &
109 sh ${srcdir}/wait-kdc.sh ipropd-master || exit 1
111 echo "starting slave"
112 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
113 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
115 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
117 echo "checking slave is up"
118 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
120 # ----------------- checking: pushing lives changes
123 ${kadmin} -l add --random-key --use-defaults host/foo@${R} || exit 1
125 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
126 ${kadmin} -l get host/foo@${R} > /dev/null || exit 1
129 ${kadmin} -l rename host/foo@${R} host/bar@${R} || exit 1
131 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
132 ${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null && exit 1
133 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
134 ${kadmin} -l get host/bar@${R} > /dev/null || exit 1
137 ${kadmin} -l delete host/bar@${R} || exit 1
139 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
140 ${kadmin} -l get host/bar@${R} > /dev/null 2>/dev/null && exit 1
147 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Down' iprop-stats >/dev/null || exit 1
149 # ----------------- checking: slave is missing changes while down
151 echo "doing changes while slave is down"
152 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
153 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
155 echo "Makeing a copy of the master log file"
156 cp ${objdir}/current.log ${objdir}/current.log.tmp
158 # ----------------- checking: checking that master and slaves resyncs
160 echo "starting slave again"
163 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
164 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
166 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
168 echo "checking slave is up again"
169 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
170 echo "checking for replay problems"
171 ${EGREP} 'Entry already exists in database' messages.log && exit 1
173 echo "kill slave and remove log and database"
177 rm current.slave.log current-db.slave* || exit 1
180 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
181 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
183 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
185 echo "checking slave is up again"
186 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
187 echo "checking for replay problems"
188 ${EGREP} 'Entry already exists in database' messages.log && exit 1
190 # ----------------- checking: checking live truncation of master log
192 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
195 echo "live truncate on master log"
196 ${iproplog} truncate || exit 1
199 echo "Killing master and slave"
200 kill ${ipdm} ${ipds} >/dev/null 2>/dev/null
203 ${EGREP} "^master down at " iprop-stats > /dev/null || exit 1
205 echo "compare versions on master and slave logs"
206 KRB5_CONFIG=${objdir}/krb5-slave.conf \
207 ${iproplog} last-version > slave-last.tmp
208 ${iproplog} last-version > master-last.tmp
209 cmp master-last.tmp slave-last.tmp || exit 1
211 # ----------------- checking: master going backward
215 echo "Going back to old version of the master log file"
216 cp ${objdir}/current.log.tmp ${objdir}/current.log
218 echo "starting master"
219 ${ipropdmaster} --hostname=localhost -k ${keytab} \
220 --database=${objdir}/current-db &
222 sh ${srcdir}/wait-kdc.sh ipropd-master || exit 1
224 echo "starting slave"
225 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
226 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
228 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
230 echo "checking slave is up again"
231 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
232 echo "checking for replay problems"
233 ${EGREP} 'Entry already exists in database' messages.log && exit 1
235 echo "pushing one change"
236 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
240 kill ${ipdm} ${ipds} ${kdcpid}
242 echo "compare versions on master and slave logs"
243 KRB5_CONFIG=${objdir}/krb5-slave.conf \
244 ${iproplog} last-version > slave-last.tmp
245 ${iproplog} last-version > master-last.tmp
246 cmp master-last.tmp slave-last.tmp || exit 1