Clean: L2 bridge domain
[csit.git] / resources / libraries / robot / shared / interfaces.robot
1 # Copyright (c) 2019 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 *** Settings ***
14 | Library | resources.libraries.python.InterfaceUtil
15 | Library | resources.libraries.python.NodePath
16
17 *** Keywords ***
18 | Set interfaces in path up
19 | | [Documentation]
20 | | ... | *Set UP state on VPP interfaces in path on all DUT nodes and set
21 | | ... | maximal MTU.*
22 | | ...
23 # TODO: Rework KW to set all interfaces in path UP and set MTU (including
24 # software interfaces. Run KW at the start phase of VPP setup to split
25 # from other "functional" configuration. This will allow modularity of this
26 # library
27 | | :FOR | ${dut} | IN | @{duts}
28 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
29 | | | ... | Variable Should Exist | ${${dut}_if1}
30 | | | Run Keyword If | '${if1_status}' == 'PASS'
31 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if1} | up
32 | | | ... | ELSE
33 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if1_1} | up
34 | | | Run Keyword Unless | '${if1_status}' == 'PASS'
35 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if1_2} | up
36 | | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
37 | | | ... | Variable Should Exist | ${${dut}_if2}
38 | | | Run Keyword If | '${if2_status}' == 'PASS'
39 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if2} | up
40 | | | ... | ELSE
41 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if2_1} | up
42 | | | Run Keyword Unless | '${if2_status}' == 'PASS'
43 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if2_2} | up
44 | | :FOR | ${dut} | IN | @{duts}
45 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
46 | | | ... | Variable Should Exist | ${${dut}_if1}
47 | | | Run Keyword If | '${if1_status}' == 'PASS'
48 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if1}
49 | | | ... | ELSE
50 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if1_1}
51 | | | Run Keyword Unless | '${if1_status}' == 'PASS'
52 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if1_2}
53 | | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
54 | | | ... | Variable Should Exist | ${${dut}_if2}
55 | | | Run Keyword If | '${if2_status}' == 'PASS'
56 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if2}
57 | | | ... | ELSE
58 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if2_1}
59 | | | Run Keyword Unless | '${if2_status}' == 'PASS'
60 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if2_2}
61 | | All VPP Interfaces Ready Wait | ${nodes} | retries=${300}
62
63 | Set single interfaces in path up
64 | | [Documentation]
65 | | ... | *Set UP state on single VPP interfaces in path on all DUT nodes and set
66 | | ... | maximal MTU.*
67 | | ...
68 # TODO: Rework KW to set all interfaces in path UP and set MTU (including
69 # software interfaces. Run KW at the start phase of VPP setup to split
70 # from other "functional" configuration. This will allow modularity of this
71 # library
72 | | :FOR | ${dut} | IN | @{duts}
73 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
74 | | | ... | Variable Should Exist | ${${dut}_if1}
75 | | | Run Keyword If | '${if1_status}' == 'PASS'
76 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if1} | up
77 | | | ... | ELSE
78 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if1_1} | up
79 | | | Run Keyword Unless | '${if1_status}' == 'PASS'
80 | | | ... | Set Interface State | ${nodes['${dut}']} | ${${dut}_if1_2} | up
81 | | :FOR | ${dut} | IN | @{duts}
82 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
83 | | | ... | Variable Should Exist | ${${dut}_if1}
84 | | | Run Keyword If | '${if1_status}' == 'PASS'
85 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if1}
86 | | | ... | ELSE
87 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if1_1}
88 | | | Run Keyword Unless | '${if1_status}' == 'PASS'
89 | | | ... | VPP Set Interface MTU | ${nodes['${dut}']} | ${${dut}_if1_2}
90 | | All VPP Interfaces Ready Wait | ${nodes}
91
92 | Get Vhost dump
93 | | [Documentation] | Get vhost-user dump.
94 | | ...
95 | | ... | *Arguments:*
96 | | ... | - node - DUT node data. Type: dictionary
97 | | ...
98 | | [Arguments] | ${dut_node}
99 | | ...
100 | | [Return] | ${vhost_dump}
101 | | ...
102 | | ${vhost_dump}= | Vhost User Dump | ${dut_node}
103
104 | Initialize layer interface on node
105 | | [Documentation]
106 | | ... | Baseline interfaces variables to be created.
107 | | ...
108 | | ... | *Arguments:*
109 | | ... | - dut - DUT node. Type: string
110 | | ... | - count - Number of baseline interface variables. Type: integer
111 | | ...
112 | | ... | *Example:*
113 | | ...
114 | | ... | \| Initialize layer interface on node \| DUT1 \| 1 \|
115 | | ...
116 | | [Arguments] | ${dut} | ${count}=${1}
117 | | ...
118 | | ${dut_str}= | Convert To Lowercase | ${dut}
119 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
120 | | | Set Test Variable | ${${dut_str}_if_${id}_1} | ${${dut_str}_if1}
121 | | | Set Test Variable | ${${dut_str}_if_${id}_2} | ${${dut_str}_if2}
122
123 | Initialize layer interface
124 | | [Documentation]
125 | | ... | Physical interfaces variables to be created on all DUTs.
126 | | ...
127 | | ... | *Arguments:*
128 | | ... | - count - Number of untagged interfaces variables. Type: integer
129 | | ...
130 | | ... | *Example:*
131 | | ...
132 | | ... | \| Initialize layer interface \| 1 \|
133 | | ...
134 | | [Arguments] | ${count}=${1}
135 | | ...
136 | | :FOR | ${dut} | IN | @{duts}
137 | | | Initialize layer interface on node | ${dut} | count=${count}
138 | | Set Test Variable | ${prev_layer} | if
139 | | Set interfaces in path up
140
141 | Initialize layer avf on node
142 | | [Documentation]
143 | | ... | Initialize AVF interfaces on DUT. Interfaces are brought up.
144 | | ...
145 | | ... | *Arguments:*
146 | | ... | - dut - DUT node. Type: string
147 | | ...
148 | | ... | *Example:*
149 | | ...
150 | | ... | \| Initialize layer avf on node \| DUT1 \|
151 | | ...
152 | | [Arguments] | ${dut}
153 | | ...
154 | | ${dut_str}= | Convert To Lowercase | ${dut}
155 | | ${if1_vlan}= | Get Interface Vlan | ${nodes['${dut}']} | ${${dut}_if1}
156 | | ${if2_vlan}= | Get Interface Vlan | ${nodes['${dut}']} | ${${dut}_if2}
157 | | Set Test Variable | ${${dut_str}_vlan1} | ${if1_vlan}
158 | | Set Test Variable | ${${dut_str}_vlan2} | ${if2_vlan}
159 | | ${if1_pci}= | Get Interface PCI Addr | ${nodes['${dut}']}
160 | | ... | ${${dut}_if1_vf0}
161 | | ${if2_pci}= | Get Interface PCI Addr | ${nodes['${dut}']}
162 | | ... | ${${dut}_if2_vf0}
163 | | ${dut_eth_vf_if1}= | VPP Create AVF Interface | ${nodes['${dut}']}
164 | | ... | ${if1_pci} | ${rxq_count_int}
165 | | ${dut_eth_vf_if2}= | VPP Create AVF Interface | ${nodes['${dut}']}
166 | | ... | ${if2_pci} | ${rxq_count_int}
167 | | Set Test Variable | ${${dut_str}_if1} | ${dut_eth_vf_if1}
168 | | Set Test Variable | ${${dut_str}_if2} | ${dut_eth_vf_if2}
169
170 | Initialize AVF interfaces
171 | | [Documentation]
172 | | ... | Initialize AVF interfaces on each DUT. Interfaces are brought up.
173 | | ...
174 | | :FOR | ${dut} | IN | @{duts}
175 | | | Initialize layer avf on node | ${dut}
176 | | Set Test Variable | ${prev_layer} | vf
177 | | Set interfaces in path up
178
179 | Initialize layer bonding on node
180 | | [Documentation]
181 | | ... | Bonded interface and variables to be created on across east and
182 | | ... | west DUT's node interfaces.
183 | | ...
184 | | ... | *Arguments:*
185 | | ... | - dut - DUT node. Type: string
186 | | ... | - bond_mode - Link bonding mode. Type: string
187 | | ... | - lb_mode - Load balance mode. Type: string
188 | | ... | - count - Number of bond interface variables. Type: integer
189 | | ...
190 | | ... | *Example:*
191 | | ...
192 | | ... | \| Initialize layer bonding on node \| DUT1 \| xor \| l34 \| 1 \|
193 | | ...
194 | | [Arguments] | ${dut} | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
195 | | ...
196 | | ${dut_str}= | Convert To Lowercase | ${dut}
197 | | ${if_index}= | VPP Create Bond Interface
198 | | ... | ${nodes['${dut}']} | ${bond_mode} | load_balance=${lb_mode}
199 | | ... | mac=00:00:00:01:01:01
200 | | Set Interface State | ${nodes['${dut}']} | ${if_index} | up
201 | | VPP Enslave Physical Interface
202 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1} | ${if_index}
203 | | VPP Enslave Physical Interface
204 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2} | ${if_index}
205 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
206 | | | Set Test Variable | ${${dut_str}_bond_${id}_1} | ${if_index}
207 | | | Set Test Variable | ${${dut_str}_bond_${id}_2} | ${if_index}
208
209 | Initialize layer bonding
210 | | [Documentation]
211 | | ... | Bonded interfaces and variables to be created on all DUT's interfaces.
212 | | ...
213 | | ... | *Arguments:*
214 | | ... | - bond_mode - Link bonding mode. Type: string
215 | | ... | - lb_mode - Load balance mode. Type: string
216 | | ... | - count - Number of bond interface variables. Type: integer
217 | | ...
218 | | ... | *Example:*
219 | | ...
220 | | ... | \| Initialize layer bonding \| xor \| l34 \| 1 \|
221 | | ...
222 | | [Arguments] | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
223 | | ...
224 | | :FOR | ${dut} | IN | @{duts}
225 | | | Initialize layer bonding on node
226 | | | ... | ${dut} | bond_mode=${bond_mode} | lb_mode=${lb_mode}
227 | | | ... | count=${count}
228 | | Set Test Variable | ${prev_layer} | bond
229
230 | Initialize layer dot1q on node
231 | | [Documentation]
232 | | ... | Dot1q interfaces and variables to be created on all DUT's node
233 | | ... | interfaces.
234 | | ...
235 | | ... | *Arguments:*
236 | | ... | - dut - DUT node. Type: string
237 | | ... | - count - Number of tagged interfaces. Type: integer
238 | | ... | - create - Whether to create vlan subinterface for each chain.
239 | | ... |     Type: boolean
240 | | ...
241 | | ... | *Example:*
242 | | ...
243 | | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
244 | | ...
245 | | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
246 | | ...
247 | | ${dut_str}= | Convert To Lowercase | ${dut}
248 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
249 | | | ${if1_vlan}= | Run Keyword If | ${${dut_str}_vlan1}
250 | | | ... | Set Variable | ${${dut_str}_vlan1}
251 | | | ... | ELSE
252 | | | ... | Evaluate | ${100} + ${id} - ${1}
253 | | | ${if2_vlan}= | Run Keyword If | ${${dut_str}_vlan2}
254 | | | ... | Set Variable | ${${dut_str}_vlan2}
255 | | | ... | ELSE
256 | | | ... | Evaluate | ${200} + ${id} - ${1}
257 | | | ${if1_name} | ${if1_index}= | Run Keyword If
258 | | | ... | ${create} or ${id} == ${1}
259 | | | ... | Create Vlan Subinterface
260 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
261 | | | ... | ${if1_vlan}
262 | | | ${if2_name} | ${if2_index}= | Run Keyword If
263 | | | ... | ${create} or ${id} == ${1}
264 | | | ... | Create Vlan Subinterface
265 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
266 | | | ... | ${if2_vlan}
267 | | | Run Keyword If | ${create} or ${id} == ${1}
268 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
269 | | | Run Keyword If | ${create} or ${id} == ${1}
270 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
271 | | | Run Keyword If | ${create} or ${id} == ${1}
272 | | | ... | Configure L2 tag rewrite method on interfaces
273 | | | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
274 | | | Run Keyword If | ${create} or ${id} == ${1}
275 | | | ... | Configure L2 tag rewrite method on interfaces
276 | | | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
277 | | | ${if1_index}= | Set Variable If | '${if1_index}' == '${NONE}'
278 | | | ... | ${${dut_str}_dot1q_1_1} | ${if1_index}
279 | | | ${if2_index}= | Set Variable If | '${if2_index}' == '${NONE}'
280 | | | ... | ${${dut_str}_dot1q_1_2} | ${if2_index}
281 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_1} | ${if1_index}
282 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_2} | ${if2_index}
283
284 | Initialize layer dot1q
285 | | [Documentation]
286 | | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
287 | | ...
288 | | ... | *Arguments:*
289 | | ... | - count - Number of tagged interfaces. Type: integer
290 | | ... | - create - Whether to create vlan for each chain. Type: boolean
291 | | ...
292 | | ... | \| Initialize layer dot1q \| 1 \| True \|
293 | | ...
294 | | [Arguments] | ${count}=${1} | ${create}=${True}
295 | | ...
296 | | :FOR | ${dut} | IN | @{duts}
297 | | | Initialize layer dot1q on node | ${dut} | count=${count}
298 | | | ... | create=${create}
299 | | Set Test Variable | ${prev_layer} | dot1q
300
301 | Initialize layer ip4vxlan on node
302 | | [Documentation]
303 | | ... | Setup VXLANoIPv4 between TG and DUTs and DUT to DUT by connecting
304 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
305 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
306 | | ... | towards TG. VXLAN sub-interfaces has same IPv4 address as interfaces.
307 | | ...
308 | | ... | *Arguments:*
309 | | ... | - dut - DUT node. Type: string
310 | | ... | - count - Number of vxlan interfaces. Type: integer
311 | | ...
312 | | ... | *Example:*
313 | | ...
314 | | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
315 | | ...
316 | | [Arguments] | ${dut} | ${count}=${1}
317 | | ...
318 | | ${dut_str}= | Convert To Lowercase | ${dut}
319 | | VPP Interface Set IP Address
320 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
321 | | ... | 172.16.0.1 | 24
322 | | VPP Interface Set IP Address
323 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
324 | | ... | 172.26.0.1 | 24
325 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
326 | | | ${subnet}= | Evaluate | ${id} - 1
327 | | | ${vni}= | Evaluate | ${id} - 1
328 | | | ${ip4vxlan_1}= | Create VXLAN interface
329 | | | ... | ${nodes['${dut}']} | ${vni} | 172.16.0.1 | 172.17.${subnet}.2
330 | | | ${ip4vxlan_2}= | Create VXLAN interface
331 | | | ... | ${nodes['${dut}']} | ${vni} | 172.26.0.1 | 172.27.${subnet}.2
332 | | | ${prev_mac}= | Set Variable If | '${dut}' == 'DUT1'
333 | | | ... | ${tg_if1_mac} | ${dut1_if2_mac}
334 | | | ${next_mac}= | Set Variable If | '${dut}' == 'DUT1' and ${duts_count} == 2
335 | | | ... | ${dut2_if1_mac} | ${tg_if2_mac}
336 | | | VPP Add IP Neighbor
337 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
338 | | | ... | 172.16.${subnet}.2 | ${prev_mac}
339 | | | VPP Add IP Neighbor
340 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
341 | | | ... | 172.26.${subnet}.2 | ${next_mac}
342 | | | VPP Route Add
343 | | | ... | ${nodes['${dut}']} | 172.17.${subnet}.0 | 24
344 | | | ... | gateway=172.16.${subnet}.2
345 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_1}
346 | | | VPP Route Add
347 | | | ... | ${nodes['${dut}']} | 172.27.${subnet}.0 | 24
348 | | | ... | gateway=172.26.${subnet}.2
349 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_2}
350 | | | Set VXLAN Bypass
351 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
352 | | | Set VXLAN Bypass
353 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
354 | | | Set Test Variable
355 | | | ... | ${${dut_str}_ip4vxlan_${id}_1} | ${ip4vxlan_1}
356 | | | Set Test Variable
357 | | | ... | ${${dut_str}_ip4vxlan_${id}_2} | ${ip4vxlan_2}
358
359 | Initialize layer ip4vxlan
360 | | [Documentation]
361 | | ... | VXLAN interfaces and variables to be created on all DUT's interfaces.
362 | | ...
363 | | ... | *Arguments:*
364 | | ... | - count - Number of vxlan interfaces. Type: integer
365 | | ...
366 | | ... | \| Initialize layer ip4vxlan \| 1 \|
367 | | ...
368 | | [Arguments] | ${count}=${1}
369 | | ...
370 | | :FOR | ${dut} | IN | @{duts}
371 | | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
372 | | Set Test Variable | ${prev_layer} | ip4vxlan
373
374 | Configure vhost interfaces
375 | | [Documentation]
376 | | ... | Create two Vhost-User interfaces on defined VPP node.
377 | | ...
378 | | ... | *Arguments:*
379 | | ... | - ${dut_node} - DUT node. Type: dictionary
380 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
381 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
382 | | ... | - ${vhost_if1} - Name of the first Vhost-User interface (Optional).
383 | | ... | Type: string
384 | | ... | - ${vhost_if2} - Name of the second Vhost-User interface (Optional).
385 | | ... | Type: string
386 | | ...
387 | | ... | _NOTE:_ This KW sets following test case variable:
388 | | ... | - ${${vhost_if1}} - First Vhost-User interface.
389 | | ... | - ${${vhost_if2}} - Second Vhost-User interface.
390 | | ...
391 | | ... | *Example:*
392 | | ...
393 | | ... | \| Configure vhost interfaces \
394 | | ... | \| ${nodes['DUT1']} \| /tmp/sock1 \| /tmp/sock2 \|
395 | | ... | \| Configure vhost interfaces \
396 | | ... | \| ${nodes['DUT2']} \| /tmp/sock1 \| /tmp/sock2 \| dut2_vhost_if1 \
397 | | ... | \| dut2_vhost_if2 \|
398 | | ...
399 | | [Arguments] | ${dut_node} | ${sock1} | ${sock2} | ${vhost_if1}=vhost_if1
400 | | ... | ${vhost_if2}=vhost_if2
401 | | ...
402 | | ${vhost_1}= | Vpp Create Vhost User Interface | ${dut_node} | ${sock1}
403 | | ${vhost_2}= | Vpp Create Vhost User Interface | ${dut_node} | ${sock2}
404 | | Set Interface State | ${dut_node} | ${vhost_1} | up
405 | | Set Interface State | ${dut_node} | ${vhost_2} | up
406 | | Set Test Variable | ${${vhost_if1}} | ${vhost_1}
407 | | Set Test Variable | ${${vhost_if2}} | ${vhost_2}