diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:20:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:20:00 +0000 |
commit | 8daa83a594a2e98f39d764422bfbdbc62c9efd44 (patch) | |
tree | 4099e8021376c7d8c05bdf8503093d80e9c7bad0 /ctdb/tests/UNIT/onnode | |
parent | Initial commit. (diff) | |
download | samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.tar.xz samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.zip |
Adding upstream version 2:4.20.0+dfsg.upstream/2%4.20.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ctdb/tests/UNIT/onnode')
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0001.sh | 24 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0002.sh | 16 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0003.sh | 16 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0004.sh | 16 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0005.sh | 13 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0006.sh | 15 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0010.sh | 13 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0011.sh | 13 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0070.sh | 32 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0071.sh | 29 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0072.sh | 29 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/0075.sh | 29 | ||||
-rw-r--r-- | ctdb/tests/UNIT/onnode/etc-ctdb/nodes | 4 | ||||
-rw-r--r-- | ctdb/tests/UNIT/onnode/scripts/local.sh | 64 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/stubs/ctdb | 19 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/onnode/stubs/ssh | 2 |
16 files changed, 334 insertions, 0 deletions
diff --git a/ctdb/tests/UNIT/onnode/0001.sh b/ctdb/tests/UNIT/onnode/0001.sh new file mode 100755 index 0000000..2853374 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0001.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE all hostname" + +define_test "$cmd" "all nodes OK" + +required_result <<EOF + +>> NODE: 192.168.1.101 << +-n 192.168.1.101 hostname + +>> NODE: 192.168.1.102 << +-n 192.168.1.102 hostname + +>> NODE: 192.168.1.103 << +-n 192.168.1.103 hostname + +>> NODE: 192.168.1.104 << +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0002.sh b/ctdb/tests/UNIT/onnode/0002.sh new file mode 100755 index 0000000..c3c8c77 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0002.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE -q all hostname" + +define_test "$cmd" "all nodes OK" + +required_result <<EOF +-n 192.168.1.101 hostname +-n 192.168.1.102 hostname +-n 192.168.1.103 hostname +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0003.sh b/ctdb/tests/UNIT/onnode/0003.sh new file mode 100755 index 0000000..d79bca2 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0003.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE -p all hostname" + +define_test "$cmd" "all nodes OK" + +required_result <<EOF +[192.168.1.101] -n 192.168.1.101 hostname +[192.168.1.102] -n 192.168.1.102 hostname +[192.168.1.103] -n 192.168.1.103 hostname +[192.168.1.104] -n 192.168.1.104 hostname +EOF + +simple_test -s $cmd diff --git a/ctdb/tests/UNIT/onnode/0004.sh b/ctdb/tests/UNIT/onnode/0004.sh new file mode 100755 index 0000000..d0986b2 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0004.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE -pq all hostname" + +define_test "$cmd" "all nodes OK" + +required_result <<EOF +-n 192.168.1.101 hostname +-n 192.168.1.102 hostname +-n 192.168.1.103 hostname +-n 192.168.1.104 hostname +EOF + +simple_test -s $cmd diff --git a/ctdb/tests/UNIT/onnode/0005.sh b/ctdb/tests/UNIT/onnode/0005.sh new file mode 100755 index 0000000..0eccbb0 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0005.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE 3 hostname" + +define_test "$cmd" "all nodes OK" + +required_result <<EOF +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0006.sh b/ctdb/tests/UNIT/onnode/0006.sh new file mode 100755 index 0000000..b027850 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0006.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE -v 3 hostname" + +define_test "$cmd" "all nodes OK" + +required_result <<EOF + +>> NODE: 192.168.1.104 << +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0010.sh b/ctdb/tests/UNIT/onnode/0010.sh new file mode 100755 index 0000000..241cf58 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0010.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE 4 hostname" + +define_test "$cmd" "invalid pnn 4" + +required_result 1 <<EOF +onnode: "node 4" does not exist +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0011.sh b/ctdb/tests/UNIT/onnode/0011.sh new file mode 100755 index 0000000..4604533 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0011.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE 99 hostname" + +define_test "$cmd" "invalid pnn 99" + +required_result 1 <<EOF +onnode: "node 99" does not exist +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0070.sh b/ctdb/tests/UNIT/onnode/0070.sh new file mode 100755 index 0000000..d649f82 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0070.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE ok hostname" + +define_test "$cmd" "all nodes OK" + +ctdb_set_output <<EOF +|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode| +|0|192.168.1.101|0|0|0|0|0|0|0|Y| +|1|192.168.1.102|0|0|0|0|0|0|0|N| +|2|192.168.1.103|0|0|0|0|0|0|0|N| +|3|192.168.1.104|0|0|0|0|0|0|0|N| +EOF + +required_result <<EOF + +>> NODE: 192.168.1.101 << +-n 192.168.1.101 hostname + +>> NODE: 192.168.1.102 << +-n 192.168.1.102 hostname + +>> NODE: 192.168.1.103 << +-n 192.168.1.103 hostname + +>> NODE: 192.168.1.104 << +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0071.sh b/ctdb/tests/UNIT/onnode/0071.sh new file mode 100755 index 0000000..4f945ac --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0071.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE ok hostname" + +define_test "$cmd" "2nd node disconnected" + +ctdb_set_output <<EOF +|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode| +|0|192.168.1.101|0|0|0|0|0|0|0|Y| +|1|192.168.1.102|1|0|0|0|0|0|0|N| +|2|192.168.1.103|0|0|0|0|0|0|0|N| +|3|192.168.1.104|0|0|0|0|0|0|0|N| +EOF + +required_result <<EOF + +>> NODE: 192.168.1.101 << +-n 192.168.1.101 hostname + +>> NODE: 192.168.1.103 << +-n 192.168.1.103 hostname + +>> NODE: 192.168.1.104 << +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0072.sh b/ctdb/tests/UNIT/onnode/0072.sh new file mode 100755 index 0000000..51a4c46 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0072.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE ok hostname" + +define_test "$cmd" "2nd node disconnected, extra status columns" + +ctdb_set_output <<EOF +|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|X1|X2|X3|X4| +|0|192.168.1.101|0|0|0|0|0|0|0|0|0|0| +|1|192.168.1.102|1|0|0|0|0|0|0|0|0|0| +|2|192.168.1.103|0|0|0|0|0|0|0|0|0|0| +|3|192.168.1.104|0|0|0|0|0|0|0|0|0|0| +EOF + +required_result <<EOF + +>> NODE: 192.168.1.101 << +-n 192.168.1.101 hostname + +>> NODE: 192.168.1.103 << +-n 192.168.1.103 hostname + +>> NODE: 192.168.1.104 << +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/0075.sh b/ctdb/tests/UNIT/onnode/0075.sh new file mode 100755 index 0000000..92fe220 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/0075.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +cmd="$ONNODE con hostname" + +define_test "$cmd" "1st node disconnected" + +ctdb_set_output <<EOF +|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode| +|0|192.168.1.101|1|0|0|0|0|0|0|N| +|1|192.168.1.102|0|0|0|0|0|0|0|Y| +|2|192.168.1.103|0|0|0|0|0|0|0|N| +|3|192.168.1.104|0|0|0|0|0|0|0|N| +EOF + +required_result <<EOF + +>> NODE: 192.168.1.102 << +-n 192.168.1.102 hostname + +>> NODE: 192.168.1.103 << +-n 192.168.1.103 hostname + +>> NODE: 192.168.1.104 << +-n 192.168.1.104 hostname +EOF + +simple_test $cmd diff --git a/ctdb/tests/UNIT/onnode/etc-ctdb/nodes b/ctdb/tests/UNIT/onnode/etc-ctdb/nodes new file mode 100644 index 0000000..e2fe268 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/etc-ctdb/nodes @@ -0,0 +1,4 @@ +192.168.1.101 +192.168.1.102 +192.168.1.103 +192.168.1.104 diff --git a/ctdb/tests/UNIT/onnode/scripts/local.sh b/ctdb/tests/UNIT/onnode/scripts/local.sh new file mode 100644 index 0000000..5b830c8 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/scripts/local.sh @@ -0,0 +1,64 @@ +# Hey Emacs, this is a -*- shell-script -*- !!! :-) + +# Default to just "onnode". +: ${ONNODE:=onnode} + +# Augment PATH with relevant stubs/ directory +stubs_dir="${CTDB_TEST_SUITE_DIR}/stubs" +[ -d "${stubs_dir}" ] || die "Failed to locate stubs/ subdirectory" +PATH="${stubs_dir}:${PATH}" + +setup_ctdb_base "$CTDB_TEST_TMP_DIR" "etc-ctdb" \ + functions + +define_test () +{ + _f=$(basename "$0") + + echo "$_f $1 - $2" +} + +# Set output for ctdb command. Option 1st argument is return code. +ctdb_set_output () +{ + _out="${CTDB_TEST_TMP_DIR}/ctdb.out" + cat >"$_out" + + _rc="${CTDB_TEST_TMP_DIR}/ctdb.rc" + echo "${1:-0}" >"$_rc" + + test_cleanup "rm -f $_out $_rc" +} + +extra_footer () +{ + cat <<EOF +-------------------------------------------------- +CTDB_BASE="$CTDB_BASE" +ctdb client is $(which ctdb) +-------------------------------------------------- +EOF +} + +simple_test () +{ + _sort="cat" + if [ "$1" = "-s" ] ; then + shift + _sort="sort" + fi + + if $CTDB_TEST_COMMAND_TRACE ; then + _onnode=$(which "$1") ; shift + _out=$(bash -x "$_onnode" "$@" 2>&1) + else + _out=$("$@" 2>&1) + fi + _rc=$? + _out=$(echo "$_out" | $_sort ) + + # Get the return code back into $? + (exit $_rc) + + result_check +} diff --git a/ctdb/tests/UNIT/onnode/stubs/ctdb b/ctdb/tests/UNIT/onnode/stubs/ctdb new file mode 100755 index 0000000..cca34c5 --- /dev/null +++ b/ctdb/tests/UNIT/onnode/stubs/ctdb @@ -0,0 +1,19 @@ +#!/bin/sh + +# Fake ctdb client for onnode tests. + +out="${CTDB_TEST_TMP_DIR}/ctdb.out" +if [ -r "$out" ] ; then + cat "$out" + + rc="${CTDB_TEST_TMP_DIR}/ctdb.rc" + if [ -r "$rc" ] ; then + exit $(cat "$rc") + fi + + exit 0 +fi + +echo "fake ctdb: no implementation for \"$*\"" + +exit 1 diff --git a/ctdb/tests/UNIT/onnode/stubs/ssh b/ctdb/tests/UNIT/onnode/stubs/ssh new file mode 100755 index 0000000..7be778f --- /dev/null +++ b/ctdb/tests/UNIT/onnode/stubs/ssh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "$*" |