1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
3 # Augment PATH with stubs/ directory.
5 if "$TEST_VERBOSE" ; then
6 debug
() { echo "$@" ; }
11 .
"${TEST_SCRIPTS_DIR}/script_install_paths.sh"
13 PATH
="$PATH:$CTDB_SCRIPTS_TOOLS_HELPER_DIR"
15 ctdbd_socket
="${TEST_VAR_DIR}/ctdbd.socket.$$"
16 ctdbd_pidfile
="${TEST_VAR_DIR}/ctdbd.pid.$$"
17 ctdbd_dbdir
="${TEST_VAR_DIR}/ctdbd.db.$$"
21 _f
=$
(basename "$0" ".sh")
23 printf "%-28s - %s\n" "$_f" "$1"
25 if [ -z "$FAKE_CTDBD_DEBUGLEVEL" ] ; then
26 FAKE_CTDBD_DEBUGLEVEL
="ERR"
28 if [ -z "$HELPER_DEBUGLEVEL" ] ; then
29 HELPER_DEBUGLEVEL
="NOTICE"
31 if [ -z "$CTDB_DEBUGLEVEL" ] ; then
38 debug
"Cleaning up fake ctdbd"
40 pid
=$
(cat "$ctdbd_pidfile" 2>/dev
/null ||
echo)
41 if [ -n "$pid" ] ; then
43 rm -f "$ctdbd_pidfile"
51 debug
"Setting up fake ctdbd"
53 mkdir
-p "$ctdbd_dbdir"
54 $VALGRIND fake_ctdbd
-d "$FAKE_CTDBD_DEBUGLEVEL" \
55 -s "$ctdbd_socket" -p "$ctdbd_pidfile" \
57 export CTDB_SOCKET
="$ctdbd_socket"
58 # This current translates to a 6 second timeout for the
60 ctdb setvar TakeoverTimeout
2
61 test_cleanup cleanup_ctdbd
69 # Render non-printable characters. The helper prints the status as
70 # binary, so render it for easy comparison.
73 sed -e 's|ctdb-takeover\[[0-9]*\]: ||'
78 echo Running
: ctdb
-d "$CTDB_DEBUGLEVEL" "$@"
79 ctdb
-d "$CTDB_DEBUGLEVEL" "$@"
84 unit_test ctdb
-d "$CTDB_DEBUGLEVEL" ip all ||
exit $?
87 takeover_helper_out
="${TEST_VAR_DIR}/takover_helper.out"
89 takeover_helper_format_outfd
()
91 od -A n
-t d4
"$takeover_helper_out" |
sed -e 's|^[[:space:]]*||'
94 test_takeover_helper
()
97 export CTDB_DEBUGLEVEL
="$HELPER_DEBUGLEVEL"
98 export CTDB_LOGGING
="file:"
99 unit_test ctdb_takeover_helper
3 "$ctdbd_socket" "$@" \
100 3>"$takeover_helper_out"
103 case "$required_rc" in
105 *) _t
="$required_rc" ;;
109 unit_test_notrace takeover_helper_format_outfd
111 rm "$takeover_helper_out"
112 [ $?
-eq 0 ] ||
exit $?