dcesrv_unixinfo: No wbc_context required
[Samba.git] / ctdb / tests / simple / 75_readonly_records_basic.sh
blob80a6adcd60e53e93d56102df59adbfbd36d35c57
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Readonly records can be activated at runtime using a ctdb command.
7 If readonly records are not activated, then any attempt to fetch a readonly
8 copy should be automatically upgraded to a read-write fetch_lock().
10 If readonly delegations are present, then any attempt to aquire a read-write
11 fetch_lock will trigger all delegations to be revoked before the fetch lock
12 completes.
15 Prerequisites:
17 * An active CTDB cluster with at least 2 active nodes.
19 Steps:
21 1. Verify that the status on all of the ctdb nodes is 'OK'.
22 2. create a test database and some records
23 3. try to fetch readonly records, this should not result in any delegations
24 4. activate readonly support
25 5. try to fetch readonly records, this should result in delegations
26 6. do a fetchlock and the delegations should be revoked
27 7. try to fetch readonly records, this should result in delegations
28 8. do a recovery and the delegations should be revoked
30 Expected results:
32 3. No delegations created when db is not in readonly mode
33 4. It is possible to activate readonly support for a database
34 5. Delegations should be created
35 6. Delegations should be revoked
36 8. Delegations should be revoked
39 EOF
42 . "${TEST_SCRIPTS_DIR}/integration.bash"
44 ctdb_test_init "$@"
46 set -e
48 cluster_is_healthy
50 # Reset configuration
51 ctdb_restart_when_done
53 try_command_on_node 0 "$CTDB listnodes"
54 num_nodes=$(echo "$out" | wc -l)
57 # create a temporary database to test with
58 echo create test database test.tdb
59 try_command_on_node 0 $CTDB attach test.tdb
62 # create some records
63 try_command_on_node all $CTDB_TEST_WRAPPER ctdb_update_record
66 # 3
67 # try readonly requests
68 echo Try some readonly fetches, these should all be upgraded to full fetchlocks
69 try_command_on_node 0,1,2 $CTDB_TEST_WRAPPER "ctdb_fetch_readonly_once </dev/null"
71 # no delegations should have been created
72 numreadonly=`try_command_on_node -v all $CTDB cattdb test.tdb | grep READONLY | wc -l`
73 [ "$numreadonly" != "0" ] && {
74 echo "BAD: readonly delegations were created, but the feature is not activated on the database"
75 exit 1
80 # 4
83 echo Activating ReadOnly record support for test.tdb ...
84 # activate readonly support
85 try_command_on_node all $CTDB setdbreadonly test.tdb
86 numreadonly=`try_command_on_node -v 0 $CTDB getdbmap | grep READONLY | wc -l`
87 [ "$numreadonly" != "1" ] && {
88 echo BAD: could not activate readonly support for the test database
89 exit 1
95 # 5
98 echo Create some readonly delegations ...
99 # fetch record to node 0 and make it dmaster
100 try_command_on_node 1 $CTDB_TEST_WRAPPER ctdb_update_record
102 # fetch readonly to node 1
103 try_command_on_node -v 0 $CTDB_TEST_WRAPPER "ctdb_fetch_readonly_once </dev/null"
105 numreadonly=`try_command_on_node -v all $CTDB cattdb test.tdb | grep RO_HAVE | wc -l`
106 [ "$numreadonly" != "2" ] && {
107 echo BAD: could not create readonly delegation
108 exit 1
118 echo verify that a fetchlock will revoke the delegations ...
119 # fetch record to node 0 and make it dmaster
120 try_command_on_node 1 $CTDB_TEST_WRAPPER ctdb_update_record
122 numreadonly=`try_command_on_node -v all $CTDB cattdb test.tdb | grep RO_HAVE | wc -l`
123 [ "$numreadonly" != "0" ] && {
124 echo BAD: fetchlock did not revoke delegations
125 exit 1
133 echo Create some readonly delegations ...
134 # fetch record to node 0 and make it dmaster
135 try_command_on_node 1 $CTDB_TEST_WRAPPER ctdb_update_record
137 # fetch readonly to node 1
138 try_command_on_node -v 0 $CTDB_TEST_WRAPPER "ctdb_fetch_readonly_once </dev/null"
140 numreadonly=`try_command_on_node -v all $CTDB cattdb test.tdb | grep RO_HAVE | wc -l`
141 [ "$numreadonly" != "2" ] && {
142 echo BAD: could not create readonly delegation
143 exit 1
153 echo verify that a recovery will revoke the delegations ...
154 try_command_on_node 0 $CTDB recover
156 numreadonly=`try_command_on_node -v all $CTDB cattdb test.tdb | grep RO_HAVE | wc -l`
157 [ "$numreadonly" != "0" ] && {
158 echo BAD: recovery did not revoke delegations
159 exit 1
162 echo OK. test completed successfully
163 exit 0