0575bb34dc479b26c7f9bc2560ef7a22d3e33b53
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / basic.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/2_node_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   2_node_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_basic
20 {
21   if [ "$3" != "no_setup" ] ; then
22     2_node_topo_setup
23   fi
24
25   maybe_pause
26   test_result=1
27
28   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
29   assert_rc_ok $? 2_node_topo_clean "No ICMP response!"
30
31   maybe_pause
32   # change IP addresses of destination RLOC
33   echo "set int ip address del host-intervpp2 6.0.3.2/24" | nc 0 5003
34   echo "set int ip address host-intervpp2 6.0.3.20/24" | nc 0 5003
35   echo "set int ip address del host-intervpp2 6:0:3::2/64" | nc 0 5003
36   echo "set int ip address host-intervpp2 6:0:3::20/64" | nc 0 5003
37   post_curl "update-mapping" ${ODL_CONFIG_FILE3}
38
39   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
40   rc=$?
41
42   # test done
43
44   maybe_pause
45   2_node_topo_clean
46   print_status $rc "No ICMP response!"
47   exit $test_result
48 }
49
50 function test_basic_map_register_fallback
51 {
52   2_node_topo_setup no_odl
53
54   maybe_pause
55
56   test_result=1
57
58   start_map_server "6.0.3.200"
59
60   wait_for_map_register=20
61   echo "Waiting for map registration $wait_for_map_register seconds .."
62   sleep $wait_for_map_register
63
64   rc=1
65
66   count="`echo "show error" | nc 0 5002 | grep 'map-notifies received' | awk '{print $1}'`"
67   if [ "$count" != "" ] ; then
68     if [ $count -gt 0 ] ; then
69       echo "no map-notifies received! ($count)"
70       rc=0 # test passed
71     fi
72   fi
73
74   maybe_pause
75   kill $ms_id
76
77   # test done
78   2_node_topo_clean no_odl
79   print_status $rc "map server fallback does not work!"
80   exit $test_result
81 }
82
83 function test_basic_map_register
84 {
85   2_node_topo_setup no_odl
86   post_curl "add-key" ${ODL_CONFIG_FILE1}
87   post_curl "add-key" ${ODL_CONFIG_FILE2}
88
89   maybe_pause
90
91   test_result=1
92
93   wait_for_map_register=10
94   echo "Waiting for map registration $wait_for_map_register seconds .."
95   sleep $wait_for_map_register
96
97   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
98   rc=$?
99
100   count=`echo "show error" | nc 0 5002 | grep 'map-notifies received' | awk '{print $1}'`
101   if [ "$count" -eq 0 ] ; then
102     echo "no map-notifies received! ($count)"
103     rc=1
104   fi
105
106   maybe_pause
107
108   # test done
109   2_node_topo_clean
110   print_status $rc "No ICMP response!"
111   exit $test_result
112 }
113
114 function test_rloc_probe
115 {
116   2_node_topo_setup
117
118   maybe_pause
119   test_result=1
120
121   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
122   rc=$?
123   assert_rc_ok $rc 2_node_topo_clean "No ICMP response!"
124
125   sleep 65
126
127   count=`echo "show error" | nc 0 5002 | grep 'rloc-probe replies received' | awk '{print $1}'`
128   if [ "$count" != "1" ] ; then
129     echo "rloc-probe replies received is not 1! ($count)"
130     rc=1
131   fi
132
133   count=`echo "show error" | nc 0 5003 | grep 'rloc-probe requests received' | awk '{print $1}'`
134   if [ "$count" != "1" ] ; then
135     echo "rloc-probe requests received is not 1! ($count)"
136     rc=1
137   fi
138
139   # test done
140
141   maybe_pause
142   2_node_topo_clean
143   print_status $rc "unexpected value"
144   exit $test_result
145 }
146
147 function test_enable_disable
148 {
149   if [ "$3" != "no_setup" ] ; then
150     2_node_topo_setup
151   fi
152
153   maybe_pause
154   test_result=1
155
156   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
157   assert_rc_ok $? 2_node_topo_clean "No ICMP response!"
158
159   maybe_pause
160
161   # disable control plane
162   echo "one disable" | nc 0 5002
163   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
164   assert_rc_not_ok $? 2_node_topo_clean "Nothing expected, but received ICMP reply!"
165
166   # enable control plane
167   echo "one enable" | nc 0 5002
168   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
169   assert_rc_ok $? 2_node_topo_clean "No ICMP response!"
170
171   # disable dataplane
172   echo "gpe disable" | nc 0 5002
173   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
174   assert_rc_not_ok $? 2_node_topo_clean "Nothing expected, but received ICMP reply!"
175
176   # enable LISP again from control plane
177   echo "one enable" | nc 0 5002
178   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
179   assert_rc_ok $? 2_node_topo_clean "No ICMP response!"
180   rc=$?
181
182   # test done
183   maybe_pause
184   2_node_topo_clean
185   print_status $rc "No ICMP response!"
186   exit $test_result
187 }