6 Verify that 'ctdb getdbmap' operates as expected.
8 This test creates some test databases using 'ctdb attach'.
12 * An active CTDB cluster with at least 2 active nodes.
16 1. Verify that the status on all of the ctdb nodes is 'OK'.
17 2. Get the database on using 'ctdb getdbmap'.
18 3. Verify that the output is valid.
22 * 'ctdb getdbmap' shows a valid listing of databases.
26 . ctdb_test_functions.bash
32 onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
34 # Restart when done since things are likely to be broken.
35 ctdb_test_exit_hook="restart_ctdb"
37 make_temp_db_filename ()
39 dd if=/dev/urandom count=1 bs=512 2>/dev/null |
41 awk '{printf "%s.tdb\n", $1}'
44 try_command_on_node -v 0 "$CTDB getdbmap"
46 db_map_pattern='^(Number of databases:[[:digit:]]+|dbid:0x[[:xdigit:]]+ name:[^[:space:]]+ path:[^[:space:]]+)$'
48 sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" "$out"
50 num_db_init=$(echo "$out" | sed -n -e '1s/.*://p')
52 for i in $(seq 1 5) ; do
53 f=$(make_temp_db_filename)
54 echo "Creating test database: $f"
55 try_command_on_node 0 $CTDB attach "$f"
56 try_command_on_node 0 $CTDB getdbmap
57 sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" "$out"
58 num=$(echo "$out" | sed -n -e '1s/^.*://p')
59 if [ $num = $(($num_db_init + $i)) ] ; then
60 echo "OK: correct number of additional databases"
62 echo "BAD: no additional database"
65 if [ "${out/name:${f} /}" != "$out" ] ; then
66 echo "OK: getdbmap knows about \"$f\""
68 echo "BAD: getdbmap does not know about \"$f\""
73 echo "OK, that worked... expect a restart..."