6 Verify that the ctdb ptrans works as expected
10 * An active CTDB cluster with at least 2 active nodes.
14 1. Verify that the status on all of the ctdb nodes is 'OK'.
15 2. Pipe some operation to ctdb ptrans and validate the TDB contents with ctdb catdb
19 * ctdb ptrans works as expected.
23 .
"${TEST_SCRIPTS_DIR}/integration.bash"
31 TESTDB
="ptrans_test.tdb"
33 # Create a temporary persistent database to test with
34 echo "create persistent test database $TESTDB"
35 try_command_on_node
0 $CTDB attach
$TESTDB persistent
38 echo "wipe test database"
39 try_command_on_node
0 $CTDB wipedb
$TESTDB
43 echo "Adding 3 records"
50 echo "$items" | try_command_on_node
-i 0 $CTDB ptrans
"$TESTDB"
52 try_command_on_node
0 $CTDB catdb
"$TESTDB"
54 n
=$
(echo "$out" |
grep -c '^key.*= "key.*"' || true
)
56 if [ $n -ne 3 ] ; then
57 echo "BAD: expected 3 keys in..."
61 echo "GOOD: 3 records were inserted"
66 echo "Deleting 1 record, updating 1, adding 1 new record, 1 bogus input line"
74 echo "$items" | try_command_on_node
-i 0 $CTDB ptrans
"$TESTDB"
76 try_command_on_node
0 $CTDB catdb
"$TESTDB"
78 n
=$
(echo "$out" |
grep -c '^key.*= "key.*"' || true
)
80 if [ $n -ne 3 ] ; then
81 echo "BAD: expected 3 keys in..."
85 echo "GOOD: 3 records found"
90 echo "Verifying records"
92 while read key value
; do
93 try_command_on_node
0 $CTDB pfetch
"$TESTDB" "$key"
94 if [ "$value" != "$out" ] ; then
95 echo "BAD: for key \"$key\" expected \"$value\" but got \"$out\""
98 echo "GOOD: for key \"$key\" got \"$out\""
108 echo "Deleting all records"
115 echo "$items" | try_command_on_node
-i 0 $CTDB ptrans
"$TESTDB"
117 try_command_on_node
0 $CTDB catdb
"$TESTDB"
119 n
=$
(echo "$out" |
grep -c '^key.*= "key.*"' || true
)
121 if [ $n -ne 0 ] ; then
122 echo "BAD: expected 0 keys in..."
126 echo "GOOD: 0 records found"