Test suite: better debug info when the cluster is unexpectedly unhealthy.
[tridge/ctdb.git] / tests / simple / 01_ctdb_version.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify the output of the 'ctdb version' command.
7
8 This test assumes an RPM-based installation and needs to be skipped on
9 non-RPM systems.
10
11 Prerequisites:
12
13 * An active CTDB cluster with at least 2 active nodes.
14
15 Steps:
16
17 1. Verify that the status on all of the ctdb nodes is 'OK'.
18 2. Run the 'ctdb version' command on one of the cluster nodes.
19 3. Compare the version displayed with that listed by the rpm command
20    for the ctdb package.
21
22 Expected results:
23
24 * The 'ctdb version' command displays the ctdb version number.
25 EOF
26 }
27
28 . ctdb_test_functions.bash
29
30 ctdb_test_init "$@"
31
32 set -e
33
34 cluster_is_healthy
35
36 if ! try_command_on_node -v 0 "rpm -q ctdb" ; then
37     echo "No useful output from rpm, SKIPPING rest of test".
38     exit 0
39 fi
40 rpm_ver="${out#ctdb-}"
41
42 try_command_on_node -v 0 "$CTDB version"
43 ctdb_ver="${out#CTDB version: }"
44
45 if [ "$ctdb_ver" = "$rpm_ver" ] ; then
46     echo "OK: CTDB version = RPM version"
47 else
48     echo "BAD: CTDB version != RPM version"
49     testfailures=1
50 fi