Add multihoming tests
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / multihoming_l2.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/multihoming_topo_l2.sh
4
5 ODL_CONFIG_FILE1="vpp1.json"
6 ODL_CONFIG_FILE2="vpp2.json"
7 ODL_CONFIG_FILE3="update_vpp2.json"
8
9 function maybe_pause
10 {
11   if [ "$1" == "wait" ] ; then
12     read -p  "press any key to continue .." -n1
13   fi
14 }
15
16 if [ "$1" == "clean" ] ; then
17   multihoming_topo_clean
18   exit 0
19 fi
20
21 if [[ $(id -u) != 0 ]]; then
22   echo "Error: run this as a root."
23   exit 1
24 fi
25
26 function test_multihoming
27 {
28   if [ "$3" != "no_setup" ] ; then
29     multihoming_topo_setup
30   fi
31
32   maybe_pause $3
33
34   test_result=1
35
36   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
37   rc=$?
38   if [ $rc -ne 0 ] ; then
39     echo "No response received!"
40
41     maybe_pause $3
42     multihoming_topo_clean
43     exit $test_result
44   fi
45
46   maybe_pause $3
47
48   # do some port sweeping to see that load balancing works
49   ip netns exec vppns1 nc -n -z "${2}" 1-1000 > /dev/null 2>&1
50
51   # check that it works
52   pkts=$(echo "show int" | nc 0 5002 | grep host-intervpp11 | awk '{print $6}' | tr -d '\r')
53
54   if [ $pkts -gt 450 ] && [ $pkts -lt 550 ] ; then
55     rc=0
56   else
57     rc=1
58   fi
59
60   if [ $rc -ne 0 ] ; then
61     echo "Load balancing doesn't work!"
62
63     maybe_pause $3
64
65     multihoming_topo_clean
66     exit $test_result
67   fi
68
69   maybe_pause $3
70
71   # change IP addresses of destination RLOC
72   echo "set int ip address del host-intervpp12 6.0.3.2/24" | nc 0 5003
73   echo "set int ip address host-intervpp12 6.0.3.20/24" | nc 0 5003
74   echo "set int ip address del host-intervpp12 6:0:3::2/64" | nc 0 5003
75   echo "set int ip address host-intervpp12 6:0:3::20/64" | nc 0 5003
76   post_curl "update-mapping" ${ODL_CONFIG_FILE3}
77
78   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
79   rc=$?
80
81   # test done
82
83   maybe_pause $3
84
85   multihoming_topo_clean
86   if [ $rc -ne 0 ] ; then
87     echo "Test failed: No ICMP response received within specified timeout limit!"
88   else
89     echo "Test passed."
90     test_result=0
91   fi
92
93   exit $test_result
94 }