1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
3 # Augment PATH with stubs/ directory.
5 if "$TEST_VERBOSE" ; then
6 debug () { echo "$@" ; }
11 ctdbd_socket="${TEST_VAR_DIR}/ctdbd.socket.$$"
12 ctdbd_pidfile="${TEST_VAR_DIR}/ctdbd.pid.$$"
16 _f=$(basename "$0" ".sh")
21 _cmd="${_cmd%.*}" # Strip test number
22 export CTDB="ctdb --socket $ctdbd_socket"
23 export CTDB_DEBUGLEVEL=3
27 die "Unknown pattern for testcase \"$_f\""
30 printf "%-28s - %s\n" "$_f" "$1"
35 debug "Cleaning up fake ctdbd"
37 pid=$(cat "$ctdbd_pidfile" 2>/dev/null || echo)
38 if [ -n "$pid" ] ; then
40 rm -f "$ctdbd_pidfile"
47 debug "Setting up fake ctdbd"
49 cat | fake_ctdbd -s "$ctdbd_socket" -p "$ctdbd_pidfile"
50 #test_cleanup cleanup_ctdbd
55 debug "Setting up NAT gateway"
57 # Use in-tree binaries if running against local daemons.
58 # Otherwise CTDB need to be installed on all nodes.
59 if [ -n "$ctdb_dir" -a -d "${ctdb_dir}/bin" ] ; then
60 if [ -z "$CTDB_NATGW_HELPER" ] ; then
61 export CTDB_NATGW_HELPER="${ctdb_dir}/tools/ctdb_natgw"
63 # Only want to find functions file, so this is OK
64 export CTDB_BASE="${ctdb_dir}/config"
67 natgw_config_dir="${TEST_VAR_DIR}/natgw_config"
68 mkdir -p "$natgw_config_dir"
70 # These will accumulate, 1 per test... but will be cleaned up
72 export CTDB_NATGW_NODES=$(mktemp --tmpdir="$natgw_config_dir")
74 cat >"$CTDB_NATGW_NODES"
79 debug "Setting up LVS"
81 # Use in-tree binaries if running against local daemons.
82 # Otherwise CTDB need to be installed on all nodes.
83 if [ -n "$ctdb_dir" -a -d "${ctdb_dir}/bin" ] ; then
84 if [ -z "$CTDB_LVS_HELPER" ] ; then
85 export CTDB_LVS_HELPER="${ctdb_dir}/tools/ctdb_lvs"
87 # Only want to find functions file, so this is OK
88 export CTDB_BASE="${ctdb_dir}/config"
91 lvs_config_dir="${TEST_VAR_DIR}/lvs_config"
92 mkdir -p "$lvs_config_dir"
94 # These will accumulate, 1 per test... but will be cleaned up
96 export CTDB_LVS_NODES=$(mktemp --tmpdir="$lvs_config_dir")
98 cat >"$CTDB_LVS_NODES"
105 _v="CTDB_NODES${_pnn:+_}${_pnn}"
106 debug "Setting up ${_v}"
108 # These will accumulate, 1 per test... but will be cleaned up at
110 eval export "${_v}"=$(mktemp --tmpdir="$TEST_VAR_DIR")
115 # You can't be too careful about what might be in the
116 # environment... so clean up when setting the default variable.
117 if [ -z "$_pnn" ] ; then
118 _n=$(wc -l "$CTDB_NODES" | awk '{ print $1 }')
119 for _i in $(seq 0 $_n) ; do
120 eval unset "CTDB_NODES_${_i}"
128 (unit_test $CTDB -d $CTDB_DEBUGLEVEL $test_args "$@")
131 [ $status -eq 0 ] || exit $status