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"
20 unit_test cluster_mutex_test lock-unlock
"$helper"
22 test_case
"Contention: lock, lock, unlock"
29 unit_test cluster_mutex_test lock-lock-unlock
"$helper"
31 test_case
"No contention: lock, unlock, lock, unlock"
38 unit_test cluster_mutex_test lock-unlock-lock-unlock
"$helper"
40 test_case
"Cancelled: unlock while lock still in progress"
45 unit_test cluster_mutex_test lock-cancel-check
"$helper"
47 test_case
"Cancelled: unlock while lock still in progress, unlock again"
52 unit_test cluster_mutex_test lock-cancel-unlock
"$helper"
54 test_case
"PPID doesn't go away: lock, wait, unlock"
59 unit_test cluster_mutex_test lock-wait-unlock
"$helper"
61 test_case
"PPID goes away: lock, wait, lock, unlock"
68 unit_test cluster_mutex_test lock-ppid-gone-lock-unlock
"$helper"
70 test_case
"Recheck off, lock file removed"
77 unit_test cluster_mutex_test lock-file-removed-no-recheck \
78 "$helper 0" "$lockfile"
80 test_case
"Recheck on, lock file not removed"
85 unit_test cluster_mutex_test lock-file-wait-recheck-unlock \
88 test_case
"Recheck on, lock file removed"
91 ctdb_mutex_fcntl_helper: lock lost - lock file "${lockfile}" open failed (ret=2)
94 unit_test cluster_mutex_test lock-file-removed
"$helper 5" "$lockfile"
96 test_case
"Recheck on, lock file replaced"
99 ctdb_mutex_fcntl_helper: lock lost - lock file "${lockfile}" inode changed
102 unit_test cluster_mutex_test lock-file-changed
"$helper 10" "$lockfile"