e123cc82b7c95b14ac057747ace53d0a500c0813
[csit.git] / tests / func / tap / tap_interface.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/ipv4.robot
17 | Resource | resources/libraries/robot/ipv6.robot
18 | Resource | resources/libraries/robot/interfaces.robot
19 | Resource | resources/libraries/robot/bridge_domain.robot
20 | Resource | resources/libraries/robot/testing_path.robot
21 | Resource | resources/libraries/robot/traffic.robot
22 | Library  | resources.libraries.python.Trace
23 | Library  | resources.libraries.python.Tap
24 | Library  | resources.libraries.python.Namespaces
25 | Library  | resources.libraries.python.IPUtil
26 | Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
27 | Test Setup | Run Keywords | Setup all DUTs before test
28 | ...        | AND          | Setup all TGs before traffic script
29 | ...        | AND          | Clean Up Namespaces | ${nodes['DUT1']}
30 | Test Teardown | Run Keywords | Show Packet Trace on All DUTs | ${nodes}
31 | ...        | AND          | Clean Up Namespaces | ${nodes['DUT1']}
32 | Documentation | *Tap Interface Traffic Tests*
33 | ... | *[Top] Network Topologies:* TG=DUT1 2-node topology with two links
34 | ... | between nodes.
35 | ... | *[Enc] Packet Encapsulations:* Eth-IPv4-ICMPv4 for L2 switching of
36 | ... | IPv4.
37 | ... | *[Cfg] DUT configuration:* DUT1 and DUT2 are configured with L2
38 | ... | bridge-domain (L2BD) MAC learning enabled; Split Horizon Groups (SHG)
39 | ... | are set depending on test case; Namespaces (NM)
40 | ... | are set on DUT1 with attached linux-TAP.
41 | ... | *[Ver] TG verification:* Test ICMPv4 Echo Request packets
42 | ... | are sent by TG on link to DUT1; On receipt TG verifies packets
43 | ... | for correctness and their IPv4 src-addr, dst-addr, and MAC addresses.
44 | ... | *[Ref] Applicable standard specifications:*
45
46 *** Variables ***
47 | ${tap1_VPP_ip}= | 16.0.10.1
48 | ${tap2_VPP_ip}= | 16.0.20.1
49
50 | ${tap1_NM_ip}= | 16.0.10.2
51 | ${tap2_NM_ip}= | 16.0.20.2
52 | ${tap2_NM_SHG}= | 16.0.10.3
53
54 | ${bid_from_TG}= | 19
55 | ${bid_to_TG}= | 20
56 | ${bid_NM}= | container1_br
57 | ${bid_TAP}= | tapBr
58 | ${bd_id1}= | 21
59 | ${bd_id2}= | 22
60 | ${shg1}= | 2
61 | ${shg2}= | 3
62
63 | ${tap1_NM_mac}= | 02:00:00:00:00:02
64 | ${tap2_NM_mac}= | 02:00:00:00:00:04
65
66 | ${tap_int1}= | tap_int1
67 | ${tap_int2}= | tap_int2
68 | ${mod_tap_name}= | tap_int1MOD
69
70 | ${namespace1}= | nmspace1
71 | ${namespace2}= | nmspace2
72
73 | ${tg_ip_address}= | 192.168.0.2
74 | ${tg_ip_address_SHG}= | 16.0.10.20
75 | ${tg_ip_address_GW}= | 192.168.0.0
76
77 | ${prefix}= | 24
78
79 *** Test Cases ***
80 | TC01: Tap Interface Simple BD
81 | | [Documentation]
82 | | ... | [Top] TG-DUT1-TG.
83 | | ... | [Enc] Eth-IPv4-ICMPv4.
84 | | ... | [Cfg] On DUT1 configure two
85 | | ... | L2BD with two if's for each L2BD with MAC learning and one L2BD
86 | | ... | joining two linux-TAP interfaces created by VPP located in namespace.
87 | | ... | [Ver] Packet sent from TG is passed through all L2BD and received
88 | | ... | back on TG. Then src_ip, dst_ip and MAC are checked.
89 | | ...
90 | | [Teardown] | Run Keywords
91 | | ... | Linux Del Bridge | ${dut_node} | ${bid_TAP} | AND
92 | | ... | Show Packet Trace on All DUTs | ${nodes} | AND
93 | | ... | Clean Up Namespaces | ${nodes['DUT1']}
94 | | ...
95 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
96 | | ... | ${nodes['TG']}
97 | | And Interfaces in 2-node path are up
98 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
99 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
100 | | And Set Interface State | ${dut_node} | ${int1} | up
101 | | And Set Interface State | ${dut_node} | ${int2} | up
102 | | And Bridge domain on DUT node is created | ${dut_node}
103 | | ... | ${bid_from_TG} | learn=${TRUE}
104 | | And Bridge domain on DUT node is created | ${dut_node}
105 | | ... | ${bid_to_TG} | learn=${TRUE}
106 | | And Linux Add Bridge | ${dut_node}
107 | | ... | ${bid_TAP} | ${tap_int1} | ${tap_int2}
108 | | And Interface is added to bridge domain | ${dut_node}
109 | | ... | ${int1} | ${bid_to_TG} | 0
110 | | And Interface is added to bridge domain | ${dut_node}
111 | | ... | ${dut_to_tg_if1} | ${bid_to_TG} | 0
112 | | And Interface is added to bridge domain | ${dut_node}
113 | | ... | ${int2} | ${bid_from_TG} | 0
114 | | And Interface is added to bridge domain | ${dut_node}
115 | | ... | ${dut_to_tg_if2} | ${bid_from_TG} | 0
116 | | Then Send and receive ICMP Packet | ${tg_node}
117 | | ... | ${tg_to_dut_if1} | ${tg_to_dut_if2}
118
119 | TC02: Tap Interface IP Ping Without Namespace
120 | | [Documentation]
121 | | ... | [Top] TG-DUT1-TG.
122 | | ... | [Enc] Eth-IPv4-ICMPv4.
123 | | ... | [Cfg] On DUT1 configure two interface addresses with IPv4 of which
124 | | ... | one is TAP interface ( dut_to_tg_if and TAP ).
125 | | ... | and one is linux-TAP.
126 | | ... | [Ver] Packet sent from TG gets to the destination and ICMP-reply is
127 | | ... | received on TG.
128 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
129 | | ... | ${nodes['TG']}
130 | | And Interfaces in 2-node path are up
131 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} |
132 | | And Set Interface Address
133 | | ... | ${dut_node} | ${int1} | ${tap1_VPP_ip} | ${prefix}
134 | | And Set Interface State | ${dut_node} | ${int1} | up
135 | | And Set Linux Interface MAC | ${dut_node} | ${tap_int1} | ${tap1_NM_mac}
136 | | And Set Linux Interface IP | ${dut_node}
137 | | ... | ${tap_int1} | ${tap1_NM_ip} | ${prefix}
138 | | And Add Route | ${dut_node}
139 | | ... | ${tg_ip_address_GW} | ${prefix} | ${tap1_VPP_ip}
140 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1}
141 | | ... | ${tg_ip_address} | ${tg_to_dut_if1_mac}
142 | | And Add Arp On Dut | ${dut_node} | ${int1}
143 | | ... | ${tap1_NM_ip} | ${tap1_NM_mac}
144 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
145 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac}
146 | | ... | ${tap1_NM_ip} | ${tg_ip_address}
147
148 | TC03: Tap Interface IP Ping With Namespace
149 | | [Documentation]
150 | | ... | [Top] TG-DUT1-TG.
151 | | ... | [Enc] Eth-IPv4-ICMPv4.
152 | | ... | [Cfg] On DUT1 configure two interface addresses with IPv4 of which
153 | | ... | one is TAP interface ( dut_to_tg_if and TAP ).
154 | | ... | and one is linux-TAP in namespace.
155 | | ... | [Ver] Packet sent from TG gets to the destination and ICMP-reply is
156 | | ... | received on TG.
157 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
158 | | ... | ${nodes['TG']}
159 | | And Interfaces in 2-node path are up
160 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} |
161 | | And Set Interface Address
162 | | ... | ${dut_node} | ${int1} | ${tap1_VPP_ip} | ${prefix}
163 | | And Set Interface State | ${dut_node} | ${int1} | up
164 | | When Create Namespace | ${dut_node} | ${namespace1}
165 | | And Attach Interface To Namespace | ${dut_node}
166 | | ... | ${namespace1} | ${tap_int1}
167 | | And Set Linux Interface MAC | ${dut_node}
168 | | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1}
169 | | And Set Linux Interface IP | ${dut_node}
170 | | ... | ${tap_int1} | ${tap1_NM_ip} | ${prefix} | ${namespace1}
171 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1}
172 | | ... | ${tg_ip_address} | ${tg_to_dut_if1_mac}
173 | | And Add Arp On Dut | ${dut_node} | ${int1}
174 | | ... | ${tap1_NM_ip} | ${tap1_NM_mac}
175 | | And Add Route | ${dut_node}
176 | | ... | ${tg_ip_address_GW} | ${prefix} | ${tap1_VPP_ip} | ${namespace1}
177 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
178 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac}
179 | | ... | ${tap1_NM_ip} | ${tg_ip_address}
180
181 | TC04: Tap Interface BD - Different Split Horizon
182 | | [Documentation]
183 | | ... | [Top] TG-DUT1-TG.
184 | | ... | [Enc] Eth-IPv4-ICMPv4.
185 | | ... | [Cfg] On DUT1
186 | | ... | configure one if into L2BD with MAC learning. Add two TAP interfaces
187 | | ... | into this L2BD and assign them different SHG. Setup two namespaces
188 | | ... | and assign two linux-TAP interfaces to it respectively.
189 | | ... | [Ver] Packet is sent from TG to both linux-TAP interfaces and reply
190 | | ... | is checked. Ping from First linux-TAP to another should pass.
191 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
192 | | ... | ${nodes['TG']}
193 | | And Interfaces in 2-node path are up
194 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
195 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
196 | | And Set Interface State | ${dut_node} | ${int1} | up
197 | | And Set Interface State | ${dut_node} | ${int2} | up
198 | | When Create Namespace | ${dut_node} | ${namespace1}
199 | | And Attach Interface To Namespace | ${dut_node}
200 | | ... | ${namespace1} | ${tap_int1}
201 | | And Create Namespace | ${dut_node} | ${namespace2}
202 | | And Attach Interface To Namespace | ${dut_node}
203 | | ... | ${namespace2} | ${tap_int2}
204 | | And Set Linux Interface IP | ${dut_node} | ${tap_int1}
205 | | ... | ${tap1_NM_ip} | ${prefix} | ${namespace1}
206 | | And Set Linux Interface IP | ${dut_node} | ${tap_int2}
207 | | ... | ${tap2_NM_SHG} | ${prefix} | ${namespace2}
208 | | And Set Linux Interface MAC | ${dut_node}
209 | | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1}
210 | | And Set Linux Interface MAC | ${dut_node}
211 | | ... | ${tap_int2} | ${tap2_NM_mac} | ${namespace2}
212 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int1}
213 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace1}
214 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int2}
215 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace2}
216 | | And Bridge domain on DUT node is created | ${dut_node}
217 | | ... | ${bd_id1} | learn=${TRUE}
218 | | And Interface is added to bridge domain | ${dut_node} | ${dut_to_tg_if1}
219 | | ...                                     | ${bd_id1}
220 | | And Interface is added to bridge domain | ${dut_node} | ${int1}
221 | | ...                                     | ${bd_id1} | ${shg1}
222 | | And Interface is added to bridge domain | ${dut_node} | ${int2}
223 | | ...                                     | ${bd_id1} | ${shg2}
224 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
225 | | ... | ${tap1_NM_mac} | ${tg_to_dut_if1_mac}
226 | | ... | ${tap1_NM_ip} | ${tg_ip_address_SHG}
227 | | And Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
228 | | ... | ${tap2_NM_mac} | ${tg_to_dut_if1_mac}
229 | | ... | ${tap2_NM_SHG} | ${tg_ip_address_SHG}
230 | | And Send Ping From Node To Dst | ${dut_node} | ${tap1_NM_ip} | namespace=${namespace2}
231 | | And Send Ping From Node To Dst | ${dut_node} | ${tap2_NM_SHG} | namespace=${namespace1}
232
233 | TC05: Tap Interface BD - Same Split Horizon
234 | | [Documentation]
235 | | ... | [Top] TG-DUT1-TG.
236 | | ... | [Enc] Eth-IPv4-ICMPv4.
237 | | ... | [Cfg] On DUT1
238 | | ... | configure one if into L2BD with MAC learning. Add two TAP interfaces
239 | | ... | into this L2BD and assign them same SHG. Setup two namespaces
240 | | ... | and assign two linux-TAP interfaces to it respectively.
241 | | ... | [Ver] Packet is sent from TG to both linux-TAP interfaces and reply
242 | | ... | is checked. Ping from First linux-TAP to another should fail.
243 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
244 | | ... | ${nodes['TG']}
245 | | And Interfaces in 2-node path are up
246 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
247 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
248 | | And Set Interface State | ${dut_node} | ${int1} | up
249 | | And Set Interface State | ${dut_node} | ${int2} | up
250 | | When Create Namespace | ${dut_node} | ${namespace1}
251 | | And Attach Interface To Namespace | ${dut_node}
252 | | ... | ${namespace1} | ${tap_int1}
253 | | And Create Namespace | ${dut_node} | ${namespace2}
254 | | And Attach Interface To Namespace | ${dut_node}
255 | | ... | ${namespace2} | ${tap_int2}
256 | | And Set Linux Interface IP | ${dut_node} | ${tap_int1}
257 | | ... | ${tap1_NM_ip} | ${prefix} | ${namespace1}
258 | | And Set Linux Interface IP | ${dut_node} | ${tap_int2}
259 | | ... | ${tap2_NM_SHG} | ${prefix} | ${namespace2}
260 | | And Set Linux Interface MAC | ${dut_node}
261 | | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1}
262 | | And Set Linux Interface MAC | ${dut_node}
263 | | ... | ${tap_int2} | ${tap2_NM_mac} | ${namespace2}
264 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int1}
265 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace1}
266 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int2}
267 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace2}
268 | | And Bridge domain on DUT node is created | ${dut_node}
269 | | ... | ${bd_id1} | learn=${TRUE}
270 | | And Interface is added to bridge domain | ${dut_node} | ${dut_to_tg_if1}
271 | | ...                                     | ${bd_id1}
272 | | And Interface is added to bridge domain | ${dut_node} | ${int1}
273 | | ...                                     | ${bd_id1} | ${shg1}
274 | | And Interface is added to bridge domain | ${dut_node} | ${int2}
275 | | ...                                     | ${bd_id1} | ${shg1}
276 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
277 | | ... | ${tap1_NM_mac} | ${tg_to_dut_if1_mac}
278 | | ... | ${tap1_NM_ip} | ${tg_ip_address_SHG}
279 | | And Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
280 | | ... | ${tap2_NM_mac} | ${tg_to_dut_if1_mac}
281 | | ... | ${tap2_NM_SHG} | ${tg_ip_address_SHG}
282 | | And Run Keyword And Expect Error | Ping Not Successful | Send Ping From Node To Dst
283 | | ... | ${dut_node} | ${tap2_NM_SHG} | namespace=${namespace1}
284 | | And Run Keyword And Expect Error | Ping Not Successful | Send Ping From Node To Dst
285 | | ... | ${dut_node} | ${tap1_NM_ip} | namespace=${namespace2}
286
287 | TC06: Tap Interface Modify And Delete
288 | | [Documentation]
289 | | ... | [Top] TG-DUT1-TG.
290 | | ... | [Enc] Eth-IPv4-ICMPv4.
291 | | ... | [Cfg] Set two TAP interfaces.
292 | | ... | [Ver] Verify that TAP interface can be modified, deleted, and no other
293 | | ... | TAP interface is affected.
294 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
295 | | ... | ${nodes['TG']}
296 | | And Interfaces in 2-node path are up
297 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
298 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
299 | | And Set Interface State | ${dut_node} | ${int1} | up
300 | | And Set Interface State | ${dut_node} | ${int2} | up
301 | | When Modify Tap Interface | ${dut_node} | ${int1} | ${mod_tap_name}
302 | | Then Check Tap Present | ${dut_node} | ${mod_tap_name}
303 | | When Delete Tap Interface | ${dut_node} | ${int1}
304 | | Then Run Keyword And Expect Error
305 | | ... | Tap interface :${mod_tap_name} does not exist
306 | | ... | Check Tap Present | ${dut_node} | ${mod_tap_name}
307 | | And Check Tap Present | ${dut_node} | ${tap_int2}
308 | | When Delete Tap Interface | ${dut_node} | ${int2}
309 | | Then Run Keyword And Expect Error
310 | | ... | ValueError: No JSON object could be decoded
311 | | ... | Check Tap Present | ${dut_node} | ${tap_int2}