ctdb-daemon: Mark RecoverPDBBySeqNum tunable deprecated
[samba.git] / ctdb / tests / simple / 76_ctdb_pdb_recovery.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 This test confirms that the deleted records are not resurrected after recovery.
7
8 Steps:
9
10 1. Create a persistent database
11 2. Add a record and update it few times.
12 3. Delete the record
13 4. Turn off one of the nodes
14 5. Add a record with same key.
15 6. Turn on the stopped node
16
17 Expected results:
18
19 * Check that the deleted record is present after recovery.
20
21 EOF
22 }
23
24 . "${TEST_SCRIPTS_DIR}/integration.bash"
25
26 ctdb_test_init "$@"
27
28 set -e
29
30 cluster_is_healthy
31
32 # Reset configuration
33 ctdb_restart_when_done
34
35 do_test()
36 {
37 # Wipe Test database
38 echo "wipe test database"
39 try_command_on_node 0 $CTDB wipedb $TESTDB
40
41 # Add a record   key=test1 data=value1
42 # and update values
43 for value in value1 value2 value3 value4 value5 ; do
44         echo "store key(test1) data($value)"
45         echo "\"test1\" \"$value\"" | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
46 done
47
48 # Delete record
49 echo "delete key(test1)"
50 try_command_on_node 0 $CTDB pdelete $TESTDB test1
51
52 # Stop a node
53 echo "stop node 1"
54 try_command_on_node 1 $CTDB stop
55
56 wait_until_node_has_status 1 stopped
57
58 # Add a record   key=test1 data=value2
59 echo "store key(test1) data(newvalue1)"
60 echo '"test1" "newvalue1"' | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
61
62 # Continue node
63 echo "contine node 1"
64 try_command_on_node 1 $CTDB continue
65
66 wait_until_node_has_status 1 notstopped
67
68 }
69
70 #
71 # Main test
72 #
73 TESTDB="persistent_test.tdb"
74
75 status=0
76
77 # Create a temporary persistent database to test with
78 echo "create persistent test database $TESTDB"
79 try_command_on_node 0 $CTDB attach $TESTDB persistent
80
81 do_test
82 if try_command_on_node 0 $CTDB pfetch $TESTDB test1 ; then
83         echo "GOOD: Record was not deleted (recovery by sequence number worked)"
84 else
85         echo "BAD: Record was deleted"
86         status=1
87 fi
88
89 exit $status