ctdb-tests: Switch 90_debug_hung_script.sh to be a simple test
authorMartin Schwenke <martin@meltin.net>
Mon, 11 Jun 2018 18:44:54 +0000 (04:44 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 2 Jul 2018 06:51:22 +0000 (08:51 +0200)
This test only runs against local daemons.  Configuration is done via
script.options, which simplifies things quite a bit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/90_debug_hung_script.sh [moved from ctdb/tests/complex/90_debug_hung_script.sh with 52% similarity]

similarity index 52%
rename from ctdb/tests/complex/90_debug_hung_script.sh
rename to ctdb/tests/simple/90_debug_hung_script.sh
index 797f007e106813b33e434f95145bcfd65633ad6a..b605dc02fd4595e96ecb5707a9a83121f8acb5d5 100755 (executable)
@@ -21,46 +21,35 @@ set -e
 
 ctdb_test_init "$@"
 
-ctdb_test_check_real_cluster
-
 cluster_is_healthy
 
-# No need for restart when done
+if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+       echo "SKIPPING this test - only runs against local daemons"
+       exit 0
+fi
+
+# Reset configuration
+ctdb_restart_when_done
 
 # This is overkill but it at least provides a valid test node
 select_test_node_and_ips
 
 ####################
 
-# Set this if CTDB is installed in a non-standard location on cluster
-# nodes
-[ -n "$CTDB_BASE" ] || CTDB_BASE="/etc/ctdb"
-
-####################
-
-echo "Enable eventscript for testing timeouts..."
-ctdb_test_exit_hook_add "onnode -q $test_node $CTDB event script disable 99.timeout"
-try_command_on_node $test_node $CTDB event script enable "99.timeout"
-
-####################
-
 echo "Setting monitor events to time out..."
-rc_local_d="${CTDB_BASE}/rc.local.d"
-try_command_on_node $test_node mkdir -p "$rc_local_d"
+try_command_on_node $test_node 'echo $CTDB_BASE'
+ctdb_base="$out"
+script_options="${ctdb_base}/script.options"
+ctdb_test_exit_hook_add "onnode $test_node rm -f $script_options"
 
-rc_local_f="${rc_local_d}/timeout_config.$$"
-ctdb_test_exit_hook_add "onnode $test_node rm -f $rc_local_f"
-
-try_command_on_node $test_node mktemp
-debug_output="$out"
+debug_output="${ctdb_base}/debug-hung-script.log"
 ctdb_test_exit_hook_add "onnode $test_node rm -f $debug_output"
 
-try_command_on_node -i $test_node tee "$rc_local_f" <<<"\
+try_command_on_node -i $test_node tee "$script_options" <<<"\
 CTDB_RUN_TIMEOUT_MONITOR=yes
 CTDB_DEBUG_HUNG_SCRIPT_LOGFILE=\"$debug_output\"
-CTDB_DEBUG_HUNG_SCRIPT_STACKPAT='exportfs|rpcinfo|sleep'"
-
-try_command_on_node $test_node chmod +x "$rc_local_f"
+CTDB_DEBUG_HUNG_SCRIPT_STACKPAT='exportfs|rpcinfo|sleep'
+CTDB_SCRIPT_VARDIR=\"$CTDB_BASE\""
 
 ####################
 
@@ -75,20 +64,20 @@ try_command_on_node -v $test_node cat "$debug_output"
 
 while IFS="" read pattern ; do
     if grep -- "^${pattern}\$" <<<"$out" >/dev/null ; then
-       echo "GOOD: output contains \"$pattern\""
+       printf 'GOOD: output contains "%s"\n' "$pattern"
     else
-       echo "BAD: output does not contain \"$pattern\""
+       printf 'BAD: output does not contain "%s"\n' "$pattern"
        exit 1
     fi
-done <<'EOF'
+done <<EOF
 ===== Start of hung script debug for PID=".*", event="monitor" =====
 ===== End of hung script debug for PID=".*", event="monitor" =====
 pstree -p -a .*:
-99\\.timeout\\.scri,.* /etc/ctdb/events/legacy/99\\.timeout\\.script monitor
+00\\\\.test\\\\.script,.* ${ctdb_base}/events/legacy/00\\\\.test\\\\.script monitor
  *\`-sleep,.*
----- Stack trace of interesting process [0-9]*\\[sleep\\] ----
+---- Stack trace of interesting process [0-9]*\\\\[sleep\\\\] ----
 [<[0-9a-f]*>] .*sleep+.*
 ---- ctdb scriptstatus monitor: ----
-99\\.timeout *TIMEDOUT.*
- *OUTPUT: sleeping for [0-9]* seconds\\.\\.\\.
+00\\.test *TIMEDOUT.*
+ *OUTPUT: Sleeping for [0-9]* seconds\\\\.\\\\.\\\\.
 EOF