diff --git a/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh b/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh index f27d83760e1..53b8dbc485b 100644 --- a/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh +++ b/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh @@ -1,10 +1,28 @@ setup() { + CTDB_STATD_CALLOUT_SHARED_STORAGE="$1" + setup_public_addresses ctdb_set_pnn setup_date "1234567890" export FAKE_NFS_HOSTNAME="cluster1" + + case "$CTDB_STATD_CALLOUT_SHARED_STORAGE" in + "" | persistent_db) + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db:ctdb.tdb" + ;; + shared_dir) + export CTDB_NFS_SHARED_STATE_DIR="/clusterfs" + ;; + esac + + export CTDB_STATD_CALLOUT_SHARED_STORAGE + statd_callout_mode="${CTDB_STATD_CALLOUT_SHARED_STORAGE%%:*}" + statd_callout_location="${CTDB_STATD_CALLOUT_SHARED_STORAGE#*:}" + if [ "$statd_callout_location" = "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + statd_callout_location="" + fi } ctdb_catdb_format_pairs() @@ -44,10 +62,53 @@ EOF done | ctdb_catdb_format_pairs | { ok - simple_test_command ctdb catdb ctdb.tdb + simple_test_command ctdb catdb "$statd_callout_location" } || exit $? } +check_shared_dir_statd_state() +{ + ctdb_get_my_public_addresses | + while read -r _ _sip _; do + for _cip; do + echo "statd-state@${_sip}@${_cip}" + done + done | + sort | { + ok + _dir="${CTDB_TEST_TMP_DIR}${statd_callout_location}" + mkdir -p "$_dir" + (cd "$_dir" && simple_test_command ls) + } || exit $? +} + +check_shared_storage_statd_state() +{ + case "$statd_callout_mode" in + persistent_db) + if [ -z "$statd_callout_location" ]; then + statd_callout_location="ctdb.tdb" + fi + check_ctdb_tdb_statd_state "$@" + ;; + shared_dir) + if [ -z "$statd_callout_location" ]; then + statd_callout_location="statd" + fi + case "$statd_callout_location" in + /*) + : + ;; + *) + _t="$CTDB_NFS_SHARED_STATE_DIR" + statd_callout_location="${_t}/${statd_callout_location}" + ;; + esac + check_shared_dir_statd_state "$@" + ;; + esac +} + check_statd_callout_smnotify() { # The state here doesn't really matter because the date stub diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh index 07421620d14..475750041c5 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh @@ -2,13 +2,18 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "single add-client" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - single add-client" + +setup "$mode" ok_null simple_test_event "startup" simple_test_event "add-client" "192.168.123.45" simple_test_event "update" -check_ctdb_tdb_statd_state "192.168.123.45" +check_shared_storage_statd_state "192.168.123.45" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh index 6785d844d54..7e5d7b23621 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh @@ -2,9 +2,14 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "2 x add-client, update" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - 2 x add-client, update" + +setup "$mode" ok_null simple_test_event "startup" @@ -12,4 +17,4 @@ simple_test_event "add-client" "192.168.123.45" simple_test_event "add-client" "192.168.123.46" simple_test_event "update" -check_ctdb_tdb_statd_state "192.168.123.45" "192.168.123.46" +check_shared_storage_statd_state "192.168.123.45" "192.168.123.46" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh index 796d3b6aab4..2522c956990 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh @@ -2,9 +2,14 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "add-client, update, del-client, update" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - add-client, update, del-client, update" + +setup "$mode" ok_null simple_test_event "startup" @@ -14,4 +19,4 @@ simple_test_event "update" simple_test_event "del-client" "192.168.123.45" simple_test_event "update" -check_ctdb_tdb_statd_state +check_shared_storage_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh index 001da78a780..1b1bc05490a 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh @@ -2,17 +2,22 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "single add-client, notify" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - single add-client, notify" + +setup "$mode" ok_null simple_test_event "startup" simple_test_event "add-client" "192.168.123.45" simple_test_event "update" -check_ctdb_tdb_statd_state "192.168.123.45" +check_shared_storage_statd_state "192.168.123.45" check_statd_callout_smnotify "192.168.123.45" -check_ctdb_tdb_statd_state +check_shared_storage_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh index e9555da152d..5a9274b1402 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh @@ -2,9 +2,14 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "2 x add-client to different nodes, notify on 1" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - 2 x add-client to different nodes, notify on 1" + +setup "$mode" ok_null simple_test_event "startup" @@ -24,4 +29,4 @@ check_statd_callout_smnotify "192.168.123.45" ctdb_set_pnn 1 -check_ctdb_tdb_statd_state "192.168.123.46" +check_shared_storage_statd_state "192.168.123.46" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh index 96c4cb517e5..1721a5c50b3 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh @@ -2,9 +2,14 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "2 x add-client to different nodes, notify on both" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - 2 x add-client to different nodes, notify on both" + +setup "$mode" ok_null simple_test_event "startup" @@ -26,4 +31,4 @@ ctdb_set_pnn 1 check_statd_callout_smnotify "192.168.123.46" -check_ctdb_tdb_statd_state +check_shared_storage_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh index ceeb248ef6c..071c583ebed 100755 --- a/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh @@ -2,9 +2,14 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "add-client, del-client, update" +if [ -z "$CTDB_STATD_CALLOUT_SHARED_STORAGE" ]; then + CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db" +fi +mode="$CTDB_STATD_CALLOUT_SHARED_STORAGE" -setup +define_test "${mode} - add-client, del-client, update" + +setup "$mode" ok_null simple_test_event "startup" @@ -12,4 +17,4 @@ simple_test_event "add-client" "192.168.123.45" simple_test_event "del-client" "192.168.123.45" simple_test_event "update" -check_ctdb_tdb_statd_state +check_shared_storage_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.101.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.101.sh new file mode 100755 index 00000000000..b57bd953f1b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.101.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.001.sh" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.102.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.102.sh new file mode 100755 index 00000000000..0827669058b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.102.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.002.sh" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.103.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.103.sh new file mode 100755 index 00000000000..07fb082e571 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.103.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.003.sh" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.104.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.104.sh new file mode 100755 index 00000000000..836a9381f8c --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.104.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.004.sh" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.105.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.105.sh new file mode 100755 index 00000000000..436f2d5cc22 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.105.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.005.sh" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.106.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.106.sh new file mode 100755 index 00000000000..5e225f9e160 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.106.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.006.sh" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.107.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.107.sh new file mode 100755 index 00000000000..1a761c61b8c --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.107.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +CTDB_STATD_CALLOUT_SHARED_STORAGE="shared_dir" + +_dir=$(dirname "$0") +. "${_dir}/statd-callout.007.sh"