summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-06-15 05:51:45 +1000
committerKarolin Seeger <kseeger@samba.org>2018-07-10 10:44:12 +0200
commita2d359358ddb20d57c76ac13376a1c1469be329e (patch)
tree3e257550272510d3de9801f1eac4e48482a9ee4d /ctdb
parent1f25b710a83cb9549b52a45cc4981e3fd3188ba5 (diff)
downloadsamba-a2d359358ddb20d57c76ac13376a1c1469be329e.tar.gz
ctdb-tests: Add a simple test for database traverses
This tests that volatile databases traverse correctly, including the case where a record was updated on a non-lmaster node. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13499 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit ec72fadecd5233234947633360fe46a3a4053c07)
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/tests/simple/79_volatile_db_traverse.sh94
1 files changed, 94 insertions, 0 deletions
diff --git a/ctdb/tests/simple/79_volatile_db_traverse.sh b/ctdb/tests/simple/79_volatile_db_traverse.sh
new file mode 100755
index 00000000000..50732cab330
--- /dev/null
+++ b/ctdb/tests/simple/79_volatile_db_traverse.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+test_info()
+{
+ cat <<EOF
+Confirm that traverses of volatile databases work as expected
+
+This is a very simple example. It writes a single record, updates it
+on another node and then confirms that the correct value is found when
+traversing. It then repeats this after removing the LMASTER role from
+the node where the value is updated.
+
+Expected results:
+
+* The expected records should be found
+
+EOF
+}
+
+. "${TEST_SCRIPTS_DIR}/integration.bash"
+
+ctdb_test_init "$@"
+
+set -e
+
+cluster_is_healthy
+
+# Reset configuration
+ctdb_restart_when_done
+
+#
+# Main test
+#
+TESTDB="traverse_db.tdb"
+
+echo "create volatile test database $TESTDB"
+try_command_on_node 0 $CTDB attach "$TESTDB"
+
+echo "wipe test database $TESTDB"
+try_command_on_node 0 $CTDB wipedb "$TESTDB"
+
+echo "write foo=bar0 on node 0"
+try_command_on_node 0 $CTDB writekey "$TESTDB" "foo" "bar0"
+
+echo "write foo=bar1 on node 1"
+try_command_on_node 1 $CTDB writekey "$TESTDB" "foo" "bar1"
+
+echo "do traverse on node 0"
+try_command_on_node -v 0 $CTDB catdb "$TESTDB"
+
+echo "do traverse on node 1"
+try_command_on_node -v 1 $CTDB catdb "$TESTDB"
+
+cat <<EOF
+
+Again, this time with lmaster role off on node 1
+
+EOF
+
+echo "wipe test database $TESTDB"
+try_command_on_node 0 $CTDB wipedb "$TESTDB"
+
+echo "switching off lmaster role on node 1"
+try_command_on_node 1 $CTDB setlmasterrole off
+
+try_command_on_node -v 1 $CTDB getcapabilities
+
+wait_until_node_has_status 1 notlmaster 10 0
+# Wait for recovery and new VNN map to be pushed
+#sleep_for 10
+
+echo "write foo=bar0 on node 0"
+try_command_on_node 0 $CTDB writekey "$TESTDB" "foo" "bar0"
+
+echo "write foo=bar1 on node 1"
+try_command_on_node 1 $CTDB writekey "$TESTDB" "foo" "bar1"
+
+echo "do traverse on node 0"
+try_command_on_node -v 0 $CTDB catdb "$TESTDB"
+
+num=$(echo "$out" | sed -n -e 's|^Dumped \(.*\) records$|\1|p')
+if [ "$num" = 1 ] ; then
+ echo "OK: There was 1 record"
+else
+ echo "BAD: There were ${num} (!= 1) records"
+ exit 1
+fi
+
+if echo "$out" | grep -q "^data(4) = \"bar1\"\$" ; then
+ echo "OK: Data from node 1 was returned"
+else
+ echo "BAD: Data from node 1 was not returned"
+ exit 1
+fi