6 The command 'ctdb restoredb' is used to restore a database across the
11 * An active CTDB cluster with at least 2 active nodes.
15 1. Verify that the status on all of the ctdb nodes is 'OK'.
16 2. Create a persistent test database
17 3. Add some records to test database
19 5. Wipe database and verify the database is empty on all nodes
20 6. Restore database and make sure all the records are restored
21 7. Make sure no recovery has been triggered
25 * Database operations should not cause a recovery
30 .
"${TEST_SCRIPTS_DIR}/integration.bash"
38 try_command_on_node
0 $CTDB status
39 generation
=$
(echo "$out" |
sed -n -e 's/^Generation:\([0-9]*\)/\1/p')
41 try_command_on_node
0 "$CTDB listnodes"
42 num_nodes
=$
(echo "$out" |
wc -l)
45 test_db
="restoredb_test.tdb"
48 echo "Create persistent test database \"$test_db\""
49 try_command_on_node
0 $CTDB attach
"$test_db" persistent
50 try_command_on_node
0 $CTDB wipedb
"$test_db"
53 # add 10,000 records to database
54 echo "Adding 10000 records to database"
56 for i
in $
(seq 1 10000) ; do
57 echo "\"key$i\" \"value$i\""
59 ) | try_command_on_node
-i 0 $CTDB ptrans
"$test_db"
61 num_records
=$
(db_ctdb_cattdb_count_records
1 "$test_db")
62 if [ $num_records = "10000" ] ; then
63 echo "OK: Records added"
65 echo "BAD: We did not end up with 10000 records"
66 echo "num records = $num_records"
70 ctdb_test_exit_hook_add
"rm -f $test_dump"
73 echo "Backup database"
74 try_command_on_node
0 $CTDB backupdb
"$test_db" "$test_dump"
78 try_command_on_node
0 $CTDB wipedb
"$test_db"
80 # check that the database is restored
81 num_records
=$
(db_ctdb_cattdb_count_records
1 "$test_db")
82 if [ $num_records = "0" ] ; then
83 echo "OK: Database was wiped"
85 echo "BAD: We did not end up with an empty database"
86 echo "num records = $num_records"
91 echo "Restore database"
92 try_command_on_node
0 $CTDB restoredb
"$test_dump" "$test_db"
94 # check that the database is restored
95 num_records
=$
(db_ctdb_cattdb_count_records
1 "$test_db")
96 if [ $num_records = "10000" ] ; then
97 echo "OK: Database was restored"
99 echo "BAD: We did not end up with 10000 records"
100 echo "num records = $num_records"
107 try_command_on_node
0 $CTDB status
108 new_generation
=$
(echo "$out" |
sed -n -e 's/^Generation:\([0-9]*\)/\1/p')
110 echo "Old generation = $generation"
111 echo "New generation = $new_generation"
113 if [ "$generation" = "$new_generation" ]; then
114 echo "OK: Database recovery not triggered."
116 echo "BAD: Database recovery triggered."