smbd: Simplify validate_lock_entries
[Samba.git] / ctdb / tests / simple / 13_ctdb_setdebug.sh
blobd1d1f22a8d5e9c12695179740853f0537fca0b1b
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that 'ctdb setdebug' works as expected.
8 This is a little superficial. It checks that CTDB thinks the debug
9 level has been changed but doesn't actually check that logging occurs
10 at the new level.
12 A test should also be added to see if setting the debug value via a
13 numerical value works too.
15 Prerequisites:
17 * An active CTDB cluster with at least 2 active nodes.
19 Steps:
21 1. Verify that the status on all of the ctdb nodes is 'OK'.
22 2. Get the current debug level on a node, using 'ctdb getdebug'.
23 3. Change the debug level to some other value (e.g. EMERG) using
24 'ctdb setdebug'.
25 4. Verify that the new debug level is correctly set using 'ctdb getdebug'.
27 Expected results:
29 * 'ctdb setdebug' correctly sets the debug level on a node.
30 EOF
33 . "${TEST_SCRIPTS_DIR}/integration.bash"
35 ctdb_test_init "$@"
37 set -e
39 cluster_is_healthy
41 get_debug ()
43 # Sets; check_debug
44 local node="$1"
46 local out
48 try_command_on_node -v $node "$CTDB getdebug"
49 check_debug=$(echo "$out" |
50 sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \(-?[[:digit:]]+\)$@\1@')
53 set_and_check_debug ()
55 local node="$1"
56 local level="$2"
58 echo "Setting debug level on node ${node} to ${level}."
59 try_command_on_node $node "$CTDB setdebug ${level}"
61 local check_debug
62 get_debug $node
64 if [ "$level" = "$check_debug" ] ; then
65 echo "That seemed to work... cool!"
66 else
67 echo "BAD: Debug level should have changed to \"$level\" but it is \"$check_debug\"."
68 testfailures=1
72 get_debug 1
73 initial_debug="$check_debug"
75 new_debug="EMERG"
76 [ "$initial_debug" = "$new_debug" ] && new_debug="ALERT"
78 set_and_check_debug 1 "$new_debug"
80 if [ "$testfailures" != 1 ] ; then
81 echo "Returning the debug level to its initial value..."
82 set_and_check_debug 1 "$initial_debug"