ctdb-mutex: open() and fstat() when testing lock file
[Samba.git] / ctdb / tests / UNIT / cunit / cluster_mutex_002.sh
blobc21d1d38f335c9b5b95d048edb10bb6f5441e464
1 #!/bin/sh
3 # This tests the fcntl helper, externally configured via !
5 . "${TEST_SCRIPTS_DIR}/unit.sh"
7 export CTDB_CLUSTER_MUTEX_HELPER="/bin/false"
9 lockfile="${CTDB_TEST_TMP_DIR}/cluster_mutex.lockfile"
10 trap 'rm ${lockfile}' 0
12 t="${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb_mutex_fcntl_helper"
13 helper="!${t} ${lockfile}"
15 test_case "No contention: lock, unlock"
16 ok <<EOF
17 LOCK
18 UNLOCK
19 EOF
20 unit_test cluster_mutex_test lock-unlock "$helper"
22 test_case "Contention: lock, lock, unlock"
23 ok <<EOF
24 LOCK
25 CONTENTION
26 NOLOCK
27 UNLOCK
28 EOF
29 unit_test cluster_mutex_test lock-lock-unlock "$helper"
31 test_case "No contention: lock, unlock, lock, unlock"
32 ok <<EOF
33 LOCK
34 UNLOCK
35 LOCK
36 UNLOCK
37 EOF
38 unit_test cluster_mutex_test lock-unlock-lock-unlock "$helper"
40 test_case "Cancelled: unlock while lock still in progress"
41 ok <<EOF
42 CANCEL
43 NOLOCK
44 EOF
45 unit_test cluster_mutex_test lock-cancel-check "$helper"
47 test_case "Cancelled: unlock while lock still in progress, unlock again"
48 ok <<EOF
49 CANCEL
50 UNLOCK
51 EOF
52 unit_test cluster_mutex_test lock-cancel-unlock "$helper"
54 test_case "PPID doesn't go away: lock, wait, unlock"
55 ok <<EOF
56 LOCK
57 UNLOCK
58 EOF
59 unit_test cluster_mutex_test lock-wait-unlock "$helper"
61 test_case "PPID goes away: lock, wait, lock, unlock"
62 ok <<EOF
63 LOCK
64 parent gone
65 LOCK
66 UNLOCK
67 EOF
68 unit_test cluster_mutex_test lock-ppid-gone-lock-unlock "$helper"
70 test_case "Recheck off, lock file removed"
71 ok <<EOF
72 LOCK
73 LOCK
74 UNLOCK
75 UNLOCK
76 EOF
77 unit_test cluster_mutex_test lock-file-removed-no-recheck \
78 "$helper 0" "$lockfile"
80 test_case "Recheck on, lock file not removed"
81 ok <<EOF
82 LOCK
83 UNLOCK
84 EOF
85 unit_test cluster_mutex_test lock-file-wait-recheck-unlock \
86 "$helper 5" 10
88 test_case "Recheck on, lock file removed"
89 ok <<EOF
90 LOCK
91 ctdb_mutex_fcntl_helper: lock lost - lock file "${lockfile}" open failed (ret=2)
92 LOST
93 EOF
94 unit_test cluster_mutex_test lock-file-removed "$helper 5" "$lockfile"
96 test_case "Recheck on, lock file replaced"
97 ok <<EOF
98 LOCK
99 ctdb_mutex_fcntl_helper: lock lost - lock file "${lockfile}" inode changed
100 LOST
102 unit_test cluster_mutex_test lock-file-changed "$helper 10" "$lockfile"