From: Liu Yuan <tailai...@taobao.com> - also add two helpers: _simulate_mahcine_done and _cleanup_machine_simulation
Signed-off-by: Liu Yuan <tailai...@taobao.com> --- tests/035 | 25 ++++++++++--------------- tests/035.out | 20 ++++++++++---------- tests/common.rc | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/tests/035 b/tests/035 index 501f959..7e2ef98 100755 --- a/tests/035 +++ b/tests/035 @@ -17,33 +17,28 @@ trap "_uninit; exit \$status" 0 1 2 3 15 _uninit() { - iptables -D INPUT -p tcp --sport 7001 -j DROP - iptables -D INPUT -p tcp --dport 7001 -j DROP + for i in `seq 1 4`; do + _cleanup_machine_simulation $i + done } _cleanup -for i in `seq 0 1 2`; do - _start_sheep $i +for i in `seq 0 5`; do + _start_sheep $i done -_wait_for_sheep 3 +_wait_for_sheep 6 $COLLIE cluster format -c 3 -m unsafe $COLLIE vdi create test 40M -( -dd if=/dev/urandom | $COLLIE vdi write test -) & +dd if=/dev/urandom | $COLLIE vdi write test & sleep 3 -# Simulate machine(127.0.0.1:7001) down -iptables -A INPUT -p tcp --sport 7001 -j DROP -iptables -A INPUT -p tcp --dport 7001 -j DROP - -sleep 1 -# Trigger the confchg -_kill_sheep 1 +for i in `seq 1 4`; do + _simulate_machine_down $i +done _wait_for_collie diff --git a/tests/035.out b/tests/035.out index 0c55d7e..1d8dca4 100644 --- a/tests/035.out +++ b/tests/035.out @@ -3,40 +3,40 @@ using backend farm store Looking for the object 0x7c2b2500000000 (the inode vid 0x7c2b25 idx 0) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000001 (the inode vid 0x7c2b25 idx 1) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000002 (the inode vid 0x7c2b25 idx 2) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000003 (the inode vid 0x7c2b25 idx 3) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000004 (the inode vid 0x7c2b25 idx 4) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000005 (the inode vid 0x7c2b25 idx 5) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000006 (the inode vid 0x7c2b25 idx 6) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000007 (the inode vid 0x7c2b25 idx 7) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000008 (the inode vid 0x7c2b25 idx 8) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) Looking for the object 0x7c2b2500000009 (the inode vid 0x7c2b25 idx 9) with 2 nodes 127.0.0.1:7000 has the object (should be 2 copies) -127.0.0.1:7002 has the object (should be 2 copies) +127.0.0.1:7005 has the object (should be 2 copies) diff --git a/tests/common.rc b/tests/common.rc index 0e086b1..0d4e95d 100644 --- a/tests/common.rc +++ b/tests/common.rc @@ -214,5 +214,25 @@ _wait_for_sheep_recovery() done } +# This differ from kill(2) that we don't get the notification that connection is +# closed and most likely leave us half-open connections +_simulate_machine_down() +{ + # Drop the packet in/out this port + iptables -A INPUT -p tcp --sport $((7000+$i)) -j DROP + iptables -A INPUT -p tcp --dport $((7000+$i)) -j DROP + + sleep 3 + # Trigger the confchg because cluster driver doesn't know we'er offline + _kill_sheep $1 +} + +# Cleanup the iptables rules used to simulate machine down +_cleanup_machine_simulation() +{ + iptables -D INPUT -p tcp --sport $((7000+$i)) -j DROP + iptables -D INPUT -p tcp --dport $((7000+$i)) -j DROP +} + # make sure this script returns success /bin/true -- 1.7.12.84.gefa6462 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog