pyldb: avoid segfault when adding an element with no name
[sfrench/samba-autobuild/.git] / ctdb / tests / simple / 12_ctdb_getdebug.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that 'ctdb getdebug' works as expected.
7
8 Prerequisites:
9
10 * An active CTDB cluster with at least 2 active nodes.
11
12 Steps:
13
14 1. Verify that the status on all of the ctdb nodes is 'OK'.
15 2. Get the current debug level on a node, using 'ctdb getdebug -n <node>'.
16
17 Expected results:
18
19 * 'ctdb getdebug' shows the debug level on all the nodes.
20 EOF
21 }
22
23 . "${TEST_SCRIPTS_DIR}/integration.bash"
24
25 ctdb_test_init
26
27 set -e
28
29 cluster_is_healthy
30
31 try_command_on_node 0 "$CTDB listnodes | wc -l"
32 num_nodes="$out"
33
34 try_command_on_node -v 1 "onnode -q all $CTDB getdebug"
35 getdebug_onnode="$out"
36
37 sanity_check_output \
38     $num_nodes \
39     '^(ERROR|WARNING|NOTICE|INFO|DEBUG)$' \
40     "$out"
41
42 cmd=""
43 n=0
44 while [ $n -lt $num_nodes ] ; do
45     cmd="${cmd}${cmd:+; }$CTDB getdebug -n $n"
46     n=$(($n + 1))
47 done
48 try_command_on_node -v 1 "$cmd"
49 getdebug_n="$out"
50
51 if [ "$getdebug_onnode" = "$getdebug_n" ] ; then
52     echo "They're the same... cool!"
53 else
54     die "Error: they differ."
55 fi
56
57 seps=""
58 nl="
59 "
60 while read line ; do
61     t=$(echo "$line" | sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \((-?[[:digit:]]+)\)$@\|\1\|\2|@')
62     seps="${seps}${seps:+${nl}}|Name|Level|${nl}${t}"
63 done <<<"$getdebug_onnode"