ctdb-tests: Avoid bulk output in $out, prefer $outfile
[vlendec/samba-autobuild/.git] / ctdb / tests / simple / 08_ctdb_isnotrecmaster.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify the operation of 'ctdb isnotrecmaster'.
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. Run 'ctdb isnotrecmaster' on each node.
16
17 3. Verify that only 1 node shows the output 'This node is the
18    recmaster' and all the other nodes show the output 'This node is
19    not the recmaster'.
20
21 Expected results:
22
23 * 'ctdb isnotrecmaster' shows the correct output.
24 EOF
25 }
26
27 . "${TEST_SCRIPTS_DIR}/integration.bash"
28
29 ctdb_test_init
30
31 set -e
32
33 cluster_is_healthy
34
35 cmd="$CTDB isnotrecmaster || true"
36 try_command_on_node -v all "$cmd"
37
38 num_all_lines=$(wc -l <"$outfile")
39 num_rm_lines=$(grep -Fc 'this node is the recmaster' "$outfile") || true
40 num_not_rm_lines=$(grep -Fc 'this node is not the recmaster' "$outfile") || true
41
42 if [ $num_rm_lines -eq 1 ] ; then
43     echo "OK, there is only 1 recmaster"
44 else
45     die "BAD, there are ${num_rm_lines} nodes claiming to be the recmaster"
46 fi
47
48 if [ $(($num_all_lines - $num_not_rm_lines)) -eq 1 ] ; then
49     echo "OK, all the other nodes claim not to be the recmaster"
50 else
51     die "BAD, there are only ${num_not_rm_lines} notrecmaster nodes"
52 fi