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