summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2008-12-16 17:22:22 +1100
committerMartin Schwenke <martin@meltin.net>2008-12-16 17:22:22 +1100
commit331f39d340b7d6663e290c3d100fd3c9c53e650f (patch)
treeef4857eb131f2820bc7a1fb888122369949003cc
parent6d7732928f15888104e034795ec1e862b63fafa6 (diff)
downloadsamba-331f39d340b7d6663e290c3d100fd3c9c53e650f.tar.gz
samba-331f39d340b7d6663e290c3d100fd3c9c53e650f.tar.xz
samba-331f39d340b7d6663e290c3d100fd3c9c53e650f.zip
Finish 24_ctdb_getdbmap.sh. New test 25_dumpmemory.sh.
Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f5aeab0390b735291ee82359f50d508619211623)
-rwxr-xr-xctdb/tests/simple/24_ctdb_getdbmap.sh26
-rwxr-xr-xctdb/tests/simple/25_dumpmemory.sh54
2 files changed, 71 insertions, 9 deletions
diff --git a/ctdb/tests/simple/24_ctdb_getdbmap.sh b/ctdb/tests/simple/24_ctdb_getdbmap.sh
index 5734932ec57..8c419210610 100755
--- a/ctdb/tests/simple/24_ctdb_getdbmap.sh
+++ b/ctdb/tests/simple/24_ctdb_getdbmap.sh
@@ -34,8 +34,6 @@ onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
# Restart when done since things are likely to be broken.
ctdb_test_exit_hook="restart_ctdb"
-echo "OK, that worked... expect a restart..."
-
make_temp_db_filename ()
{
dd if=/dev/urandom count=1 bs=512 2>/dev/null |
@@ -44,24 +42,34 @@ make_temp_db_filename ()
}
try_command_on_node -v 0 "ctdb getdbmap"
+
+db_map_pattern='^(Number of databases:[[:digit:]]+|dbid:0x[[:xdigit:]]+ name:[^[:space:]]+ path:[^[:space:]]+)$'
+
+sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" "$out"
+
num_db_init=$(echo "$out" | sed -n -e '1s/.*://p')
for i in $(seq 1 5) ; do
f=$(make_temp_db_filename)
- echo "Attempting to create test database \"$f\"..."
+ echo "Creating test database: $f"
try_command_on_node 0 ctdb attach "$f"
try_command_on_node 0 ctdb getdbmap
+ sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" "$out"
num=$(echo "$out" | sed -n -e '1s/^.*://p')
if [ $num = $(($num_db_init + $i)) ] ; then
- echo "OK: seem to have the right number of databases"
+ echo "OK: correct number of additional databases"
else
- echo "BAD: we didn't get an additional database"
+ echo "BAD: no additional database"
+ exit 1
+ fi
+ if [ "${out/name:${f} /}" != "$out" ] ; then
+ echo "OK: getdbmap knows about \"$f\""
+ else
+ echo "BAD: getdbmap does not know about \"$f\""
exit 1
fi
-
- # Add check to make sure we have the database we actually added!
- # Probably do a sanity check on the overall output of getdbmap
- # each time too.
done
+echo "OK, that worked... expect a restart..."
+
ctdb_test_exit
diff --git a/ctdb/tests/simple/25_dumpmemory.sh b/ctdb/tests/simple/25_dumpmemory.sh
new file mode 100755
index 00000000000..babaafbb160
--- /dev/null
+++ b/ctdb/tests/simple/25_dumpmemory.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+test_info()
+{
+ cat <<EOF
+Verify that 'ctdb dumpmemory' shows expected output.
+
+Prerequisites:
+
+* An active CTDB cluster with at least 2 active nodes.
+
+Steps:
+
+1. Verify that the status on all of the ctdb nodes is 'OK'.
+2. Run 'ctdb dumpmemory' and verify that it shows expected output
+3. Verify that the command takes the '-n all' option and that it
+ causes output for all nodes to be displayed.
+
+Expected results:
+
+* 'ctdb dumpmemory' sows valid output.
+EOF
+}
+
+. ctdb_test_functions.bash
+
+ctdb_test_init "$@"
+
+set -e
+
+onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
+
+try_command_on_node -v 0 "ctdb dumpmemory"
+
+pat='^([[:space:]].+[[:space:]]+contains[[:space:]]+[[:digit:]]+ bytes in[[:space:]]+[[:digit:]]+ blocks \(ref [[:digit:]]+\)[[:space:]]+0x[[:xdigit:]]+|[[:space:]]+reference to: .+|full talloc report on .+ \(total[[:space:]]+[[:digit:]]+ bytes in [[:digit:]]+ blocks\))$'
+
+sanity_check_output 10 "$pat" "$out"
+
+echo "Checking output using '-n all'..."
+
+try_command_on_node 0 "ctdb listnodes"
+num_nodes=$(echo "$out" | wc -l)
+
+try_command_on_node 0 "ctdb dumpmemory" -n all
+sanity_check_output 10 "$pat" "$out"
+
+if [ $(fgrep -c 'full talloc report on' <<<"$out") -eq $num_nodes ] ; then
+ echo "OK: there looks to be output for all $num_nodes nodes"
+else
+ echo "BAD: there not look to be output for all $num_nodes nodes"
+ exit 1
+fi
+
+ctdb_test_exit