ctdb-scripts: Update important installed files to use build-time defaults
[Samba.git] / ctdb / tests / simple / 72_update_record_persistent.sh
blobf40933278e620324b527f9ac9869704b5050ca17
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 UPDATE_RECORD control should be able to create new records and update
7 existing records in a persistent database.
9 Prerequisites:
11 * An active CTDB cluster with at least one active node.
13 Steps:
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
19 5, update the record
21 Expected results:
23 * 4 created record found in the tdb
24 * 5 updated record found in the tdb
26 EOF
29 . "${TEST_SCRIPTS_DIR}/integration.bash"
31 ctdb_test_init "$@"
33 set -e
35 cluster_is_healthy
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
47 # 3,
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"
57 else
58 echo "BAD: we did not end up with an empty database"
59 exit 1
62 # 4,
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"
69 else
70 echo "BAD: we did find the record after the create/update"
71 exit 1
74 # 5,
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"
81 else
82 echo "BAD: we still found the old record after the modify/update"
83 exit 1
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"
89 else
90 echo "BAD: could not find the record after the modify/update"
91 exit 1
94 echo "Wipe the persistent test databases and clean up"
95 try_command_on_node 0 $CTDB wipedb "$test_db"