CSIT-465: Common test setup and teardown
[csit.git] / tests / func / gre / gre_encapsulation.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Resource | resources/libraries/robot/default.robot
16 | Resource | resources/libraries/robot/testing_path.robot
17 | Resource | resources/libraries/robot/ipv4.robot
18 | Resource | resources/libraries/robot/gre.robot
19 | Resource | resources/libraries/robot/traffic.robot
20 | Library  | resources.libraries.python.IPUtil
21 | Library  | resources.libraries.python.Trace
22 | Force Tags | VM_ENV | HW_ENV
23 | Test Setup | Func Test Setup
24 | Test Teardown | Func Test Teardown
25 | Documentation | *GREoIPv4 test cases*
26 | ...
27 | ... | *[Top] Network Topologies:* TG=DUT1 2-node topology with two links
28 | ... | between nodes; TG-DUT1-DUT2-TG 3-node circular topology with single
29 | ... | links between nodes.
30 | ... | *[Enc] Packet Encapsulations:* Eth-IPv4-GRE-IPv4-ICMPv4 on DUT1-DUT2,
31 | ... | Eth-IPv4-ICMPv4 on TG-DUTn for routing over GRE tunnel; Eth-IPv4-ICMPv4
32 | ... | on TG_if1-DUT, Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT for GREoIPv4
33 | ... | encapsulation and decapsulation verification.
34 | ... | *[Cfg] DUT configuration:* DUT1 and DUT2 are configured with IPv4 routing
35 | ... | and static routes. GREoIPv4 tunnel is configured between DUT1 and DUT2.
36 | ... | *[Ver] TG verification:* Test ICMPv4 (or ICMPv6) Echo Request packets are
37 | ... | sent in both directions by TG on links to DUT1 and DUT2; GREoIPv4
38 | ... | encapsulation and decapsulation are verified separately by TG; on
39 | ... | receive TG verifies packets for correctness and their IPv4 (IPv6)
40 | ... | src-addr, dst-addr and MAC addresses.
41 | ... | *[Ref] Applicable standard specifications:* RFC2784.
42
43 *** Variables ***
44 | ${net1_address}= | 192.168.0.0
45 | ${net1_host_address}= | 192.168.0.100
46 | ${net1_gw_address}= | 192.168.0.1
47 | ${net2_address}= | 192.168.2.0
48 | ${net2_host_address}= | 192.168.2.100
49 | ${net3_address}= | 192.168.3.0
50 | ${net3_host_address}= | 192.168.3.100
51 | ${net2_gw_address}= | 192.168.2.1
52 | ${dut1_ip_address}= | 192.168.1.1
53 | ${dut2_ip_address}= | 192.168.1.2
54 | ${dut1_gre_ip}= | 172.16.0.1
55 | ${dut2_gre_ip}= | 172.16.0.2
56 | ${dut_tun0_ip1}= | 172.16.0.1
57 | ${dut_tun0_ip2}= | 172.16.0.2
58 | ${dut_tun1_ip1}= | 172.16.1.1
59 | ${dut_tun1_ip2}= | 172.16.1.2
60 | ${dut1_lo_address}= | 10.0.0.1
61 | ${tun0_dst}= | 10.0.0.2
62 | ${tun1_dst}= | 10.0.0.3
63 | ${prefix}= | 24
64
65 *** Test Cases ***
66 | TC01: DUT1 and DUT2 route over GREoIPv4 tunnel between two TG links
67 | | [Documentation]
68 | | ... | [Top] TG-DUT1-DUT2-TG. [Enc] Eth-IPv4-GRE-IPv4-ICMPv4 on \
69 | | ... | DUT1-DUT2, Eth-IPv4-ICMPv4 on TG-DUTn. [Cfg] On DUT1 and DUT2
70 | | ... | configure GREoIPv4 tunnel with IPv4 routes towards each other.
71 | | ... | [Ver] Make TG send ICMPv4 Echo Req between its interfaces across
72 | | ... | both DUTs and GRE tunnel between them; verify IPv4 headers on
73 | | ... | received packets are correct. [Ref] RFC2784.
74 | | [Tags] | 3_NODE_SINGLE_LINK_TOPO | 3_NODE_DOUBLE_LINK_TOPO
75 | | Given Path for 3-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
76 | | ... | ${nodes['DUT2']} | ${nodes['TG']}
77 | | And Interfaces in 3-node path are up
78 | | And IP addresses are set on interfaces
79 | | ... | ${dut1_node} | ${dut1_to_dut2} | ${dut1_ip_address} | ${prefix}
80 | | ... | ${dut1_node} | ${dut1_to_tg}   | ${net1_gw_address} | ${prefix}
81 | | ... | ${dut2_node} | ${dut2_to_dut1} | ${dut2_ip_address} | ${prefix}
82 | | ... | ${dut2_node} | ${dut2_to_tg}   | ${net2_gw_address} | ${prefix}
83 | | And VPP IP Probe | ${dut1_node} | ${dut1_to_dut2} | ${dut2_ip_address}
84 | | And VPP IP Probe | ${dut2_node} | ${dut2_to_dut1} | ${dut1_ip_address}
85 | | And Add Arp On Dut | ${dut2_node} | ${dut2_to_tg} | ${net2_host_address}
86 | | ... | ${tg_to_dut2_mac}
87 | | ${dut1_gre_interface} | ${dut1_gre_index}=
88 | | ... | When GRE tunnel interface is created and up
89 | | ... | ${dut1_node} | ${dut1_ip_address} | ${dut2_ip_address}
90 | | ${dut2_gre_interface} | ${dut2_gre_index}=
91 | | ... | And  GRE tunnel interface is created and up
92 | | ... | ${dut2_node} | ${dut2_ip_address} | ${dut1_ip_address}
93 | | And IP addresses are set on interfaces
94 | | ... | ${dut1_node} | ${dut1_gre_index} | ${dut1_gre_ip} | ${prefix}
95 | | ... | ${dut2_node} | ${dut2_gre_index} | ${dut2_gre_ip} | ${prefix}
96 | | And Vpp Route Add | ${dut1_node} | ${net2_address} | ${prefix}
97 | | ... | ${dut2_gre_ip} | ${dut1_gre_index}
98 | | Then Send Packet And Check Headers | ${tg_node}
99 | | ... | ${net1_host_address} | ${net2_host_address}
100 | | ... | ${tg_to_dut1} | ${tg_to_dut1_mac} | ${dut1_to_tg_mac}
101 | | ... | ${tg_to_dut2} | ${dut2_to_tg_mac} | ${tg_to_dut2_mac}
102
103 | TC02: DUT encapsulates IPv4 into GREoIPv4 tunnel - GRE header verification
104 | | [Documentation]
105 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
106 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure
107 | | ... | GREoIPv4 tunnel with IPv4 route towards TG. [Ver] Make TG send
108 | | ... | non-encapsulated ICMPv4 Echo Req to DUT; verify TG received
109 | | ... | GREoIPv4 encapsulated packet is correct. [Ref] RFC2784.
110 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
111 | | Given Path for 2-node testing is set
112 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
113 | | And Interfaces in 2-node path are up
114 | | And IP addresses are set on interfaces
115 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
116 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
117 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
118 | | ... | ${tg_to_dut_if2_mac}
119 | | ${dut1_gre_interface} | ${dut1_gre_index}=
120 | | ... | When GRE tunnel interface is created and up
121 | | ... | ${dut_node} | ${dut1_ip_address} | ${dut2_ip_address}
122 | | And IP addresses are set on interfaces
123 | | ... | ${dut_node} | ${dut1_gre_index} | ${dut1_gre_ip} | ${prefix}
124 | | And Vpp Route Add | ${dut_node} | ${net2_address} | ${prefix}
125 | | ... | ${dut2_gre_ip} | ${dut1_gre_index}
126 | | Then Send ICMPv4 and check received GRE header
127 | | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
128 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if2_mac}
129 | | ... | ${net1_host_address} | ${net2_host_address}
130 | | ... | ${dut1_ip_address} | ${dut2_ip_address}
131
132 | TC03: DUT decapsulates IPv4 from GREoIPv4 tunnel - IPv4 header verification
133 | | [Documentation]
134 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
135 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure
136 | | ... | GREoIPv4 tunnel towards TG. [Ver] Make TG send ICMPv4 Echo Req
137 | | ... | encapsulated into GREoIPv4 towards VPP; verify TG received IPv4
138 | | ... | de-encapsulated packet is correct. [Ref] RFC2784.
139 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
140 | | Given Path for 2-node testing is set
141 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
142 | | And Interfaces in 2-node path are up
143 | | And IP addresses are set on interfaces
144 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
145 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
146 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} | ${net1_host_address}
147 | | ... | ${tg_to_dut_if1_mac}
148 | | ${dut1_gre_interface} | ${dut1_gre_index}=
149 | | ... | When GRE tunnel interface is created and up
150 | | ... | ${dut_node} | ${dut1_ip_address} | ${dut2_ip_address}
151 | | And IP addresses are set on interfaces
152 | | ... | ${dut_node} | ${dut1_gre_index} | ${dut1_gre_ip} | ${prefix}
153 | | Then Send GRE and check received ICMPv4 header
154 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1}
155 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if1_mac}
156 | | ... | ${net2_host_address} | ${net1_host_address}
157 | | ... | ${dut2_ip_address} | ${dut1_ip_address}
158
159 | TC04: DUT encapsulates IPv4 into GREoIPv4 different tunnels - GRE header verification
160 | | [Documentation]
161 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
162 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure two
163 | | ... | GRE tunnels with loopback's source address. Destination address of
164 | | ... | tunnels are routed via next hop address of DUT's to TG if2, where
165 | | ... | should be only GRE encapsulated packets. Each tunnel has IPv4 address
166 | | ... | and configured prefix routed through the tunnel. [Ver] Make TG send
167 | | ... | non-encapsulated ICMPv4 Echo Req to DUT; verify TG received GREoIPv4
168 | | ... | encapsulated packet is correct for each tunnel. [Ref] RFC2784.
169 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
170 | | Given Path for 2-node testing is set
171 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
172 | | And Interfaces in 2-node path are up
173 | | ${dut1_lo_index}= | And VPP Create loopback | ${dut_node}
174 | | And Set Interface State |  ${dut_node} | ${dut1_lo_index} | up
175 | | And IP addresses are set on interfaces
176 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
177 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
178 | | ... | ${dut_node} | ${dut1_lo_index} | ${dut1_lo_address} | ${32}
179 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
180 | | ... | ${tg_to_dut_if2_mac}
181 | | And Vpp Route Add | ${dut_node} | ${tun0_dst} | ${32}
182 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
183 | | And Vpp Route Add | ${dut_node} | ${tun1_dst} | ${32}
184 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
185 | | ${dut1_gre0_interface} | ${dut1_gre0_index}=
186 | | ... | When GRE tunnel interface is created and up
187 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun0_dst}
188 | | ${dut1_gre1_interface} | ${dut1_gre1_index}=
189 | | ... | And GRE tunnel interface is created and up
190 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun1_dst}
191 | | And IP addresses are set on interfaces
192 | | ... | ${dut_node} | ${dut1_gre0_index} | ${dut_tun0_ip1} | ${prefix}
193 | | ... | ${dut_node} | ${dut1_gre1_index} | ${dut_tun1_ip1} | ${prefix}
194 | | And Vpp Route Add | ${dut_node} | ${net2_address} | ${prefix}
195 | |  ... | ${dut_tun0_ip2} | ${dut1_gre0_index}
196 | | And Vpp Route Add | ${dut_node} | ${net3_address} | ${prefix}
197 | | ... | ${dut_tun1_ip2} | ${dut1_gre1_index}
198 | | Then Send ICMPv4 and check received GRE header
199 | | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
200 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if2_mac}
201 | | ... | ${net1_host_address} | ${net2_host_address}
202 | | ... | ${dut1_lo_address} | ${tun0_dst}
203 | | And Send ICMPv4 and check received GRE header
204 | | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
205 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if2_mac}
206 | | ... | ${net1_host_address} | ${net3_host_address}
207 | | ... | ${dut1_lo_address} | ${tun1_dst}
208
209 | TC05: DUT re-encapsulates IPv4 GRE into other GRE tunnel - GRE header verification
210 | | [Documentation]
211 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
212 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure two
213 | | ... | GRE tunnels with loopback's source address. Destination address of
214 | | ... | tunnels are routed via next hop address of DUT's to TG if2, where
215 | | ... | should be only GRE encapsulated packets. Each tunnel has IPv4 address
216 | | ... | and configured prefix routed through the tunnel. [Ver] Make TG send
217 | | ... | encapsulated IPv4 UDP to DUT; Encapsulated IP source is behind
218 | | ... | configured tunnel same as destination; verify TG received GREoIPv4
219 | | ... | encapsulated packet is correct. [Ref] RFC2784.
220 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
221 | | Given Path for 2-node testing is set
222 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
223 | | And Interfaces in 2-node path are up
224 | | ${dut1_lo_index}= | And VPP Create loopback | ${dut_node}
225 | | And Set Interface State |  ${dut_node} | ${dut1_lo_index} | up
226 | | And IP addresses are set on interfaces
227 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
228 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
229 | | ... | ${dut_node} | ${dut1_lo_index} | ${dut1_lo_address} | ${32}
230 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
231 | | ... | ${tg_to_dut_if2_mac}
232 | | And Vpp Route Add | ${dut_node} | ${tun0_dst} | ${32}
233 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
234 | | And Vpp Route Add | ${dut_node} | ${tun1_dst} | ${32}
235 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
236 | | ${dut1_gre0_interface} | ${dut1_gre0_index}=
237 | | ... | When GRE tunnel interface is created and up
238 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun0_dst}
239 | | ${dut1_gre1_interface} | ${dut1_gre1_index}=
240 | | ... | And GRE tunnel interface is created and up
241 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun1_dst}
242 | | And IP addresses are set on interfaces
243 | | ... | ${dut_node} | ${dut1_gre0_index} | ${dut_tun0_ip1} | ${prefix}
244 | | ... | ${dut_node} | ${dut1_gre1_index} | ${dut_tun1_ip1} | ${prefix}
245 | | And Vpp Route Add | ${dut_node} | ${net2_address} | ${prefix}
246 | |  ... | ${dut_tun0_ip2} | ${dut1_gre0_index}
247 | | And Vpp Route Add | ${dut_node} | ${net3_address} | ${prefix}
248 | | ... | ${dut_tun1_ip2} | ${dut1_gre1_index}
249 | | Then Send GRE and check received GRE header
250 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if2}
251 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if2_mac}
252 | | ... | ${dut1_lo_address} | ${tun0_dst}
253 | | ... | ${net3_host_address} | ${net2_host_address}
254 | | ... | ${tg_to_dut_if2_mac} | ${dut_to_tg_if2_mac}
255 | | ... | ${tun1_dst} | ${dut1_lo_address}
256
257 | TC06: DUT do not process GRE with wrong tunnel destination IP
258 | | [Documentation]
259 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
260 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure two
261 | | ... | GRE tunnels with loopback's source address. Destination address of
262 | | ... | tunnels are routed via next hop address of DUT's to TG if2, where
263 | | ... | should be only GRE encapsulated packets. On DUT's to TG if1 interface
264 | | ... | is configured test destination host MAC address. [Ver] Make TG send
265 | | ... | GRE encapsulated ICMPv4 Echo Req to DUT; verify TG received
266 | | ... | de-capsulated packet is correct, then send packet with wrong tunnel
267 | | ... | destination address. [Ref] RFC2784.
268 | | ... |
269 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
270 | | Given Path for 2-node testing is set
271 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
272 | | And Interfaces in 2-node path are up
273 | | ${dut1_lo_index}= | And VPP Create loopback | ${dut_node}
274 | | And Set Interface State |  ${dut_node} | ${dut1_lo_index} | up
275 | | And IP addresses are set on interfaces
276 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
277 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
278 | | ... | ${dut_node} | ${dut1_lo_index} | ${dut1_lo_address} | ${32}
279 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} | ${net1_host_address}
280 | | ... | ${tg_to_dut_if1_mac}
281 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
282 | | ... | ${tg_to_dut_if2_mac}
283 | | And Vpp Route Add | ${dut_node} | ${tun0_dst} | ${32}
284 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
285 | | And Vpp Route Add | ${dut_node} | ${tun1_dst} | ${32}
286 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
287 | | ${dut1_gre0_interface} | ${dut1_gre0_index}=
288 | | ... | When GRE tunnel interface is created and up
289 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun0_dst}
290 | | ${dut1_gre1_interface} | ${dut1_gre1_index}=
291 | | ... | And GRE tunnel interface is created and up
292 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun1_dst}
293 | | And IP addresses are set on interfaces
294 | | ... | ${dut_node} | ${dut1_gre0_index} | ${dut_tun0_ip1} | ${prefix}
295 | | ... | ${dut_node} | ${dut1_gre1_index} | ${dut_tun1_ip1} | ${prefix}
296 | | Then Send GRE and check received ICMPv4 header
297 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1}
298 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if1_mac}
299 | | ... | ${net2_host_address} | ${net1_host_address}
300 | | ... | ${tun0_dst} | ${dut1_lo_address}
301 | | And Run Keyword And Expect Error | ICMP echo Rx timeout
302 | | ... | Send GRE and check received ICMPv4 header |
303 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1}
304 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if1_mac}
305 | | ... | ${net2_host_address} | ${net1_host_address}
306 | | ... | ${tun0_dst} | ${dut1_ip_address}