The branch, master has been updated via 84f544b55f2 ctdb-client: Fix some typos in debug messages via fc7f3b99aca ctdb-scripts: Drop bit-rotted shellcheck directive via 80cbebce712 ctdb-scripts: Silence shellcheck warning SC2166 via 597039daeb8 ctdb-utils: CID 1273087 - Resource leak via 32b5ceb3193 ctdb-tools: Stop deleted nodes from influencing ctdb nodestatus exit code via 2b37d99a5fb ctdb-tests: Put the summary file inside $TEST_VAR_DIR via 7a5a4a4494d ctdb-tests: Drop run_tests -d option via 2730e483607 ctdb-tests: Simplify setup_ctdb() via 8443798846d ctdb-tests: Invert some logic so it makes sense via 8038f4f64f4 ctdb-tests: Avoid shellcheck warnings via 497ae563a0b ctdb-tests: Fix zero event scripts test so it tests something via 429502186a7 ctdb-tests: Drop unused code from onnode unit test ctdb stub via bb040f27985 ctdb-tests: Only set TEST_SUBDIR when needed via 284bbca7c73 ctdb-tests: Move NFS test functions to complex local script via 2c6b098c722 ctdb-tests: Don't run setup_ctdb_base() for real cluster via 8aed06ce8c8 ctdb-tests: Use db_ctdb_cattdb_count_records() via 68684377c69 ctdb-tests: Use ctdb_get_all_pnns() via 522a8480fa5 ctdb-tests: Drop reference to unused ctdb_eventd test directory from d51bb3137fa whitespace: Conform to coding convention
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 84f544b55f235e2f08596bf4b7854460af008f88 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Sep 4 14:14:22 2019 +1000 ctdb-client: Fix some typos in debug messages tdb_sore -> tdb_store SCHDULE_FOR_DELETION -> SCHEDULE_FOR_DELETION Switch to modern debug macros while touching the lines. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Tue Sep 17 05:52:15 UTC 2019 on sn-devel-184 commit fc7f3b99acad0a1c5ebeb2bc3c0753ec7b31bb49 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Sep 3 15:24:52 2019 +1000 ctdb-scripts: Drop bit-rotted shellcheck directive The code has changed so this is no longer needed. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 80cbebce7123f934562d74e5e29dae3719e9cc37 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 2 14:58:22 2019 +1000 ctdb-scripts: Silence shellcheck warning SC2166 This covers the following: SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. POSIX agrees that -a and -o should not be used: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html Fixing these doesn't cause much churn. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 597039daeb88f6d97f71ecaaa55efd7e091638ea Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 3 20:40:44 2019 +1000 ctdb-utils: CID 1273087 - Resource leak Ensure that p is not leaked. This is a test program and the program exits anyway. No need to backport. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 32b5ceb31936ec5447362236c1809db003561d29 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 13 21:42:15 2019 +1000 ctdb-tools: Stop deleted nodes from influencing ctdb nodestatus exit code Deleted nodes should simply be ignored. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14129 RN: Stop deleted nodes from influencing ctdb nodestatus exit code Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 2b37d99a5fbb08954dc4c0ff20867e9fd9dd5712 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Sep 4 15:04:05 2019 +1000 ctdb-tests: Put the summary file inside $TEST_VAR_DIR This means less random files dropped in /tmp or similar. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 7a5a4a4494d5fd2514651e06c2206007b8422449 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Sep 4 14:59:22 2019 +1000 ctdb-tests: Drop run_tests -d option The usage message says it is dodgy and some test suites may not support it. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 2730e48360750d4fbfd66ea76a2b0f002acfcab9 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Sep 3 19:12:45 2019 +1000 ctdb-tests: Simplify setup_ctdb() There is no point inventing a whole new set of options here. Continue to locally implement the --no-event-scripts option. This must be first, though in practice only one option is ever passed to setup_ctdb() from ctdb_test_init(). Simply pass all other options through to "local_daemons.sh setup". This has the side effect of causing failure when an invalid option is passed. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 8443798846d3e6f67eeb651f98af24272a8a4b5c Author: Martin Schwenke <mar...@meltin.net> Date: Tue Sep 3 17:54:29 2019 +1000 ctdb-tests: Invert some logic so it makes sense The test should be outside the loop. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 8038f4f64f4f6a77346837c1877e352be2632cd0 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Sep 6 09:01:36 2019 +1000 ctdb-tests: Avoid shellcheck warnings SC2086 Double quote to prevent globbing and word splitting This one doesn't need the double quotes if it is contained within the preceding variable expansion. SC2181 Check exit code directly with e.g. 'if mycmd;', not indirectly with $? SC2004 $/${} is unnecessary on arithmetic variables These are straightforward. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 497ae563a0b3e45794c22acb67ccde060d34f371 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Sep 3 17:40:59 2019 +1000 ctdb-tests: Fix zero event scripts test so it tests something Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 429502186a70f4220c8597d68a3306a073a33c4c Author: Martin Schwenke <mar...@meltin.net> Date: Fri Sep 6 20:03:36 2019 +1000 ctdb-tests: Drop unused code from onnode unit test ctdb stub Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit bb040f27985245449771a68606f0da2440ba1e7c Author: Martin Schwenke <mar...@meltin.net> Date: Thu Sep 5 15:51:08 2019 +1000 ctdb-tests: Only set TEST_SUBDIR when needed This is only needed for setup_ctdb_base() so only set it when calling this function. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 284bbca7c730235dd2df9ec2acbfc5fa6de5be42 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Sep 5 16:15:54 2019 +1000 ctdb-tests: Move NFS test functions to complex local script Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 2c6b098c7220a3e6d78f6040c912fc22a02f6e46 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 9 16:58:06 2019 +1000 ctdb-tests: Don't run setup_ctdb_base() for real cluster This has not been needed for some time. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 8aed06ce8c802d75e7bacb289916c835164e7307 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 2 16:18:32 2019 +1000 ctdb-tests: Use db_ctdb_cattdb_count_records() Avoid reinventing the wheel. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 68684377c6970725a57ec6111cb165736468440f Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 16 19:08:11 2019 +1000 ctdb-tests: Use ctdb_get_all_pnns() The nested, arbitrary use of onnode can cause messages from ssh on stderr to appear in the node list: Getting list of nodes... Output of "onnode -pq all ctdb pnn | grep '^[0-9][0-9]*$'": Warning: Permanently added '10.0.0.72' (RSA) to the list of known hosts.^M Warning: Permanently added '10.0.0.75' (RSA) to the list of known hosts.^M Warning: Permanently added '10.0.0.73' (RSA) to the list of known hosts.^M Warning: Permanently added '10.0.0.74' (RSA) to the list of known hosts.^M 1 0 3 2 Create/wipe test database rec_test.tdb Failed to execute "Permanently added '10.0.0.72' (RSA) to the list of known hosts.^M ctdb attach rec_test.tdb" on node(s) "Warning:" Invalid <nodespec> Avoid that by using an existing function that does not nest ssh uses. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 522a8480fa5e886d66a2efc8d49ac4e2ac6403d7 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 9 16:04:36 2019 +1000 ctdb-tests: Drop reference to unused ctdb_eventd test directory Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/client/client_db.c | 12 ++++---- ctdb/config/events/legacy/11.routing.script | 2 +- ctdb/config/events/legacy/13.per_ip_routing.script | 15 +++++----- ctdb/config/events/legacy/60.nfs.script | 4 +-- ctdb/config/functions | 2 -- ctdb/tests/complex/scripts/local.bash | 32 ++++++++++++++++++++++ ctdb/tests/local_daemons.sh | 18 ++++++------ ctdb/tests/onnode/stubs/ctdb | 14 ---------- ctdb/tests/run_tests.sh | 26 ++++++------------ ctdb/tests/scripts/integration.bash | 32 ---------------------- ctdb/tests/shellcheck/scripts/local.sh | 9 +----- ctdb/tests/simple/01_ctdb_reclock_command.sh | 2 +- ctdb/tests/simple/19_ip_takeover_noop.sh | 4 +-- ctdb/tests/simple/28_zero_eventscripts.sh | 2 +- ctdb/tests/simple/69_recovery_resurrect_deleted.sh | 13 +++++---- ctdb/tests/simple/scripts/local.bash | 7 +---- ctdb/tests/simple/scripts/local_daemons.bash | 29 ++++++++------------ ctdb/tools/ctdb.c | 8 +++++- ctdb/tools/ctdb_diagnostics | 2 +- ctdb/tools/onnode | 4 +-- ctdb/utils/ping_pong/ping_pong.c | 12 +++++--- ctdb/wscript | 1 - 22 files changed, 109 insertions(+), 141 deletions(-) Changeset truncated at 500 lines: diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index dfa8d970de5..a008f2ad63d 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -1540,9 +1540,9 @@ struct tevent_req *ctdb_delete_record_send(TALLOC_CTX *mem_ctx, ret = tdb_store(h->db->ltdb->tdb, h->key, rec, TDB_REPLACE); if (ret != 0) { - DEBUG(DEBUG_ERR, - ("fetch_lock delete: %s tdb_sore failed, %s\n", - h->db->db_name, tdb_errorstr(h->db->ltdb->tdb))); + D_ERR("fetch_lock delete: %s tdb_store failed, %s\n", + h->db->db_name, + tdb_errorstr(h->db->ltdb->tdb)); tevent_req_error(req, EIO); return tevent_req_post(req, ev); } @@ -1576,9 +1576,9 @@ static void ctdb_delete_record_done(struct tevent_req *subreq) status = ctdb_client_control_recv(subreq, &ret, NULL, NULL); TALLOC_FREE(subreq); if (! status) { - DEBUG(DEBUG_ERR, - ("delete_record: %s SCHDULE_FOR_DELETION failed, " - "ret=%d\n", state->h->db->db_name, ret)); + D_ERR("delete_record: %s SCHEDULE_FOR_DELETION failed, ret=%d\n", + state->h->db->db_name, + ret); tevent_req_error(req, ret); return; } diff --git a/ctdb/config/events/legacy/11.routing.script b/ctdb/config/events/legacy/11.routing.script index 018ee5732a6..3a526e1ed47 100755 --- a/ctdb/config/events/legacy/11.routing.script +++ b/ctdb/config/events/legacy/11.routing.script @@ -39,7 +39,7 @@ updateip) oiface=$2 niface=$3 while read iface dest gw; do - if [ "$niface" = "$iface" -o "$oiface" = "$iface" ] ; then + if [ "$niface" = "$iface" ] || [ "$oiface" = "$iface" ] ; then ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1 fi done <"${CTDB_BASE}/static-routes" diff --git a/ctdb/config/events/legacy/13.per_ip_routing.script b/ctdb/config/events/legacy/13.per_ip_routing.script index 269829483ab..ed5677327a1 100755 --- a/ctdb/config/events/legacy/13.per_ip_routing.script +++ b/ctdb/config/events/legacy/13.per_ip_routing.script @@ -20,8 +20,8 @@ table_id_prefix="ctdb." [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -lt "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] 2>/dev/null || \ die "error: CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW] and/or CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] improperly configured" -if [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -le 253 -a \ - 255 -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then +if [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -le 253 ] && \ + [ 255 -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then die "error: range CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW]..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] must not include 253-255" fi @@ -49,7 +49,7 @@ ipv4_is_valid_addr() for _o in $(export IFS="." ; echo $_ip) ; do # The 2>/dev/null stops output from failures where an "octet" # is not numeric. The test will still fail. - if ! [ 0 -le $_o -a $_o -le 255 ] 2>/dev/null ; then + if ! [ 0 -le $_o ] && [ $_o -le 255 ] 2>/dev/null ; then return 1 fi _count=$((_count + 1)) @@ -149,8 +149,9 @@ ensure_table_id_for_ip () fi # Potentially update the new table id to be used. The # redirect stops error spam for a non-numeric value. - if [ "$_new" -le "$_t" -a \ - "$_t" -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] 2>/dev/null ; then + if [ "$_new" -le "$_t" ] && \ + [ "$_t" -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] \ + 2>/dev/null ; then _new=$((_t + 1)) fi done <"$rt_tables" @@ -317,8 +318,8 @@ add_missing_routes () [ -n "$_iface" ] || continue _table_id="${table_id_prefix}${_ip}" - if [ -z "$(ip route show table "$_table_id" 2>/dev/null)" -o \ - "$1" = "force" ] ; then + if [ -z "$(ip route show table "$_table_id" 2>/dev/null)" ] || \ + [ "$1" = "force" ] ; then add_routing_for_ip "$_iface" "$_ip" fi done diff --git a/ctdb/config/events/legacy/60.nfs.script b/ctdb/config/events/legacy/60.nfs.script index 2eb90b421c8..1b87b3d27e3 100755 --- a/ctdb/config/events/legacy/60.nfs.script +++ b/ctdb/config/events/legacy/60.nfs.script @@ -139,7 +139,7 @@ nfs_check_service () fi if $_ok ; then - if [ $unhealthy_after -ne 1 -o $restart_every -ne 0 ] ; then + if [ $unhealthy_after -ne 1 ] || [ $restart_every -ne 0 ] ; then ctdb_counter_init "$_progname" fi exit 0 @@ -179,7 +179,7 @@ nfs_check_service () # shellcheck disable=SC2031 nfs_restart_service () { - if [ -z "$service_stop_cmd" -o -z "$service_start_cmd" ] ; then + if [ -z "$service_stop_cmd" ] || [ -z "$service_start_cmd" ] ; then die "ERROR: Can not restart service \"${_progname}\" without corresponding service_start_cmd/service_stop_cmd settings" fi diff --git a/ctdb/config/functions b/ctdb/config/functions index 1dc16532890..994a30162fe 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -228,8 +228,6 @@ ctdb_get_ip_address () awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file" fi - # ip_address is used by caller - # shellcheck disable=SC2034 cat "$_ip_addr_file" } diff --git a/ctdb/tests/complex/scripts/local.bash b/ctdb/tests/complex/scripts/local.bash index 787f597edcc..20b3ba706b5 100644 --- a/ctdb/tests/complex/scripts/local.bash +++ b/ctdb/tests/complex/scripts/local.bash @@ -270,3 +270,35 @@ ping_wrapper () *) ping "$@" ;; esac } + +####################################### + +nfs_test_setup () +{ + select_test_node_and_ips + + nfs_first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p') + + echo "Creating test subdirectory..." + try_command_on_node $test_node "TMPDIR=$nfs_first_export mktemp -d" + nfs_test_dir="$out" + try_command_on_node $test_node "chmod 777 $nfs_test_dir" + + nfs_mnt_d=$(mktemp -d) + nfs_local_file="${nfs_mnt_d}/${nfs_test_dir##*/}/TEST_FILE" + nfs_remote_file="${nfs_test_dir}/TEST_FILE" + + ctdb_test_exit_hook_add nfs_test_cleanup + + echo "Mounting ${test_ip}:${nfs_first_export} on ${nfs_mnt_d} ..." + mount -o timeo=1,hard,intr,vers=3 \ + "[${test_ip}]:${nfs_first_export}" ${nfs_mnt_d} +} + +nfs_test_cleanup () +{ + rm -f "$nfs_local_file" + umount -f "$nfs_mnt_d" + rmdir "$nfs_mnt_d" + onnode -q $test_node rmdir "$nfs_test_dir" +} diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh index 4934783ff9a..15c80713b3b 100755 --- a/ctdb/tests/local_daemons.sh +++ b/ctdb/tests/local_daemons.sh @@ -13,14 +13,6 @@ export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts" . "${TEST_SCRIPTS_DIR}/common.sh" -# common.sh will set TEST_SUBDIR to a stupid value when installed -# because common.sh is usually sourced by a test. TEST_SUBDIR needs -# to be correctly set so setup_ctdb_base() finds the etc-ctdb/ -# subdirectory and the test event script is correctly installed, so -# fix it. -# shellcheck disable=SC2034 -TEST_SUBDIR="$CTDB_TEST_DIR" - if ! $CTDB_TESTS_ARE_INSTALLED ; then hdir="$CTDB_SCRIPTS_HELPER_BINDIR" export CTDB_EVENTD="${hdir}/ctdb-eventd" @@ -205,7 +197,15 @@ local_daemons_setup () fi for _n in $(seq 0 $((_num_nodes - 1))) ; do - setup_ctdb_base "$directory" "node.${_n}" \ + # common.sh will set TEST_SUBDIR to a stupid value + # when installed because common.sh is usually sourced + # by a test. TEST_SUBDIR needs to be correctly set so + # setup_ctdb_base() finds the etc-ctdb/ subdirectory + # and the test event script is correctly installed, so + # fix it. + # shellcheck disable=SC2034 + TEST_SUBDIR="$CTDB_TEST_DIR" \ + setup_ctdb_base "$directory" "node.${_n}" \ functions notify.sh debug-hung-script.sh cp "$_nodes_all" "${CTDB_BASE}/nodes" diff --git a/ctdb/tests/onnode/stubs/ctdb b/ctdb/tests/onnode/stubs/ctdb index e420d25e029..8d1f855e5da 100755 --- a/ctdb/tests/onnode/stubs/ctdb +++ b/ctdb/tests/onnode/stubs/ctdb @@ -2,8 +2,6 @@ # Fake ctdb client for onnode tests. -cmd=$(echo "$*" | sed -r -e 's@[[:space:]]+@_@g') - out="${ONNODE_TESTS_VAR_DIR}/ctdb.out" if [ -r "$out" ] ; then cat "$out" @@ -16,18 +14,6 @@ if [ -r "$out" ] ; then exit 0 fi -f="${ONNODE_TESTCASE_DIR}/ctdb.d/${cmd}.sh" -if [ -x "$f" ] ; then - "$f" - exit $? -fi - -f="${ONNODE_TESTCASE_DIR}/ctdb.d/${cmd}.out" -if [ -r "$f" ] ; then - cat "$f" - exit 0 -fi - echo "fake ctdb: no implementation for \"$*\"" exit 1 diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index 2f692c1b90b..b74d7c5f193 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -8,7 +8,6 @@ Options: -A Use "cat -A" to print test output (only some tests) -c Run integration tests on a cluster -C Remove TEST_VAR_DIR when done - -d Print descriptions of tests instead of filenames (dodgy!) -D Show diff between failed/expected test output (some tests only) -e Exit on the first test failure -H No headers - for running single test with other wrapper @@ -33,7 +32,6 @@ die () ###################################################################### with_summary=true -with_desc=false quiet=false exit_on_fail=false max_iterations=1 @@ -50,12 +48,11 @@ export TEST_CLEANUP=false export TEST_TIMEOUT=3600 export TEST_SOCKET_WRAPPER_SO_PATH="" -while getopts "AcCdDehHI:NqS:T:vV:xX?" opt ; do +while getopts "AcCDehHI:NqS:T:vV:xX?" opt ; do case "$opt" in A) TEST_CAT_RESULTS_OPTS="-A" ;; c) TEST_LOCAL_DAEMONS="" ;; C) TEST_CLEANUP=true ;; - d) with_desc=true ;; # 4th line of output is description D) TEST_DIFF_RESULTS=true ;; e) exit_on_fail=true ;; H) no_header=true ;; @@ -178,9 +175,6 @@ if ! type mktemp >/dev/null 2>&1 ; then } fi -tf=$(mktemp) || die "mktemp failed for tf - is TMPDIR missing?" -sf=$(mktemp) || die "mktemp failed for sf - is TMPDIR missing?" - set -o pipefail run_one_test () @@ -189,7 +183,7 @@ run_one_test () tests_total=$((tests_total + 1)) - ctdb_test_run "$f" | tee "$tf" | show_progress + ctdb_test_run "$f" | show_progress status=$? if [ $status -eq 0 ] ; then tests_passed=$((tests_passed + 1)) @@ -203,11 +197,7 @@ run_one_test () else t="*FAILED*" fi - if $with_desc ; then - desc=$(tail -n +4 "$tf" | head -n 1) - f="$desc" - fi - echo "$t $f" >>"$sf" + echo "$t $f" >>"$summary_file" fi } @@ -286,6 +276,9 @@ if [ -z "$TEST_VAR_DIR" ] ; then fi mkdir -p "$TEST_VAR_DIR" +summary_file="${TEST_VAR_DIR}/.summary" +: >"$summary_file" + export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts" unit_tests=" @@ -354,18 +347,15 @@ while [ "$max_iterations" -eq 0 ] || [ $iterations -lt "$max_iterations" ] ; do fi done -rm -f "$tf" - if $with_summary ; then if [ $status -eq 0 ] || ! $exit_on_fail ; then echo - cat "$sf" + cat "$summary_file" echo echo "${tests_passed}/${tests_total} tests passed" fi fi - -rm -f "$sf" +rm -f "$summary_file" echo diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index 284449d4503..0aaede98e8a 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -619,38 +619,6 @@ _ctdb_scriptstatus_changed () ####################################### -nfs_test_setup () -{ - select_test_node_and_ips - - nfs_first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p') - - echo "Creating test subdirectory..." - try_command_on_node $test_node "TMPDIR=$nfs_first_export mktemp -d" - nfs_test_dir="$out" - try_command_on_node $test_node "chmod 777 $nfs_test_dir" - - nfs_mnt_d=$(mktemp -d) - nfs_local_file="${nfs_mnt_d}/${nfs_test_dir##*/}/TEST_FILE" - nfs_remote_file="${nfs_test_dir}/TEST_FILE" - - ctdb_test_exit_hook_add nfs_test_cleanup - - echo "Mounting ${test_ip}:${nfs_first_export} on ${nfs_mnt_d} ..." - mount -o timeo=1,hard,intr,vers=3 \ - "[${test_ip}]:${nfs_first_export}" ${nfs_mnt_d} -} - -nfs_test_cleanup () -{ - rm -f "$nfs_local_file" - umount -f "$nfs_mnt_d" - rmdir "$nfs_mnt_d" - onnode -q $test_node rmdir "$nfs_test_dir" -} - -####################################### - # If the given IP is hosted then print 2 items: maskbits and iface ip_maskbits_iface () { diff --git a/ctdb/tests/shellcheck/scripts/local.sh b/ctdb/tests/shellcheck/scripts/local.sh index ab92aaa5575..84019144009 100644 --- a/ctdb/tests/shellcheck/scripts/local.sh +++ b/ctdb/tests/shellcheck/scripts/local.sh @@ -28,14 +28,7 @@ shellcheck_test () # SC2164: Use cd ... || exit in case cd fails. # - Most hits are on known directories. Too # much churn, maybe later. - # SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not - # well defined. - # SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not - # well defined. - # - This can cause issues but the number of - # true positives will be very low. Too much - # churn, maybe later. - _excludes="SC1090,SC1091,SC2162,SC2164,SC2166" + _excludes="SC1090,SC1091,SC2162,SC2164" unit_test shellcheck --exclude="$_excludes" "$@" else echo "WARNING: shellcheck not installed, skipping test" diff --git a/ctdb/tests/simple/01_ctdb_reclock_command.sh b/ctdb/tests/simple/01_ctdb_reclock_command.sh index 34f82e981a1..1e1bb1b588f 100755 --- a/ctdb/tests/simple/01_ctdb_reclock_command.sh +++ b/ctdb/tests/simple/01_ctdb_reclock_command.sh @@ -21,7 +21,7 @@ if [ -z "$TEST_LOCAL_DAEMONS" ] ; then fi echo "Starting CTDB with recovery lock command configured..." -ctdb_test_init --reclock-use-command +ctdb_test_init -R cluster_is_healthy diff --git a/ctdb/tests/simple/19_ip_takeover_noop.sh b/ctdb/tests/simple/19_ip_takeover_noop.sh index 93caf668c0b..d162f0e5fba 100755 --- a/ctdb/tests/simple/19_ip_takeover_noop.sh +++ b/ctdb/tests/simple/19_ip_takeover_noop.sh @@ -23,7 +23,7 @@ if [ -z "$TEST_LOCAL_DAEMONS" ] ; then fi echo "Starting CTDB with failover disabled..." -ctdb_test_init --disable-failover +ctdb_test_init -F cluster_is_healthy @@ -41,7 +41,7 @@ echo "GOOD: All IP addresses are unassigned" echo "----------------------------------------" echo "Starting CTDB with an empty public addresses configuration..." -ctdb_test_init --no-public-addresses +ctdb_test_init -P /dev/null cluster_is_healthy diff --git a/ctdb/tests/simple/28_zero_eventscripts.sh b/ctdb/tests/simple/28_zero_eventscripts.sh index 75e5e047a73..2e536da5e6a 100755 --- a/ctdb/tests/simple/28_zero_eventscripts.sh +++ b/ctdb/tests/simple/28_zero_eventscripts.sh @@ -19,7 +19,7 @@ if [ -z "$TEST_LOCAL_DAEMONS" ] ; then exit 0 fi -ctdb_test_init --no-event_scripts +ctdb_test_init --no-event-scripts cluster_is_healthy diff --git a/ctdb/tests/simple/69_recovery_resurrect_deleted.sh b/ctdb/tests/simple/69_recovery_resurrect_deleted.sh index f6c72c59f2a..51d806a5d47 100755 --- a/ctdb/tests/simple/69_recovery_resurrect_deleted.sh +++ b/ctdb/tests/simple/69_recovery_resurrect_deleted.sh @@ -18,11 +18,11 @@ cluster_is_healthy testdb="rec_test.tdb" echo "Getting list of nodes..." -try_command_on_node -v any "onnode -pq all ctdb pnn | grep '^[0-9][0-9]*$'" +ctdb_get_all_pnns -first=$(sed -n -e '1p' "$outfile") -second=$(sed -n -e '2p' "$outfile") -notfirst=$(tail -n +2 "$outfile") +first=$(echo "$all_pnns" | sed -n -e '1p') +second=$(echo "$all_pnns" | sed -n -e '2p') +notfirst=$(echo "$all_pnns" | tail -n +2) echo "Create/wipe test database ${testdb}" try_command_on_node $first $CTDB attach "$testdb" @@ -45,8 +45,9 @@ database_has_zero_records () { local n for n in $notfirst ; do - try_command_on_node $n $CTDB cattdb "$testdb" - if grep -q '^key(' "$outfile" ; then + local num_records + num_records=$(db_ctdb_cattdb_count_records "$n" "$testdb") + if [ "$num_records" != 0 ] ; then return 1 fi done diff --git a/ctdb/tests/simple/scripts/local.bash b/ctdb/tests/simple/scripts/local.bash index 7b4a4f030df..5ffe2892c5c 100644 --- a/ctdb/tests/simple/scripts/local.bash +++ b/ctdb/tests/simple/scripts/local.bash @@ -6,11 +6,6 @@ export SIMPLE_TESTS_VAR_DIR="${TEST_VAR_DIR}/simple" # Don't remove old directory since state is retained between tests mkdir -p "$SIMPLE_TESTS_VAR_DIR" -if [ -z "$TEST_LOCAL_DAEMONS" ] ; then - # Running against a real cluster - setup_ctdb_base "$SIMPLE_TESTS_VAR_DIR" "ctdb-etc" \ - functions \ - nodes -else +if [ -n "$TEST_LOCAL_DAEMONS" ] ; then . "${TEST_SUBDIR}/scripts/local_daemons.bash" fi diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash index 5da900288b2..95af943f6d7 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/simple/scripts/local_daemons.bash @@ -19,34 +19,29 @@ export ONNODE_SSH="${ctdb_local_daemons} ssh" setup_ctdb () { - local public_addresses="" local no_event_scripts=false -- Samba Shared Repository