CSIT-158: Tap interface tests
[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 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
90 | | ... | ${nodes['TG']}
91 | | And Interfaces in 2-node path are up
92 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
93 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
94 | | And Set Interface State | ${dut_node} | ${int1} | up
95 | | And Set Interface State | ${dut_node} | ${int2} | up
96 | | And Bridge domain on DUT node is created | ${dut_node}
97 | | ... | ${bid_from_TG} | learn=${TRUE}
98 | | And Bridge domain on DUT node is created | ${dut_node}
99 | | ... | ${bid_to_TG} | learn=${TRUE}
100 | | And Linux Add Bridge | ${dut_node}
101 | | ... | ${bid_TAP} | ${tap_int1} | ${tap_int2}
102 | | And Interface is added to bridge domain | ${dut_node}
103 | | ... | ${int1} | ${bid_to_TG} | 0
104 | | And Interface is added to bridge domain | ${dut_node}
105 | | ... | ${dut_to_tg_if1} | ${bid_to_TG} | 0
106 | | And Interface is added to bridge domain | ${dut_node}
107 | | ... | ${int2} | ${bid_from_TG} | 0
108 | | And Interface is added to bridge domain | ${dut_node}
109 | | ... | ${dut_to_tg_if2} | ${bid_from_TG} | 0
110 | | Then Send and receive ICMP Packet | ${tg_node}
111 | | ... | ${tg_to_dut_if1} | ${tg_to_dut_if2}
112
113 | TC02: Tap Interface IP Ping Without Namespace
114 | | [Documentation]
115 | | ... | [Top] TG-DUT1-TG.
116 | | ... | [Enc] Eth-IPv4-ICMPv4.
117 | | ... | [Cfg] On DUT1 configure two interface addresses with IPv4 of which
118 | | ... | one is TAP interface ( dut_to_tg_if and TAP ).
119 | | ... | and one is linux-TAP.
120 | | ... | [Ver] Packet sent from TG gets to the destination and ICMP-reply is
121 | | ... | received on TG.
122 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
123 | | ... | ${nodes['TG']}
124 | | And Interfaces in 2-node path are up
125 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} |
126 | | And Set Interface Address
127 | | ... | ${dut_node} | ${int1} | ${tap1_VPP_ip} | ${prefix}
128 | | And Set Interface State | ${dut_node} | ${int1} | up
129 | | And Set Linux Interface MAC | ${dut_node} | ${tap_int1} | ${tap1_NM_mac}
130 | | And Set Linux Interface IP | ${dut_node}
131 | | ... | ${tap_int1} | ${tap1_NM_ip} | ${prefix}
132 | | And Add Route | ${dut_node}
133 | | ... | ${tg_ip_address_GW} | ${prefix} | ${tap1_VPP_ip}
134 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1}
135 | | ... | ${tg_ip_address} | ${tg_to_dut_if1_mac}
136 | | And Add Arp On Dut | ${dut_node} | ${int1}
137 | | ... | ${tap1_NM_ip} | ${tap1_NM_mac}
138 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
139 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac}
140 | | ... | ${tap1_NM_ip} | ${tg_ip_address}
141
142 | TC03: Tap Interface IP Ping With Namespace
143 | | [Documentation]
144 | | ... | [Top] TG-DUT1-TG.
145 | | ... | [Enc] Eth-IPv4-ICMPv4.
146 | | ... | [Cfg] On DUT1 configure two interface addresses with IPv4 of which
147 | | ... | one is TAP interface ( dut_to_tg_if and TAP ).
148 | | ... | and one is linux-TAP in namespace.
149 | | ... | [Ver] Packet sent from TG gets to the destination and ICMP-reply is
150 | | ... | received on TG.
151 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
152 | | ... | ${nodes['TG']}
153 | | And Interfaces in 2-node path are up
154 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} |
155 | | And Set Interface Address
156 | | ... | ${dut_node} | ${int1} | ${tap1_VPP_ip} | ${prefix}
157 | | And Set Interface State | ${dut_node} | ${int1} | up
158 | | When Create Namespace | ${dut_node} | ${namespace1}
159 | | And Attach Interface To Namespace | ${dut_node}
160 | | ... | ${namespace1} | ${tap_int1}
161 | | And Set Linux Interface MAC | ${dut_node}
162 | | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1}
163 | | And Set Linux Interface IP | ${dut_node}
164 | | ... | ${tap_int1} | ${tap1_NM_ip} | ${prefix} | ${namespace1}
165 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1}
166 | | ... | ${tg_ip_address} | ${tg_to_dut_if1_mac}
167 | | And Add Arp On Dut | ${dut_node} | ${int1}
168 | | ... | ${tap1_NM_ip} | ${tap1_NM_mac}
169 | | And Add Route | ${dut_node}
170 | | ... | ${tg_ip_address_GW} | ${prefix} | ${tap1_VPP_ip} | ${namespace1}
171 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
172 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac}
173 | | ... | ${tap1_NM_ip} | ${tg_ip_address}
174
175 | TC04: Tap Interface BD - Different Split Horizon
176 | | [Documentation]
177 | | ... | [Top] TG-DUT1-TG.
178 | | ... | [Enc] Eth-IPv4-ICMPv4.
179 | | ... | [Cfg] On DUT1
180 | | ... | configure one if into L2BD with MAC learning. Add two TAP interfaces
181 | | ... | into this L2BD and assign them different SHG. Setup two namespaces
182 | | ... | and assign two linux-TAP interfaces to it respectively.
183 | | ... | [Ver] Packet is sent from TG to both linux-TAP interfaces and reply
184 | | ... | is checked. Ping from First linux-TAP to another should pass.
185 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
186 | | ... | ${nodes['TG']}
187 | | And Interfaces in 2-node path are up
188 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
189 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
190 | | And Set Interface State | ${dut_node} | ${int1} | up
191 | | And Set Interface State | ${dut_node} | ${int2} | up
192 | | When Create Namespace | ${dut_node} | ${namespace1}
193 | | And Attach Interface To Namespace | ${dut_node}
194 | | ... | ${namespace1} | ${tap_int1}
195 | | And Create Namespace | ${dut_node} | ${namespace2}
196 | | And Attach Interface To Namespace | ${dut_node}
197 | | ... | ${namespace2} | ${tap_int2}
198 | | And Set Linux Interface IP | ${dut_node} | ${tap_int1}
199 | | ... | ${tap1_NM_ip} | ${prefix} | ${namespace1}
200 | | And Set Linux Interface IP | ${dut_node} | ${tap_int2}
201 | | ... | ${tap2_NM_SHG} | ${prefix} | ${namespace2}
202 | | And Set Linux Interface MAC | ${dut_node}
203 | | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1}
204 | | And Set Linux Interface MAC | ${dut_node}
205 | | ... | ${tap_int2} | ${tap2_NM_mac} | ${namespace2}
206 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int1}
207 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace1}
208 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int2}
209 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace2}
210 | | And Bridge domain on DUT node is created | ${dut_node}
211 | | ... | ${bd_id1} | learn=${TRUE}
212 | | And Interface is added to bridge domain | ${dut_node} | ${dut_to_tg_if1}
213 | | ...                                     | ${bd_id1}
214 | | And Interface is added to bridge domain | ${dut_node} | ${int1}
215 | | ...                                     | ${bd_id1} | ${shg1}
216 | | And Interface is added to bridge domain | ${dut_node} | ${int2}
217 | | ...                                     | ${bd_id1} | ${shg2}
218 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
219 | | ... | ${tap1_NM_mac} | ${tg_to_dut_if1_mac}
220 | | ... | ${tap1_NM_ip} | ${tg_ip_address_SHG}
221 | | And Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
222 | | ... | ${tap2_NM_mac} | ${tg_to_dut_if1_mac}
223 | | ... | ${tap2_NM_SHG} | ${tg_ip_address_SHG}
224 | | And Send Ping From Node To Dst | ${dut_node} | ${tap1_NM_ip} | namespace=${namespace2}
225 | | And Send Ping From Node To Dst | ${dut_node} | ${tap2_NM_SHG} | namespace=${namespace1}
226
227 | TC05: Tap Interface BD - Same Split Horizon
228 | | [Documentation]
229 | | ... | [Top] TG-DUT1-TG.
230 | | ... | [Enc] Eth-IPv4-ICMPv4.
231 | | ... | [Cfg] On DUT1
232 | | ... | configure one if into L2BD with MAC learning. Add two TAP interfaces
233 | | ... | into this L2BD and assign them same SHG. Setup two namespaces
234 | | ... | and assign two linux-TAP interfaces to it respectively.
235 | | ... | [Ver] Packet is sent from TG to both linux-TAP interfaces and reply
236 | | ... | is checked. Ping from First linux-TAP to another should fail.
237 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
238 | | ... | ${nodes['TG']}
239 | | And Interfaces in 2-node path are up
240 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
241 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
242 | | And Set Interface State | ${dut_node} | ${int1} | up
243 | | And Set Interface State | ${dut_node} | ${int2} | up
244 | | When Create Namespace | ${dut_node} | ${namespace1}
245 | | And Attach Interface To Namespace | ${dut_node}
246 | | ... | ${namespace1} | ${tap_int1}
247 | | And Create Namespace | ${dut_node} | ${namespace2}
248 | | And Attach Interface To Namespace | ${dut_node}
249 | | ... | ${namespace2} | ${tap_int2}
250 | | And Set Linux Interface IP | ${dut_node} | ${tap_int1}
251 | | ... | ${tap1_NM_ip} | ${prefix} | ${namespace1}
252 | | And Set Linux Interface IP | ${dut_node} | ${tap_int2}
253 | | ... | ${tap2_NM_SHG} | ${prefix} | ${namespace2}
254 | | And Set Linux Interface MAC | ${dut_node}
255 | | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1}
256 | | And Set Linux Interface MAC | ${dut_node}
257 | | ... | ${tap_int2} | ${tap2_NM_mac} | ${namespace2}
258 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int1}
259 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace1}
260 | | And Set Linux Interface ARP | ${dut_node} | ${tap_int2}
261 | | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace2}
262 | | And Bridge domain on DUT node is created | ${dut_node}
263 | | ... | ${bd_id1} | learn=${TRUE}
264 | | And Interface is added to bridge domain | ${dut_node} | ${dut_to_tg_if1}
265 | | ...                                     | ${bd_id1}
266 | | And Interface is added to bridge domain | ${dut_node} | ${int1}
267 | | ...                                     | ${bd_id1} | ${shg1}
268 | | And Interface is added to bridge domain | ${dut_node} | ${int2}
269 | | ...                                     | ${bd_id1} | ${shg1}
270 | | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
271 | | ... | ${tap1_NM_mac} | ${tg_to_dut_if1_mac}
272 | | ... | ${tap1_NM_ip} | ${tg_ip_address_SHG}
273 | | And Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
274 | | ... | ${tap2_NM_mac} | ${tg_to_dut_if1_mac}
275 | | ... | ${tap2_NM_SHG} | ${tg_ip_address_SHG}
276 | | And Run Keyword And Expect Error | Ping Not Successful | Send Ping From Node To Dst
277 | | ... | ${dut_node} | ${tap2_NM_SHG} | namespace=${namespace1}
278 | | And Run Keyword And Expect Error | Ping Not Successful | Send Ping From Node To Dst
279 | | ... | ${dut_node} | ${tap1_NM_ip} | namespace=${namespace2}
280
281 | TC06: Tap Interface Modify And Delete
282 | | [Documentation]
283 | | ... | [Top] TG-DUT1-TG.
284 | | ... | [Enc] Eth-IPv4-ICMPv4.
285 | | ... | [Cfg] Set two TAP interfaces.
286 | | ... | [Ver] Verify that TAP interface can be modified, deleted, and no other
287 | | ... | TAP interface is affected.
288 | | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
289 | | ... | ${nodes['TG']}
290 | | And Interfaces in 2-node path are up
291 | | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1}
292 | | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2}
293 | | And Set Interface State | ${dut_node} | ${int1} | up
294 | | And Set Interface State | ${dut_node} | ${int2} | up
295 | | When Modify Tap Interface | ${dut_node} | ${int1} | ${mod_tap_name}
296 | | Then Check Tap Present | ${dut_node} | ${mod_tap_name}
297 | | When Delete Tap Interface | ${dut_node} | ${int1}
298 | | Then Run Keyword And Expect Error
299 | | ... | Tap interface :${mod_tap_name} does not exist
300 | | ... | Check Tap Present | ${dut_node} | ${mod_tap_name}
301 | | And Check Tap Present | ${dut_node} | ${tap_int2}
302 | | When Delete Tap Interface | ${dut_node} | ${int2}
303 | | Then Run Keyword And Expect Error
304 | | ... | ValueError: No JSON object could be decoded
305 | | ... | Check Tap Present | ${dut_node} | ${tap_int2}