smbd: Simplify validate_lock_entries
[Samba.git] / ctdb / tests / simple / 76_ctdb_pdb_recovery.sh
blob1c897c2ff24b3876f51fb3155b6f37e1d2e754f6
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 The recovery process based on RSN for persistent databases is defective.
7 For persistent databases sequence number based recovery method should be
8 used. This test checks for the defect in the RSN based recovery method
9 for persistent databases and confirms that the same issue is not observed
10 when using sequence number based recovery method.
12 Steps:
14 1. Create a persistent database
15 2. Add a record and update it few times.
16 3. Delete the record
17 4. Turn off one of the nodes
18 5. Add a record with same key.
19 6. Turn on the stopped node
21 Expected results:
23 * Check that the record is deleted (RSN based recovery) and record is
24 present (sequence number based recovery)
26 EOF
29 . "${TEST_SCRIPTS_DIR}/integration.bash"
31 ctdb_test_init "$@"
33 set -e
35 cluster_is_healthy
37 # Reset configuration
38 ctdb_restart_when_done
40 do_test()
42 # Wipe Test database
43 echo "wipe test database"
44 try_command_on_node 0 $CTDB wipedb $TESTDB
46 # Add a record key=test1 data=value1
47 # and update values
48 for value in value1 value2 value3 value4 value5 ; do
49 echo "store key(test1) data($value)"
50 echo "\"test1\" \"$value\"" | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
51 done
53 # Delete record
54 echo "delete key(test1)"
55 try_command_on_node 0 $CTDB pdelete $TESTDB test1
57 # Stop a node
58 echo "stop node 1"
59 try_command_on_node 1 $CTDB stop
61 wait_until_node_has_status 1 stopped
63 # Add a record key=test1 data=value2
64 echo "store key(test1) data(newvalue1)"
65 echo '"test1" "newvalue1"' | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
67 # Continue node
68 echo "contine node 1"
69 try_command_on_node 1 $CTDB continue
71 wait_until_node_has_status 1 notstopped
76 # Main test
78 TESTDB="persistent_test.tdb"
80 status=0
82 # Create a temporary persistent database to test with
83 echo "create persistent test database $TESTDB"
84 try_command_on_node 0 $CTDB attach $TESTDB persistent
86 echo "set RecoverPDBBySeqNum to 0"
87 try_command_on_node all $CTDB setvar RecoverPDBBySeqNum 0
89 do_test
90 if try_command_on_node 0 $CTDB pfetch $TESTDB test1 ; then
91 echo "GOOD: Record was not deleted (recovery by RSN worked)"
92 else
93 echo "BAD: Record was deleted"
94 status=1
97 # Set RecoverPDBBySeqNum = 1
98 echo "set RecoverPDBBySeqNum to 1"
99 try_command_on_node all $CTDB setvar RecoverPDBBySeqNum 1
101 do_test
102 if try_command_on_node 0 $CTDB pfetch $TESTDB test1 ; then
103 echo "GOOD: Record was not deleted (recovery by sequence number worked)"
104 else
105 echo "BAD: Record was deleted"
106 status=1
109 exit $status