6 UPDATE_RECORD control should be able to create new records and update
7 existing records in a persistent database.
11 * An active CTDB cluster with at least one active node.
15 1. Verify that the status on all of the ctdb nodes is 'OK'.
16 2. create a persistent test database
17 3, wipe the database to make sure it is empty
18 4, create a new record
23 * 4 created record found in the tdb
24 * 5 updated record found in the tdb
29 .
"${TEST_SCRIPTS_DIR}/integration.bash"
37 try_command_on_node
0 "$CTDB listnodes"
38 num_nodes
=$
(echo "$out" |
wc -l)
40 test_db
="persistent_test.tdb"
42 # create a temporary persistent database to test with
43 echo "Create persistent test database \"$test_db\""
44 try_command_on_node
0 $CTDB attach
"$test_db" persistent
48 echo "Wipe the persistent test database"
49 try_command_on_node
0 $CTDB wipedb
"$test_db"
50 echo "Force a recovery"
51 try_command_on_node
0 $CTDB recover
53 # check that the database is wiped
54 num_records
=$
(db_ctdb_cattdb_count_records
1 "$test_db")
55 if [ $num_records = "0" ] ; then
56 echo "OK: database was wiped"
58 echo "BAD: we did not end up with an empty database"
63 echo "Create a new record in the persistent database using UPDATE_RECORD"
64 try_command_on_node
0 $CTDB_TEST_WRAPPER ctdb_update_record_persistent
--database="$test_db" --record=Update_Record_Persistent
--value=FirstValue
66 try_command_on_node
0 "$CTDB cattdb "$test_db" | grep 'FirstValue' | wc -l"
67 if [ "$out" = 1 ] ; then
68 echo "GOOD: we did not find the record after the create/update"
70 echo "BAD: we did find the record after the create/update"
75 echo Modify an existing record
in the persistent database using UPDATE_RECORD
76 try_command_on_node
0 $CTDB_TEST_WRAPPER ctdb_update_record_persistent
--database="$test_db" --record=Update_Record_Persistent
--value=SecondValue
78 try_command_on_node
0 "$CTDB cattdb "$test_db" | grep 'FirstValue' | wc -l"
79 if [ "$out" = 0 ] ; then
80 echo "GOOD: did not find old record after the modify/update"
82 echo "BAD: we still found the old record after the modify/update"
86 try_command_on_node
0 "$CTDB cattdb "$test_db" | grep 'SecondValue' | wc -l"
87 if [ "$out" = 1 ] ; then
88 echo "GOOD: found the record after the modify/update"
90 echo "BAD: could not find the record after the modify/update"
94 echo "Wipe the persistent test databases and clean up"
95 try_command_on_node
0 $CTDB wipedb
"$test_db"