3 # rbd_mirror_ha.sh - test rbd-mirror daemons in HA mode
6 . $(dirname $0)/rbd_mirror_helpers.sh
13 test -n "${pool}" || pool=${POOL}
15 admin_daemon "${CLUSTER1}:${instance}" \
16 rbd mirror status ${pool} ${CLUSTER2} |
24 for s in 1 1 2 4 4 4 4 4 8 8 8 8 16 16 32 64; do
26 for instance in `seq 0 9`; do
27 is_leader ${instance} || continue
40 local cmd="rbd mirror leader release"
42 test -n "${pool}" && cmd="${cmd} ${pool} ${CLUSTER2}"
44 admin_daemon "${CLUSTER1}:${LEADER}" ${cmd}
47 wait_for_leader_released()
53 is_leader ${LEADER} || return 0
65 wait_for_image_replay_started ${CLUSTER1}:${LEADER} ${POOL} ${image}
66 write_image ${CLUSTER2} ${POOL} ${image} 100
67 wait_for_replay_complete ${CLUSTER1}:${LEADER} ${CLUSTER2} ${POOL} \
69 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' \
71 if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
72 wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} \
75 compare_images ${POOL} ${image}
79 testlog "TEST: start first daemon instance and test replay"
80 start_mirror ${CLUSTER1}:0
82 create_image ${CLUSTER2} ${POOL} ${image1}
86 testlog "TEST: release leader and wait it is reacquired"
88 is_leader 0 ${PARENT_POOL}
89 release_leader ${POOL}
90 wait_for_leader_released
91 is_leader 0 ${PARENT_POOL}
94 wait_for_leader_released
95 expect_failure "" is_leader 0 ${PARENT_POOL}
98 testlog "TEST: start second daemon instance and test replay"
99 start_mirror ${CLUSTER1}:1
101 create_image ${CLUSTER2} ${POOL} ${image2}
102 test_replay ${image1} ${image2}
104 testlog "TEST: release leader and test it is acquired by secondary"
106 is_leader 0 ${PARENT_POOL}
107 release_leader ${POOL}
108 wait_for_leader_released
110 test_replay ${image1} ${image2}
112 wait_for_leader_released
116 testlog "TEST: stop first daemon instance and test replay"
117 stop_mirror ${CLUSTER1}:0
119 create_image ${CLUSTER2} ${POOL} ${image3}
121 test_replay ${image1} ${image2} ${image3}
123 testlog "TEST: start first daemon instance and test replay"
124 start_mirror ${CLUSTER1}:0
126 create_image ${CLUSTER2} ${POOL} ${image4}
127 test_replay ${image3} ${image4}
129 testlog "TEST: crash leader and test replay"
130 stop_mirror ${CLUSTER1}:1 -KILL
132 create_image ${CLUSTER2} ${POOL} ${image5}
134 test_replay ${image1} ${image4} ${image5}
136 testlog "TEST: start crashed leader and test replay"
137 start_mirror ${CLUSTER1}:1
139 create_image ${CLUSTER2} ${POOL} ${image6}
140 test_replay ${image1} ${image6}
142 testlog "TEST: start yet another daemon instance and test replay"
143 start_mirror ${CLUSTER1}:2
145 create_image ${CLUSTER2} ${POOL} ${image7}
146 test_replay ${image1} ${image7}
148 testlog "TEST: release leader and test it is acquired by secondary"
151 wait_for_leader_released
153 test_replay ${image1} ${image2}
155 testlog "TEST: stop leader and test replay"
156 stop_mirror ${CLUSTER1}:${LEADER}
158 create_image ${CLUSTER2} ${POOL} ${image8}
159 prev_leader=${LEADER}
161 test_replay ${image1} ${image8}
163 testlog "TEST: start previous leader and test replay"
164 start_mirror ${CLUSTER1}:${prev_leader}
166 create_image ${CLUSTER2} ${POOL} ${image9}
167 test_replay ${image1} ${image9}
169 testlog "TEST: crash leader and test replay"
170 stop_mirror ${CLUSTER1}:${LEADER} -KILL
172 create_image ${CLUSTER2} ${POOL} ${image10}
173 prev_leader=${LEADER}
175 test_replay ${image1} ${image10}
177 testlog "TEST: start previous leader and test replay"
178 start_mirror ${CLUSTER1}:${prev_leader}
180 create_image ${CLUSTER2} ${POOL} ${image11}
181 test_replay ${image1} ${image11}
183 testlog "TEST: start some more daemon instances and test replay"
184 start_mirror ${CLUSTER1}:3
185 start_mirror ${CLUSTER1}:4
186 start_mirror ${CLUSTER1}:5
187 start_mirror ${CLUSTER1}:6
189 create_image ${CLUSTER2} ${POOL} ${image13}
190 test_replay ${leader} ${image1} ${image13}
192 testlog "TEST: release leader and test it is acquired by secondary"
194 wait_for_leader_released
196 test_replay ${image1} ${image2}
198 testlog "TEST: in loop: stop leader and test replay"
199 for i in 0 1 2 3 4 5; do
200 stop_mirror ${CLUSTER1}:${LEADER}
202 test_replay ${image1}
205 stop_mirror ${CLUSTER1}:${LEADER}