diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2012-02-16 10:19:15 +1100 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2012-02-16 10:19:15 +1100 |
commit | 1cfefb406f289a9d1d7601e4e4708725b4782ac4 (patch) | |
tree | bf157e8a56485b27769b3f4694bed615e7b0f508 | |
parent | 5082bba2466af8a3f8953377d270f47a3706e375 (diff) | |
download | samba-1cfefb406f289a9d1d7601e4e4708725b4782ac4.tar.gz samba-1cfefb406f289a9d1d7601e4e4708725b4782ac4.tar.xz samba-1cfefb406f289a9d1d7601e4e4708725b4782ac4.zip |
TESTS: Add test for wipedb command
(This used to be ctdb commit 4ea05fef886b0680d0ad0936c239a51fd75bf000)
-rwxr-xr-x | ctdb/tests/simple/71_ctdb_wipedb.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/ctdb/tests/simple/71_ctdb_wipedb.sh b/ctdb/tests/simple/71_ctdb_wipedb.sh new file mode 100755 index 0000000000..3859661908 --- /dev/null +++ b/ctdb/tests/simple/71_ctdb_wipedb.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +test_info() +{ + cat <<EOF +The command 'ctdb wipedb' is used to clear a database across the whole +cluster. + +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. create a persistent test database +3, add some records to node #0 and node #1 +4, perform wipedb on node #0 and verify the database is empty on both node 0 and 1 + +Expected results: + +* that 4 will result in empty database + +EOF +} + +. ctdb_test_functions.bash + +ctdb_test_init "$@" + +set -e + +cluster_is_healthy + +try_command_on_node 0 "$CTDB listnodes" +num_nodes=$(echo "$out" | wc -l) + +# create a temporary persistent database to test with +echo create persistent test database persistent_test.tdb +try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb attach persistent_test.tdb persistent + + +# 3, +# add one record to node 0 key==ABC data==ABC +TDB=`try_command_on_node -v -q 0 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"` +echo "store key(ABC) data(ABC) on node 0" +try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x414243 0x070000000000000000000000000000000000000000000000414243 +# +# add one record to node 1 key==DEF data==DEF +TDB=`try_command_on_node -v -q 1 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"` +echo "store key(DEF) data(DEF) on node 1" +try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x444546 0x070000000000000000000000000000000000000000000000444546 + + +# 4, +echo wipe the persistent test database +try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb wipedb persistent_test.tdb +echo force a recovery +try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb recover + +# check that the database is wiped +num_records=$(try_command_on_node -v -pq 1 $CTDB_TEST_WRAPPER ctdb cattdb persistent_test.tdb | grep key | wc -l) +[ $num_records != "0" ] && { + echo "BAD: we did not end up with an empty database" + exit 1 +} +echo "OK. database was wiped" + |