From 4f5791ebd03eaec1c7da0865a383175b05102712 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 19:47:29 +0200 Subject: Adding upstream version 2:4.17.12+dfsg. Signed-off-by: Daniel Baumann --- ctdb/tests/UNIT/cunit/cluster_mutex_001.sh | 66 +++++ ctdb/tests/UNIT/cunit/cluster_mutex_002.sh | 132 ++++++++++ ctdb/tests/UNIT/cunit/cluster_mutex_003.sh | 75 ++++++ ctdb/tests/UNIT/cunit/cmdline_test_001.sh | 98 +++++++ ctdb/tests/UNIT/cunit/comm_test_001.sh | 13 + ctdb/tests/UNIT/cunit/comm_test_002.sh | 24 ++ ctdb/tests/UNIT/cunit/conf_test_001.sh | 196 ++++++++++++++ ctdb/tests/UNIT/cunit/config_test_001.sh | 115 +++++++++ ctdb/tests/UNIT/cunit/config_test_002.sh | 65 +++++ ctdb/tests/UNIT/cunit/config_test_003.sh | 52 ++++ ctdb/tests/UNIT/cunit/config_test_004.sh | 144 +++++++++++ ctdb/tests/UNIT/cunit/config_test_005.sh | 97 +++++++ ctdb/tests/UNIT/cunit/config_test_006.sh | 56 ++++ ctdb/tests/UNIT/cunit/config_test_007.sh | 24 ++ ctdb/tests/UNIT/cunit/ctdb_io_test_001.sh | 10 + ctdb/tests/UNIT/cunit/db_hash_test_001.sh | 7 + ctdb/tests/UNIT/cunit/event_protocol_test_001.sh | 7 + ctdb/tests/UNIT/cunit/event_script_test_001.sh | 127 +++++++++ ctdb/tests/UNIT/cunit/hash_count_test_001.sh | 7 + ctdb/tests/UNIT/cunit/line_test_001.sh | 90 +++++++ ctdb/tests/UNIT/cunit/path_tests_001.sh | 62 +++++ ctdb/tests/UNIT/cunit/pidfile_test_001.sh | 8 + ctdb/tests/UNIT/cunit/pkt_read_001.sh | 7 + ctdb/tests/UNIT/cunit/pkt_write_001.sh | 7 + ctdb/tests/UNIT/cunit/porting_tests_001.sh | 15 ++ ctdb/tests/UNIT/cunit/protocol_test_001.sh | 7 + ctdb/tests/UNIT/cunit/protocol_test_002.sh | 7 + ctdb/tests/UNIT/cunit/protocol_test_012.sh | 7 + ctdb/tests/UNIT/cunit/protocol_test_101.sh | 7 + ctdb/tests/UNIT/cunit/protocol_test_111.sh | 7 + ctdb/tests/UNIT/cunit/protocol_test_201.sh | 6 + ctdb/tests/UNIT/cunit/rb_test_001.sh | 31 +++ ctdb/tests/UNIT/cunit/reqid_test_001.sh | 13 + ctdb/tests/UNIT/cunit/run_event_001.sh | 137 ++++++++++ ctdb/tests/UNIT/cunit/run_proc_001.sh | 159 ++++++++++++ ctdb/tests/UNIT/cunit/sock_daemon_test_001.sh | 135 ++++++++++ ctdb/tests/UNIT/cunit/sock_io_test_001.sh | 9 + ctdb/tests/UNIT/cunit/srvid_test_001.sh | 7 + ctdb/tests/UNIT/cunit/system_socket_test_001.sh | 6 + ctdb/tests/UNIT/cunit/system_socket_test_002.sh | 68 +++++ ctdb/tests/UNIT/cunit/system_socket_test_003.sh | 42 +++ ctdb/tests/UNIT/cunit/tmon_test_001.sh | 195 ++++++++++++++ ctdb/tests/UNIT/cunit/tmon_test_002.sh | 142 +++++++++++ ctdb/tests/UNIT/cunit/tunable_test_001.sh | 312 +++++++++++++++++++++++ 44 files changed, 2801 insertions(+) create mode 100755 ctdb/tests/UNIT/cunit/cluster_mutex_001.sh create mode 100755 ctdb/tests/UNIT/cunit/cluster_mutex_002.sh create mode 100755 ctdb/tests/UNIT/cunit/cluster_mutex_003.sh create mode 100755 ctdb/tests/UNIT/cunit/cmdline_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/comm_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/comm_test_002.sh create mode 100755 ctdb/tests/UNIT/cunit/conf_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_002.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_003.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_004.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_005.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_006.sh create mode 100755 ctdb/tests/UNIT/cunit/config_test_007.sh create mode 100755 ctdb/tests/UNIT/cunit/ctdb_io_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/db_hash_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/event_protocol_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/event_script_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/hash_count_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/line_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/path_tests_001.sh create mode 100755 ctdb/tests/UNIT/cunit/pidfile_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/pkt_read_001.sh create mode 100755 ctdb/tests/UNIT/cunit/pkt_write_001.sh create mode 100755 ctdb/tests/UNIT/cunit/porting_tests_001.sh create mode 100755 ctdb/tests/UNIT/cunit/protocol_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/protocol_test_002.sh create mode 100755 ctdb/tests/UNIT/cunit/protocol_test_012.sh create mode 100755 ctdb/tests/UNIT/cunit/protocol_test_101.sh create mode 100755 ctdb/tests/UNIT/cunit/protocol_test_111.sh create mode 100755 ctdb/tests/UNIT/cunit/protocol_test_201.sh create mode 100755 ctdb/tests/UNIT/cunit/rb_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/reqid_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/run_event_001.sh create mode 100755 ctdb/tests/UNIT/cunit/run_proc_001.sh create mode 100755 ctdb/tests/UNIT/cunit/sock_daemon_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/sock_io_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/srvid_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/system_socket_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/system_socket_test_002.sh create mode 100755 ctdb/tests/UNIT/cunit/system_socket_test_003.sh create mode 100755 ctdb/tests/UNIT/cunit/tmon_test_001.sh create mode 100755 ctdb/tests/UNIT/cunit/tmon_test_002.sh create mode 100755 ctdb/tests/UNIT/cunit/tunable_test_001.sh (limited to 'ctdb/tests/UNIT/cunit') diff --git a/ctdb/tests/UNIT/cunit/cluster_mutex_001.sh b/ctdb/tests/UNIT/cunit/cluster_mutex_001.sh new file mode 100755 index 0000000..7976143 --- /dev/null +++ b/ctdb/tests/UNIT/cunit/cluster_mutex_001.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +# This tests the fcntl helper, configured via a lock file + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +t="${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb_mutex_fcntl_helper" +export CTDB_CLUSTER_MUTEX_HELPER="$t" + +lockfile="${CTDB_TEST_TMP_DIR}/cluster_mutex.lockfile" +trap 'rm -f ${lockfile}' 0 + +test_case "No contention: lock, unlock" +ok <] [] + +Help Options: + -h, --help Show this help message + +Options: + -c, --count=INT Option help of length thirty. + -v, --value=Value help of length 23 Short description + +Commands: + A really really long command This is a really long help message + short command short msg for short command +Usage: test4 [-h] [-h|--help] [-c|--count=INT] + [-v|--value=Value help of length 23] [] + + short command short msg for short command +EOF +unit_test cmdline_test 4 + +ok <] [] + +Help Options: + -h, --help Show this help message + +Action Commands: + action one action one help + action two action two help +Usage: test5 [] [] + +Help Options: + -h, --help Show this help message + +Action Commands: + action one action one help + action two action two help +Usage: test5 [] [] + +Help Options: + -h, --help Show this help message + +Action Commands: + action one action one help + action two action two help +EOF +unit_test cmdline_test 5 + +ok <] [] + +Help Options: + -h, --help Show this help message + +Basic Commands: + cmd1 command one help + cmd2 command two help + +Advanced Commands: + cmd3 command three help + cmd4 command four help + +Ultimate Commands: + cmd5 command five help + cmd6 command six help + +one +three +six +EOF +unit_test cmdline_test 7 diff --git a/ctdb/tests/UNIT/cunit/comm_test_001.sh b/ctdb/tests/UNIT/cunit/comm_test_001.sh new file mode 100755 index 0000000..ac09f5c --- /dev/null +++ b/ctdb/tests/UNIT/cunit/comm_test_001.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + + +ok_null +unit_test comm_test 1 + +ok_null +unit_test comm_test 2 + +ok "100 2048 500 4096 1024 8192 200 16384 300 32768 400 65536 1048576 " +unit_test comm_test 3 diff --git a/ctdb/tests/UNIT/cunit/comm_test_002.sh b/ctdb/tests/UNIT/cunit/comm_test_002.sh new file mode 100755 index 0000000..a2fbf51 --- /dev/null +++ b/ctdb/tests/UNIT/cunit/comm_test_002.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +socket="${CTDB_TEST_TMP_DIR}/test_sock.$$" +num_clients=10 + +remove_socket () +{ + rm -f "$socket" +} + +test_cleanup remove_socket + +ok_null + +unit_test comm_server_test "$socket" $num_clients & +pid=$! + +for i in $(seq 1 $num_clients) ; do + unit_test comm_client_test "$socket" +done + +wait $pid diff --git a/ctdb/tests/UNIT/cunit/conf_test_001.sh b/ctdb/tests/UNIT/cunit/conf_test_001.sh new file mode 100755 index 0000000..188964e --- /dev/null +++ b/ctdb/tests/UNIT/cunit/conf_test_001.sh @@ -0,0 +1,196 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +conffile="${CTDB_TEST_TMP_DIR}/config.$$" + +remove_files () +{ + rm -f "$conffile" +} + +test_cleanup remove_files + +ok_null +unit_test conf_test 1 + +ok < "$conffile" < "$conffile" < "$conffile" < "key1" +[section1] + # key1 = value1 + # key2 = 10 + key3 = false # temporary +EOF +unit_test conf_test 9 "$conffile" + +cat > "$conffile" < "key3" +[section1] + # key1 = value1 + # key2 = 10 + key3 = false # temporary +EOF +unit_test conf_test 9 "$conffile" + +cat > "$conffile" < "$conffile" < "$conffile" < "$conffile" < "foo" +[section1] + # key1 = value1 + # key2 = 10 + key3 = false # temporary +EOF +unit_test conf_test 10 "$conffile" + +cat > "$conffile" < "$conffile" < "${conffile}.reload" < "$conffile" < "$conffile" < "$conffile" < "key" not defined +EOF +unit_test ctdb-config get section key + +# Confirm that an unknown key doesn't stop the rest of the file from +# loading +cat > "$conffile" < "unknown key" +Failed to load config file $conffile +EOF +unit_test ctdb-config validate + +ok < "$conffile" < "$conffile" < "$conffile" < "$conffile" < "$conffile" < "$conffile" < "$conffile" < "$conffile" < transport = invalid +conf: validation for option "transport" failed +Failed to load config file $conffile +EOF +unit_test ctdb-config validate + +cat > "$conffile" < "$conffile" < "$conffile" < node address = 10.1.2.3:123 +conf: validation for option "node address" failed +Failed to load config file $conffile +EOF +unit_test ctdb-config validate + +cat > "$conffile" < "$conffile" < recovery lock is deprecated +EOF +unit_test ctdb-config -d WARNING validate + +cat > "$conffile" < "$conffile" < leader timeout = 0 +conf: validation for option "leader timeout" failed +Failed to load config file $conffile +EOF +unit_test ctdb-config validate + +cat > "$conffile" < "leader timeout" = "-5" +Failed to load config file $conffile +EOF +unit_test ctdb-config validate + +cat > "$conffile" < "$conffile" < "$conffile" < "$conffile" < "$conffile" < script log level = INVALID +conf: validation for option "script log level" failed +Failed to load config file ${conffile} +EOF +unit_test ctdb-config validate diff --git a/ctdb/tests/UNIT/cunit/config_test_007.sh b/ctdb/tests/UNIT/cunit/config_test_007.sh new file mode 100755 index 0000000..8804448 --- /dev/null +++ b/ctdb/tests/UNIT/cunit/config_test_007.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +PATH="$PATH:$CTDB_SCRIPTS_HELPER_BINDIR" + +setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc" + +conffile="${CTDB_BASE}/ctdb.conf" + +remove_files () +{ + rm -f "$conffile" +} + +test_cleanup remove_files + +cat > "$conffile" < "$tfile" + +ok_null +unit_test line_test "$tfile" + +printf "\0" > "$tfile" + +required_result 1 < "$tfile" + +ok_null +unit_test line_test "$tfile" + +cat < "$tfile" +hello +world +EOF + +required_result 2 << EOF +hello +world +EOF +unit_test line_test "$tfile" + +required_result 2 << EOF +hello +world +EOF +unit_test line_test "$tfile" + +cat < "$tfile" +This is a really long long line full of random words and hopefully it will be read properly by the line test program and identified as a single line +EOF + +required_result 1 < "$tfile" +line number one +line number two +line number one +line number two +line number one +EOF + +required_result 5 < "$tfile" +this is line number one +this is line number two +this is line number three +this is line number four +this is line number five +EOF + +required_result 5 < "$scriptdir/prog" < "$scriptdir/11.foo.script" < "$scriptdir/22.bar.script" < "$scriptdir/22.bar.script" < "$prog" < "$prog" < "$prog" <"$output" 2>&1 +echo hello +EOF + +ok < "$prog" < "$prog" < "$prog" < "$prog" < "$pidfile" +sleep 10 +EOF + +ok < "$prog" < "$output" <"$tfile" +chmod a-r "$tfile" +uid=$(id -u) +# root can read unreadable files +if [ "$uid" = 0 ]; then + ok_tunable_defaults +else + required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" +required_error EINVAL <"$tfile" <"$tfile" <"$tfile" +ok_tunable_defaults +unit_test tunable_test "$tfile" + +test_case "OK, comments and blanks only" +cat >"$tfile" <"$tfile" <"$tfile" <"$tfile" <"$tfile" <"$tfile" <"$tfile" <"$tfile" <