1 # $NetBSD: t_basic.sh,v 1.1 2017/01/16 08:18:11 ozaki-r Exp $
3 # Copyright (c) 2017 Internet Initiative Japan Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 SOCK_CLIENT=unix://carp_client
29 SOCK_MASTER=unix://carp_master
30 SOCK_BACKUP=unix://carp_backup
38 atf_test_case carp_handover cleanup
43 atf_set "descr" "Tests for CARP handover"
44 atf_set "require.progs" "rump_server"
51 local carpif= ip= advskew=
63 export RUMP_SERVER=$sock
64 atf_check -s exit:0 rump.ifconfig $carpif create
65 atf_check -s exit:0 rump.ifconfig shmif0 $ip/24 up
66 atf_check -s exit:0 rump.ifconfig $carpif \
67 vhid 175 advskew $advskew advbase 1 pass s3cret \
68 $IP_CARP netmask 255.255.255.0
69 atf_check -s exit:0 rump.ifconfig -w 10
76 export RUMP_SERVER=$SOCK_CLIENT
78 while [ $i -ne 5 ]; do
79 $DEBUG && echo "Trying ping $IP_CARP"
80 rump.ping -n -w 1 -c 1 $IP_CARP >/dev/null
82 $DEBUG && echo "Passed ping $IP_CARP"
85 $DEBUG && echo "Failed ping $IP_CARP"
90 atf_fail "Failed to failover (5 sec)"
97 rump_server_start $SOCK_CLIENT
98 rump_server_start $SOCK_MASTER
99 rump_server_start $SOCK_BACKUP
101 rump_server_add_iface $SOCK_CLIENT shmif0 $BUS
102 rump_server_add_iface $SOCK_MASTER shmif0 $BUS
103 rump_server_add_iface $SOCK_BACKUP shmif0 $BUS
105 setup_carp $SOCK_MASTER true
106 setup_carp $SOCK_BACKUP false
108 export RUMP_SERVER=$SOCK_CLIENT
109 atf_check -s exit:0 rump.ifconfig shmif0 $IP_CLIENT/24 up
110 atf_check -s exit:0 rump.ifconfig -w 10
112 # Check that the primary addresses are up
113 atf_check -s exit:0 -o ignore \
114 rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
115 atf_check -s exit:0 -o ignore \
116 rump.ping -n -w $TIMEOUT -c 1 $IP_BACKUP
118 # Give carp a while to croak
122 export RUMP_SERVER=$SOCK_MASTER
123 $DEBUG && rump.ifconfig
124 atf_check -s exit:0 -o match:'carp: MASTER carpdev shmif0' \
126 export RUMP_SERVER=$SOCK_BACKUP
127 $DEBUG && rump.ifconfig
128 atf_check -s exit:0 -o match:'carp: BACKUP carpdev shmif0' \
130 export RUMP_SERVER=$SOCK_CLIENT
132 # Check that the shared IP works
133 atf_check -s exit:0 -o ignore \
134 rump.ping -n -w $TIMEOUT -c 1 $IP_CARP
137 env RUMP_SERVER=$SOCK_MASTER rump.halt
140 # Check that primary is now dead
141 atf_check -s not-exit:0 -o ignore \
142 rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
144 # Do it in installments. carp will cluck meanwhile
148 export RUMP_SERVER=$SOCK_BACKUP
149 $DEBUG && rump.ifconfig
150 atf_check -s exit:0 -o match:'carp: MASTER carpdev shmif0' \
154 carp_handover_cleanup()
161 atf_init_test_cases()
164 atf_add_test_case carp_handover