e249cd5d4ec5e14cee6ed02f414672f649eba7cf
[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_if1_mac}= | Get Interface MAC | ${nodes['${dut}']}
166 | | ... | ${dut_eth_vf_if1}
167 | | ${dut_eth_vf_if2}= | VPP Create AVF Interface | ${nodes['${dut}']}
168 | | ... | ${if2_pci} | ${rxq_count_int}
169 | | ${dut_eth_vf_if2_mac}= | Get Interface MAC | ${nodes['${dut}']}
170 | | ... | ${dut_eth_vf_if2}
171 | | Set Test Variable | ${${dut_str}_if1} | ${dut_eth_vf_if1}
172 | | Set Test Variable | ${${dut_str}_if2} | ${dut_eth_vf_if2}
173 | | Set Test Variable | ${${dut_str}_if1_mac} | ${dut_eth_vf_if1_mac}
174 | | Set Test Variable | ${${dut_str}_if2_mac} | ${dut_eth_vf_if2_mac}
175
176 | Initialize AVF interfaces
177 | | [Documentation]
178 | | ... | Initialize AVF interfaces on each DUT. Interfaces are brought up.
179 | | ...
180 | | :FOR | ${dut} | IN | @{duts}
181 | | | Initialize layer avf on node | ${dut}
182 | | Set Test Variable | ${prev_layer} | vf
183 | | Set interfaces in path up
184
185 | Initialize layer bonding on node
186 | | [Documentation]
187 | | ... | Bonded interface and variables to be created on across east and
188 | | ... | west DUT's node interfaces.
189 | | ...
190 | | ... | *Arguments:*
191 | | ... | - dut - DUT node. Type: string
192 | | ... | - bond_mode - Link bonding mode. Type: string
193 | | ... | - lb_mode - Load balance mode. Type: string
194 | | ... | - count - Number of bond interface variables. Type: integer
195 | | ...
196 | | ... | *Example:*
197 | | ...
198 | | ... | \| Initialize layer bonding on node \| DUT1 \| xor \| l34 \| 1 \|
199 | | ...
200 | | [Arguments] | ${dut} | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
201 | | ...
202 | | ${dut_str}= | Convert To Lowercase | ${dut}
203 | | ${if_index}= | VPP Create Bond Interface
204 | | ... | ${nodes['${dut}']} | ${bond_mode} | load_balance=${lb_mode}
205 | | ... | mac=00:00:00:01:01:01
206 | | Set Interface State | ${nodes['${dut}']} | ${if_index} | up
207 | | VPP Enslave Physical Interface
208 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1} | ${if_index}
209 | | VPP Enslave Physical Interface
210 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2} | ${if_index}
211 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
212 | | | Set Test Variable | ${${dut_str}_bond_${id}_1} | ${if_index}
213 | | | Set Test Variable | ${${dut_str}_bond_${id}_2} | ${if_index}
214
215 | Initialize layer bonding
216 | | [Documentation]
217 | | ... | Bonded interfaces and variables to be created on all DUT's interfaces.
218 | | ...
219 | | ... | *Arguments:*
220 | | ... | - bond_mode - Link bonding mode. Type: string
221 | | ... | - lb_mode - Load balance mode. Type: string
222 | | ... | - count - Number of bond interface variables. Type: integer
223 | | ...
224 | | ... | *Example:*
225 | | ...
226 | | ... | \| Initialize layer bonding \| xor \| l34 \| 1 \|
227 | | ...
228 | | [Arguments] | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
229 | | ...
230 | | :FOR | ${dut} | IN | @{duts}
231 | | | Initialize layer bonding on node
232 | | | ... | ${dut} | bond_mode=${bond_mode} | lb_mode=${lb_mode}
233 | | | ... | count=${count}
234 | | Set Test Variable | ${prev_layer} | bond
235
236 | Initialize layer dot1q on node
237 | | [Documentation]
238 | | ... | Dot1q interfaces and variables to be created on all DUT's node
239 | | ... | interfaces.
240 | | ...
241 | | ... | *Arguments:*
242 | | ... | - dut - DUT node. Type: string
243 | | ... | - count - Number of tagged interfaces. Type: integer
244 | | ... | - create - Whether to create vlan subinterface for each chain.
245 | | ... |     Type: boolean
246 | | ...
247 | | ... | *Example:*
248 | | ...
249 | | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
250 | | ...
251 | | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
252 | | ...
253 | | ${dut_str}= | Convert To Lowercase | ${dut}
254 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
255 | | | ${default}= | Evaluate | ${100} + ${id} - ${1}
256 | | | ${if1_vlan}= | Get Variable Value | \${${dut_str}_vlan1} | ${default}
257 | | | ${default}= | Evaluate | ${200} + ${id} - ${1}
258 | | | ${if2_vlan}= | Get Variable Value | \${${dut_str}_vlan2} | ${default}
259 | | | ${if1_name} | ${if1_index}= | Run Keyword If
260 | | | ... | ${create} or ${id} == ${1}
261 | | | ... | Create Vlan Subinterface
262 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
263 | | | ... | ${if1_vlan}
264 | | | ${if2_name} | ${if2_index}= | Run Keyword If
265 | | | ... | ${create} or ${id} == ${1}
266 | | | ... | Create Vlan Subinterface
267 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
268 | | | ... | ${if2_vlan}
269 | | | Run Keyword If | ${create} or ${id} == ${1}
270 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
271 | | | Run Keyword If | ${create} or ${id} == ${1}
272 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
273 | | | Run Keyword If | ${create} or ${id} == ${1}
274 | | | ... | Configure L2 tag rewrite method on interfaces
275 | | | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
276 | | | Run Keyword If | ${create} or ${id} == ${1}
277 | | | ... | Configure L2 tag rewrite method on interfaces
278 | | | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
279 | | | ${if1_index}= | Set Variable If | '${if1_index}' == '${NONE}'
280 | | | ... | ${${dut_str}_dot1q_1_1} | ${if1_index}
281 | | | ${if2_index}= | Set Variable If | '${if2_index}' == '${NONE}'
282 | | | ... | ${${dut_str}_dot1q_1_2} | ${if2_index}
283 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_1} | ${if1_index}
284 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_2} | ${if2_index}
285
286 | Initialize layer dot1q
287 | | [Documentation]
288 | | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
289 | | ...
290 | | ... | *Arguments:*
291 | | ... | - count - Number of tagged interfaces. Type: integer
292 | | ... | - create - Whether to create vlan for each chain. Type: boolean
293 | | ...
294 | | ... | \| Initialize layer dot1q \| 1 \| True \|
295 | | ...
296 | | [Arguments] | ${count}=${1} | ${create}=${True}
297 | | ...
298 | | :FOR | ${dut} | IN | @{duts}
299 | | | Initialize layer dot1q on node | ${dut} | count=${count}
300 | | | ... | create=${create}
301 | | Set Test Variable | ${prev_layer} | dot1q
302
303 | Initialize layer ip4vxlan on node
304 | | [Documentation]
305 | | ... | Setup VXLANoIPv4 between TG and DUTs and DUT to DUT by connecting
306 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
307 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
308 | | ... | towards TG. VXLAN sub-interfaces has same IPv4 address as interfaces.
309 | | ...
310 | | ... | *Arguments:*
311 | | ... | - dut - DUT node. Type: string
312 | | ... | - count - Number of vxlan interfaces. Type: integer
313 | | ...
314 | | ... | *Example:*
315 | | ...
316 | | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
317 | | ...
318 | | [Arguments] | ${dut} | ${count}=${1}
319 | | ...
320 | | ${dut_str}= | Convert To Lowercase | ${dut}
321 | | VPP Interface Set IP Address
322 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
323 | | ... | 172.16.0.1 | 24
324 | | VPP Interface Set IP Address
325 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
326 | | ... | 172.26.0.1 | 24
327 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
328 | | | ${subnet}= | Evaluate | ${id} - 1
329 | | | ${vni}= | Evaluate | ${id} - 1
330 | | | ${ip4vxlan_1}= | Create VXLAN interface
331 | | | ... | ${nodes['${dut}']} | ${vni} | 172.16.0.1 | 172.17.${subnet}.2
332 | | | ${ip4vxlan_2}= | Create VXLAN interface
333 | | | ... | ${nodes['${dut}']} | ${vni} | 172.26.0.1 | 172.27.${subnet}.2
334 | | | ${prev_mac}= | Set Variable If | '${dut}' == 'DUT1'
335 | | | ... | ${tg_if1_mac} | ${dut1_if2_mac}
336 | | | ${next_mac}= | Set Variable If | '${dut}' == 'DUT1' and ${duts_count} == 2
337 | | | ... | ${dut2_if1_mac} | ${tg_if2_mac}
338 | | | VPP Add IP Neighbor
339 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
340 | | | ... | 172.16.${subnet}.2 | ${prev_mac}
341 | | | VPP Add IP Neighbor
342 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
343 | | | ... | 172.26.${subnet}.2 | ${next_mac}
344 | | | VPP Route Add
345 | | | ... | ${nodes['${dut}']} | 172.17.${subnet}.0 | 24
346 | | | ... | gateway=172.16.${subnet}.2
347 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_1}
348 | | | VPP Route Add
349 | | | ... | ${nodes['${dut}']} | 172.27.${subnet}.0 | 24
350 | | | ... | gateway=172.26.${subnet}.2
351 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_2}
352 | | | Set VXLAN Bypass
353 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
354 | | | Set VXLAN Bypass
355 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
356 | | | Set Test Variable
357 | | | ... | ${${dut_str}_ip4vxlan_${id}_1} | ${ip4vxlan_1}
358 | | | Set Test Variable
359 | | | ... | ${${dut_str}_ip4vxlan_${id}_2} | ${ip4vxlan_2}
360
361 | Initialize layer ip4vxlan
362 | | [Documentation]
363 | | ... | VXLAN interfaces and variables to be created on all DUT's interfaces.
364 | | ...
365 | | ... | *Arguments:*
366 | | ... | - count - Number of vxlan interfaces. Type: integer
367 | | ...
368 | | ... | \| Initialize layer ip4vxlan \| 1 \|
369 | | ...
370 | | [Arguments] | ${count}=${1}
371 | | ...
372 | | :FOR | ${dut} | IN | @{duts}
373 | | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
374 | | Set Test Variable | ${prev_layer} | ip4vxlan
375
376 | Configure vhost interfaces
377 | | [Documentation]
378 | | ... | Create two Vhost-User interfaces on defined VPP node.
379 | | ...
380 | | ... | *Arguments:*
381 | | ... | - ${dut_node} - DUT node. Type: dictionary
382 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
383 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
384 | | ... | - ${vhost_if1} - Name of the first Vhost-User interface (Optional).
385 | | ... | Type: string
386 | | ... | - ${vhost_if2} - Name of the second Vhost-User interface (Optional).
387 | | ... | Type: string
388 | | ...
389 | | ... | _NOTE:_ This KW sets following test case variable:
390 | | ... | - ${${vhost_if1}} - First Vhost-User interface.
391 | | ... | - ${${vhost_if2}} - Second Vhost-User interface.
392 | | ...
393 | | ... | *Example:*
394 | | ...
395 | | ... | \| Configure vhost interfaces \
396 | | ... | \| ${nodes['DUT1']} \| /tmp/sock1 \| /tmp/sock2 \|
397 | | ... | \| Configure vhost interfaces \
398 | | ... | \| ${nodes['DUT2']} \| /tmp/sock1 \| /tmp/sock2 \| dut2_vhost_if1 \
399 | | ... | \| dut2_vhost_if2 \|
400 | | ...
401 | | [Arguments] | ${dut_node} | ${sock1} | ${sock2} | ${vhost_if1}=vhost_if1
402 | | ... | ${vhost_if2}=vhost_if2
403 | | ...
404 | | ${vhost_1}= | Vpp Create Vhost User Interface | ${dut_node} | ${sock1}
405 | | ${vhost_2}= | Vpp Create Vhost User Interface | ${dut_node} | ${sock2}
406 | | Set Interface State | ${dut_node} | ${vhost_1} | up
407 | | Set Interface State | ${dut_node} | ${vhost_2} | up
408 | | Set Test Variable | ${${vhost_if1}} | ${vhost_1}
409 | | Set Test Variable | ${${vhost_if2}} | ${vhost_2}