6 Verify that "ctdb setreclock" sets the recovery lock correctly.
8 This test only does something when there is a recovery lock
13 . "${TEST_SCRIPTS_DIR}/integration.bash"
22 ctdb_restart_when_done
27 try_command_on_node any $CTDB status
28 generation=$(sed -n -e 's@^Generation:@@p' <<<"$out")
31 generation_has_changed ()
33 local old_generation="$generation"
35 [ "$old_generation" != "$generation" ]
38 wait_until_generation_has_changed ()
41 echo "Wait until generation has changed..."
42 wait_until 60 generation_has_changed
45 wait_until_recovered ()
47 wait_until_generation_has_changed
48 wait_until_node_has_status all recovered
51 echo "Check that recovery lock is set the same on all nodes..."
52 try_command_on_node -v -q all $CTDB getreclock
53 n=$(echo "$out" | sort -u | wc -l)
54 if [ "$n" = 1 ] ; then
55 echo "GOOD: All nodes have the same recovery lock setting"
57 echo "BAD: Recovery lock setting differs across nodes"
62 echo "Check that recovery lock is actually enabled..."
63 t=$(echo "$out" | sed -e 's@^Reclock file:@@' | sort -u)
64 if [ "$t" != "No reclock file used." ] ; then
65 echo "OK: Recovery lock is set"
67 echo "OOPS: Recovery lock is unset. Skipping remainder of test"
72 orig_reclock=$(sed -n -e '1s@^Reclock file:@@p' <<<"$out")
73 echo "Remember original recovery lock file: \"${orig_reclock}\""
76 echo "Unset and test the recovery lock on all nodes..."
77 try_command_on_node -pq all $CTDB setreclock
79 try_command_on_node -v -q all $CTDB getreclock
80 t=$(sort -u <<<"$out")
81 if [ "$t" = "No reclock file used." ] ; then
82 echo "GOOD: Recovery lock unset on all nodes"
84 echo "BAD: Recovery lock not unset on all nodes"
90 echo "Current generation is ${generation}"
92 alt="${orig_reclock}.test"
94 echo "Set alternative recovery lock (${alt}) and test on all nodes..."
95 try_command_on_node -pq all $CTDB setreclock "$alt"
97 try_command_on_node -v -q all $CTDB getreclock
98 t=$(echo "$out" | sed -e 's@^Reclock file:@@' | sort -u)
99 if [ "$t" = "$alt" ] ; then
100 echo "GOOD: Recovery lock set on all nodes"
102 echo "BAD: Recovery lock not set on all nodes"
103 try_command_on_node -vf all rm -v "$alt" || true
107 # Setting or updating the recovery lock file must cause a recovery
108 echo "Current generation is ${generation}"
111 echo "Restore and test the recovery lock on all nodes..."
112 try_command_on_node -pq all $CTDB setreclock "$orig_reclock"
114 try_command_on_node -v all rm -vf "$alt"
115 try_command_on_node -v -q all $CTDB getreclock
116 t=$(echo "$out" | sed -e 's@^Reclock file:@@' | sort -u)
117 if [ "$t" = "$orig_reclock" ] ; then
118 echo "GOOD: Recovery lock restored on all nodes"
120 echo "BAD: Recovery lock not restored on all nodes"
124 echo "Current generation is ${generation}"