lockfile="${CTDB_TEST_TMP_DIR}/cluster_mutex.lockfile"
trap 'rm -f ${lockfile}' 0
+test_case "No contention: lock, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-unlock "$lockfile"
+test_case "Contention: lock, lock, unlock"
ok <<EOF
LOCK
CONTENTION
EOF
unit_test cluster_mutex_test lock-lock-unlock "$lockfile"
+test_case "No contention: lock, unlock, lock, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-unlock-lock-unlock "$lockfile"
+test_case "Cancelled: unlock while lock still in progress"
ok <<EOF
CANCEL
NOLOCK
EOF
unit_test cluster_mutex_test lock-cancel-check "$lockfile"
+test_case "Cancelled: unlock while lock still in progress, unlock again"
ok <<EOF
CANCEL
UNLOCK
EOF
unit_test cluster_mutex_test lock-cancel-unlock "$lockfile"
+test_case "PPID doesn't go away: lock, wait, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-wait-unlock "$lockfile"
+test_case "PPID goes away: lock, wait, lock, unlock"
ok <<EOF
LOCK
parent gone
t="${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb_mutex_fcntl_helper"
helper="!${t} ${lockfile}"
+test_case "No contention: lock, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-unlock "$helper"
+test_case "Contention: lock, lock, unlock"
ok <<EOF
LOCK
CONTENTION
EOF
unit_test cluster_mutex_test lock-lock-unlock "$helper"
+test_case "No contention: lock, unlock, lock, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-unlock-lock-unlock "$helper"
+test_case "Cancelled: unlock while lock still in progress"
ok <<EOF
CANCEL
NOLOCK
EOF
unit_test cluster_mutex_test lock-cancel-check "$helper"
+test_case "Cancelled: unlock while lock still in progress, unlock again"
ok <<EOF
CANCEL
UNLOCK
EOF
unit_test cluster_mutex_test lock-cancel-unlock "$helper"
+test_case "PPID doesn't go away: lock, wait, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-wait-unlock "$helper"
+test_case "PPID goes away: lock, wait, lock, unlock"
ok <<EOF
LOCK
parent gone
EOF
unit_test cluster_mutex_test lock-ppid-gone-lock-unlock "$helper"
+test_case "Recheck off, lock file removed"
ok <<EOF
LOCK
LOCK
unit_test cluster_mutex_test lock-file-removed-no-recheck \
"$helper 0" "$lockfile"
+test_case "Recheck on, lock file not removed"
ok <<EOF
LOCK
UNLOCK
unit_test cluster_mutex_test lock-file-wait-recheck-unlock \
"$helper 5" 10
+test_case "Recheck on, lock file removed"
ok <<EOF
LOCK
ctdb_mutex_fcntl_helper: lock lost - lock file "${lockfile}" check failed (ret=2)
EOF
unit_test cluster_mutex_test lock-file-removed "$helper 5" "$lockfile"
+test_case "Recheck on, lock file replaced"
ok <<EOF
LOCK
ctdb_mutex_fcntl_helper: lock lost - lock file "${lockfile}" inode changed
helper="!${t} ${lockfile}"
fi
+test_case "No contention: lock, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-unlock "$helper"
+test_case "Contention: lock, lock, unlock"
ok <<EOF
LOCK
CONTENTION
EOF
unit_test cluster_mutex_test lock-lock-unlock "$helper"
+test_case "No contention: lock, unlock, lock, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-unlock-lock-unlock "$helper"
+test_case "Cancelled: unlock while lock still in progress"
ok <<EOF
CANCEL
NOLOCK
EOF
unit_test cluster_mutex_test lock-cancel-check "$helper"
+test_case "Cancelled: unlock while lock still in progress, unlock again"
ok <<EOF
CANCEL
UNLOCK
EOF
unit_test cluster_mutex_test lock-cancel-unlock "$helper"
+test_case "PPID doesn't go away: lock, wait, unlock"
ok <<EOF
LOCK
UNLOCK
EOF
unit_test cluster_mutex_test lock-wait-unlock "$helper"
+test_case "PPID goes away: lock, wait, lock, unlock"
ok <<EOF
LOCK
parent gone
unit_test system_socket_test tcp "$@"
}
+test_case "ACK, IPv4, seq# 0, ack# 0"
ok <<EOF
000000 45 00 00 08 00 00 00 00 ff 06 00 00 c0 a8 01 19
000010 c0 a8 02 4b 01 bd d4 31 00 00 00 00 00 00 00 00
EOF
tcp_test "192.168.1.25:445" "192.168.2.75:54321" 0 0 0
+test_case "RST, IPv4, seq# 0, ack# 0"
ok <<EOF
000000 45 00 00 08 00 00 00 00 ff 06 00 00 c0 a8 01 19
000010 c0 a8 02 4b 01 bd d4 31 00 00 00 00 00 00 00 00
EOF
tcp_test "192.168.1.25:445" "192.168.2.75:54321" 0 0 1
+test_case "RST, IPv4, seq# 12345, ack# 23456"
ok <<EOF
000000 45 00 00 08 00 00 00 00 ff 06 00 00 c0 a8 01 19
000010 c0 a8 02 4b 01 bd d4 31 39 30 00 00 a0 5b 00 00
EOF
tcp_test "192.168.1.25:445" "192.168.2.75:54321" 12345 23456 1
+test_case "ACK, IPv6, seq# 0, ack# 0"
ok <<EOF
000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
000010 6a f7 28 ff fe fa d1 36 fe 80 00 00 00 00 00 00
tcp_test "[fe80::6af7:28ff:fefa:d136]:445" \
"[fe80::6af7:28ff:fefb:d137]:54321" 0 0 0
+test_case "RST, IPv6, seq# 0, ack# 0"
ok <<EOF
000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
000010 6a f7 28 ff fe fa d1 36 fe 80 00 00 00 00 00 00
tcp_test "[fe80::6af7:28ff:fefa:d136]:445" \
"[fe80::6af7:28ff:fefb:d137]:54321" 0 0 1
+test_case "RST, IPv6, seq# 12345, ack# 23456"
ok <<EOF
000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
000010 6a f7 28 ff fe fa d1 36 fe 80 00 00 00 00 00 00
unit_test system_socket_test arp "$@"
}
+test_case "IPv4 ARP send"
ok <<EOF
000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
000010 08 00 06 04 00 01 12 34 56 78 9a bc c0 a8 01 19
EOF
arp_test "192.168.1.25" "12:34:56:78:9a:bc"
+test_case "IPv4 ARP reply"
ok <<EOF
000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
000010 08 00 06 04 00 02 12 34 56 78 9a bc c0 a8 01 19
EOF
arp_test "192.168.1.25" "12:34:56:78:9a:bc" reply
+test_case "IPv6 neighbor advertisement"
ok <<EOF
000000 33 33 00 00 00 01 12 34 56 78 9a bc 86 dd 60 00
000010 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 6a f7