1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-tests: Add tests for takeover helper

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2016-12-07 09:42:46 +11:00 committed by Amitay Isaacs
parent 27cb5d63d5
commit 89b4920539
39 changed files with 1408 additions and 1 deletions

View File

@ -257,7 +257,8 @@ export TEST_SCRIPTS_DIR="${test_dir}/scripts"
# If no tests specified then run some defaults
if [ -z "$1" ] ; then
if [ -n "$TEST_LOCAL_DAEMONS" ] ; then
set -- onnode takeover tool eventscripts cunit eventd shellcheck simple
set -- onnode takeover takeover_helper tool eventscripts \
cunit eventd shellcheck simple
else
set -- simple complex
fi

View File

@ -0,0 +1,22 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, no IPs"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
EOF
required_result 0 <<EOF
No nodes available to host public IPs yet
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,33 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
ok_null
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,33 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, 1 ok, IPs all unassigned"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x2 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
ok_null
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 2
10.0.0.33 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,33 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, 1 IP unassigned"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 2
10.0.0.33 1
EOF
ok_null
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 2
10.0.0.33 1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,33 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, 1 unhealthy, IPs all assigned"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x2
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 2
10.0.0.33 1
EOF
ok_null
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 0
10.0.0.33 1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,33 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all unhealthy, all IPs assigned"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x2 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x2
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 2
10.0.0.33 1
EOF
ok_null
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 2
10.0.0.33 1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,39 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all unhealthy, all IPs assigned, NoIPHostOnAllDisabled"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x2 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x2
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 2
10.0.0.33 1
EOF
ctdb_cmd setvar NoIPHostOnAllDisabled 1
ok <<EOF
Failed to find node to cover ip 10.0.0.33
Failed to find node to cover ip 10.0.0.32
Failed to find node to cover ip 10.0.0.31
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,36 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs all unassigned, DisableIPFailover"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
ctdb_cmd setvar DisableIPFailover 1
ok <<EOF
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,36 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs unbalanced, NoIPFailback"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 1
EOF
ctdb_cmd setvar NoIPFailback 1
ok <<EOF
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,34 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs unbalanced"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 1
EOF
ok <<EOF
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,37 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, 1 node unhealthy, IPs all assigned, NoIPTakeover"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
EOF
ctdb_cmd setvar NoIPTakeover 1
ok <<EOF
Failed to find node to cover ip 10.0.0.32
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 -1
10.0.0.33 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,36 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all unhealthy, IPs all assigned, NoIPTakeover"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x2 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x2
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
EOF
ctdb_cmd setvar NoIPTakeover 1
ok <<EOF
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,39 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs all assigned"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 -1
EOF
ctdb_cmd setvar NoIPTakeover 1
ok <<EOF
Failed to find node to cover ip 10.0.0.34
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 -1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs very unbalanced, no force rebalance"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 2
10.0.0.36 2
EOF
ok <<EOF
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 2
10.0.0.36 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,41 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs very unbalanced, force rebalance 1"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 2
10.0.0.36 2
EOF
ok <<EOF
Forcing rebalancing of IPs to node 1
EOF
test_takeover_helper 1
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 1
10.0.0.36 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,43 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all healthy, IPs very unbalanced, force rebalance all"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 2
10.0.0.36 2
EOF
ok <<EOF
Forcing rebalancing of IPs to node 1
Forcing rebalancing of IPs to node 0
Forcing rebalancing of IPs to node 2
EOF
test_takeover_helper 1,0,2
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 0
10.0.0.36 1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,37 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all assigned randomly, deterministic IPs"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 0
10.0.0.33 2
EOF
ctdb_cmd setvar IPAllocAlgorithm 0
ok <<EOF
Deterministic IPs enabled. Resetting all ip allocations
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,41 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs assigned, unbalanced, non-deterministic IPs"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 2
EOF
ctdb_cmd setvar IPAllocAlgorithm 1
ok_null
test_takeover_helper
# This is non-deterministic - LCP2 would not rebalance without
# force-rebalance-nodes
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
10.0.0.34 2
10.0.0.35 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,29 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, no IPs, IPREALLOCATED error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
CONTROLFAILS
137 1 ERROR CTDB_CONTROL_IPREALLOCATED fake failure
EOF
required_result 255 <<EOF
No nodes available to host public IPs yet
IPREALLOCATED failed on node 1, ret=-1
Assigning banning credits to node 1
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned, IPREALLOCATED error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
CONTROLFAILS
137 1 ERROR CTDB_CONTROL_IPREALLOCATED fake failure
EOF
required_result 255 <<EOF
IPREALLOCATED failed on node 1, ret=-1
Assigning banning credits to node 1
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned, TAKEOVER_IP error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
CONTROLFAILS
89 1 ERROR CTDB_CONTROL_TAKEOVER_IP fake failure
EOF
required_result 255 <<EOF
TAKEOVER_IP 10.0.0.32 failed on node 1, ret=-1
Assigning banning credits to node 1
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 -1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, 2/3 IPs assigned, TAKEOVER_IP error (redundant)"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 2
10.0.0.32 1
10.0.0.33 -1
CONTROLFAILS
89 1 ERROR CTDB_CONTROL_TAKEOVER_IP fake failure
EOF
required_result 255 <<EOF
TAKEOVER_IP 10.0.0.32 failed on node 1, ret=-1
Assigning banning credits to node 1
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, 2/3 IPs assigned, TAKEOVER_IP error (target)"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 2
10.0.0.32 1
10.0.0.33 -1
CONTROLFAILS
89 0 ERROR CTDB_CONTROL_TAKEOVER_IP fake failure
EOF
required_result 255 <<EOF
TAKEOVER_IP 10.0.0.33 failed on node 0, ret=-1
Assigning banning credits to node 0
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 1
10.0.0.33 -1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,41 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned, RELEASE_IP error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
CONTROLFAILS
88 2 ERROR CTDB_CONTROL_RELEASE_IP fake failure
EOF
required_result 255 <<EOF
RELEASE_IP 10.0.0.33 failed on node 2, ret=-1
RELEASE_IP 10.0.0.32 failed on node 2, ret=-1
Assigning banning credits to node 2
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, all IPs assigned, RELEASE_IP error (redundant)"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
CONTROLFAILS
88 0 ERROR CTDB_CONTROL_RELEASE_IP fake failure
EOF
required_result 255 <<EOF
RELEASE_IP 10.0.0.33 failed on node 0, ret=-1
Assigning banning credits to node 0
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 -1
10.0.0.33 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,42 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, all IPs assigned, RELEASE_IP error (target)"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x2
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
CONTROLFAILS
88 1 ERROR CTDB_CONTROL_RELEASE_IP fake failure
EOF
required_result 255 <<EOF
RELEASE_IP 10.0.0.33 failed on node 1, ret=-1
RELEASE_IP 10.0.0.32 failed on node 1, ret=-1
RELEASE_IP 10.0.0.31 failed on node 1, ret=-1
Assigning banning credits to node 1
takeover run failed, ret=-1
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 0
10.0.0.32 1
10.0.0.33 2
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,32 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, GET_PUBLIC_IPS error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 1
10.0.0.33 1
CONTROLFAILS
90 2 ERROR CTDB_CONTROL_GET_PUBLIC_IPS fake failure
EOF
required_result 255 <<EOF
control GET_PUBLIC_IPS failed on node 2, ret=-1
Failed to fetch known public IPs
takeover run failed, ret=-1
EOF
test_takeover_helper

View File

@ -0,0 +1,31 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, GET_NODEMAP error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 1
10.0.0.33 1
CONTROLFAILS
91 0 ERROR CTDB_CONTROL_GET_NODEMAP fake failure
EOF
required_result 255 <<EOF
control GET_NODEMAP failed, ret=-1
takeover run failed, ret=-1
EOF
test_takeover_helper

View File

@ -0,0 +1,31 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, GET_ALL_TUNABLES error"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 1
10.0.0.33 1
CONTROLFAILS
53 0 ERROR CTDB_CONTROL_GET_ALL_TUNABLES fake failure
EOF
required_result 255 <<EOF
control GET_ALL_TUNABLES failed, ret=-1
takeover run failed, ret=-1
EOF
test_takeover_helper

View File

@ -0,0 +1,29 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, no IPs, IPREALLOCATED timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
CONTROLFAILS
137 1 TIMEOUT CTDB_CONTROL_IPREALLOCATED fake timeout
EOF
required_result 110 <<EOF
No nodes available to host public IPs yet
IPREALLOCATED failed on node 1, ret=110
Assigning banning credits to node 1
takeover run failed, ret=110
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned, IPREALLOCATED timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
CONTROLFAILS
137 1 TIMEOUT CTDB_CONTROL_IPREALLOCATED fake timeout
EOF
required_result 110 <<EOF
IPREALLOCATED failed on node 1, ret=110
Assigning banning credits to node 1
takeover run failed, ret=110
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,40 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned, TAKEOVER_IP timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
CONTROLFAILS
89 1 TIMEOUT CTDB_CONTROL_TAKEOVER_IP fake timeout
EOF
required_result 110 <<EOF
TAKEOVER_IP 10.0.0.32 failed to node 1, ret=110
Assigning banning credits to node 1
takeover run failed, ret=110
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 2
10.0.0.32 -1
10.0.0.33 0
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,41 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, IPs all unassigned, RELEASE_IP timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
CONTROLFAILS
88 2 TIMEOUT CTDB_CONTROL_RELEASE_IP fake timeout
EOF
required_result 110 <<EOF
RELEASE_IP 10.0.0.33 failed on node 2, ret=110
RELEASE_IP 10.0.0.32 failed on node 2, ret=110
Assigning banning credits to node 2
takeover run failed, ret=110
EOF
test_takeover_helper
required_result 0 <<EOF
Public IPs on ALL nodes
10.0.0.31 -1
10.0.0.32 -1
10.0.0.33 -1
EOF
test_ctdb_ip_all

View File

@ -0,0 +1,32 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, GET_PUBLIC_IPS timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 1
10.0.0.33 1
CONTROLFAILS
90 2 TIMEOUT CTDB_CONTROL_GET_PUBLIC_IPS fake timeout
EOF
required_result 110 <<EOF
control GET_PUBLIC_IPS failed on node 2, ret=110
Failed to fetch known public IPs
takeover run failed, ret=110
EOF
test_takeover_helper

View File

@ -0,0 +1,31 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, GET_NODEMAP timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 1
10.0.0.33 1
CONTROLFAILS
91 0 TIMEOUT CTDB_CONTROL_GET_NODEMAP fake timeout
EOF
required_result 110 <<EOF
control GET_NODEMAP failed to node 0, ret=110
takeover run failed, ret=110
EOF
test_takeover_helper

View File

@ -0,0 +1,31 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all ok, GET_ALL_TUNABLES timeout"
setup_ctdbd <<EOF
NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
IFACES
:Name:LinkStatus:References:
:eth2:1:2:
:eth1:1:4:
PUBLICIPS
10.0.0.31 1
10.0.0.32 1
10.0.0.33 1
CONTROLFAILS
53 0 TIMEOUT CTDB_CONTROL_GET_ALL_TUNABLES fake timeout
EOF
required_result 110 <<EOF
control GET_ALL_TUNABLES failed, ret=110
takeover run failed, ret=110
EOF
test_takeover_helper

View File

@ -0,0 +1,109 @@
# Hey Emacs, this is a -*- shell-script -*- !!! :-)
# Augment PATH with stubs/ directory.
if "$TEST_VERBOSE" ; then
debug () { echo "$@" ; }
else
debug () { : ; }
fi
. "${TEST_SCRIPTS_DIR}/script_install_paths.sh"
PATH="$PATH:$CTDB_SCRIPTS_TOOLS_HELPER_DIR"
ctdbd_socket="${TEST_VAR_DIR}/ctdbd.socket.$$"
ctdbd_pidfile="${TEST_VAR_DIR}/ctdbd.pid.$$"
define_test ()
{
_f=$(basename "$0" ".sh")
printf "%-28s - %s\n" "$_f" "$1"
if [ -z "$FAKE_CTDBD_DEBUGLEVEL" ] ; then
FAKE_CTDBD_DEBUGLEVEL="ERR"
fi
if [ -z "$HELPER_DEBUGLEVEL" ] ; then
HELPER_DEBUGLEVEL="NOTICE"
fi
if [ -z "$CTDB_DEBUGLEVEL" ] ; then
CTDB_DEBUGLEVEL="ERR"
fi
}
cleanup_ctdbd ()
{
debug "Cleaning up fake ctdbd"
pid=$(cat "$ctdbd_pidfile" 2>/dev/null || echo)
if [ -n "$pid" ] ; then
kill $pid || true
rm -f "$ctdbd_pidfile"
fi
rm -f "$ctdbd_socket"
}
setup_ctdbd ()
{
debug "Setting up fake ctdbd"
$VALGRIND fake_ctdbd -d "$FAKE_CTDBD_DEBUGLEVEL" \
-s "$ctdbd_socket" -p "$ctdbd_pidfile"
# This current translates to a 6 second timeout for the
# important controls
ctdb --socket $ctdbd_socket setvar TakeoverTimeout 2
test_cleanup cleanup_ctdbd
}
ctdbd_getpid ()
{
cat "$ctdbd_pidfile"
}
# Render non-printable characters. The helper prints the status as
# binary, so render it for easy comparison.
result_filter ()
{
sed -e 's|ctdb-takeover\[[0-9]*\]: ||'
}
ctdb_cmd ()
{
echo Running: ctdb -d "$CTDB_DEBUGLEVEL" --socket $ctdbd_socket "$@"
ctdb -d "$CTDB_DEBUGLEVEL" --socket $ctdbd_socket "$@"
}
test_ctdb_ip_all ()
{
unit_test ctdb -d "$CTDB_DEBUGLEVEL" \
--socket $ctdbd_socket ip all || exit $?
}
takeover_helper_out="${TEST_VAR_DIR}/takover_helper.out"
takeover_helper_format_outfd ()
{
od -A n -t d4 "$takeover_helper_out" | sed -e 's|^[[:space:]]*||'
}
test_takeover_helper ()
{
(
export CTDB_DEBUGLEVEL="$HELPER_DEBUGLEVEL"
export CTDB_LOGGING="file:"
unit_test ctdb_takeover_helper 3 "$ctdbd_socket" "$@" \
3>"$takeover_helper_out"
) || exit $?
case "$required_rc" in
255) _t="-1" ;;
*) _t="$required_rc" ;;
esac
ok "$_t"
unit_test_notrace takeover_helper_format_outfd
_ret=$?
rm "$takeover_helper_out"
[ $? -eq 0 ] || exit $?
}

View File

@ -838,6 +838,7 @@ def build(bld):
'shellcheck',
'simple',
'takeover',
'takeover_helper',
'tool'
]