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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 | Library | resources.libraries.python.InterfaceUtil
15 | Library | resources.libraries.python.NodePath
18 | Set interfaces in path up
20 | | ... | *Set UP state on VPP interfaces in path on all DUT nodes and set
21 | | ... | maximal MTU.*
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
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
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
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}
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}
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}
63 | Set single interfaces in path up
65 | | ... | *Set UP state on single VPP interfaces in path on all DUT nodes and set
66 | | ... | maximal MTU.*
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
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
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}
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}
93 | | [Documentation] | Get vhost-user dump.
95 | | ... | *Arguments:*
96 | | ... | - node - DUT node data. Type: dictionary
98 | | [Arguments] | ${dut_node}
100 | | [Return] | ${vhost_dump}
102 | | ${vhost_dump}= | Vhost User Dump | ${dut_node}
104 | Initialize layer interface on node
106 | | ... | Baseline interfaces variables to be created.
108 | | ... | *Arguments:*
109 | | ... | - dut - DUT node. Type: string
110 | | ... | - count - Number of baseline interface variables. Type: integer
114 | | ... | \| Initialize layer interface on node \| DUT1 \| 1 \|
116 | | [Arguments] | ${dut} | ${count}=${1}
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}
123 | Initialize layer interface
125 | | ... | Physical interfaces variables to be created on all DUTs.
127 | | ... | *Arguments:*
128 | | ... | - count - Number of untagged interfaces variables. Type: integer
132 | | ... | \| Initialize layer interface \| 1 \|
134 | | [Arguments] | ${count}=${1}
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
141 | Initialize layer avf on node
143 | | ... | Initialize AVF interfaces on DUT. Interfaces are brought up.
145 | | ... | *Arguments:*
146 | | ... | - dut - DUT node. Type: string
150 | | ... | \| Initialize layer avf on node \| DUT1 \|
152 | | [Arguments] | ${dut}
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}
176 | Initialize AVF interfaces
178 | | ... | Initialize AVF interfaces on each DUT. Interfaces are brought up.
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
185 | Initialize layer bonding on node
187 | | ... | Bonded interface and variables to be created on across east and
188 | | ... | west DUT's node interfaces.
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
198 | | ... | \| Initialize layer bonding on node \| DUT1 \| xor \| l34 \| 1 \|
200 | | [Arguments] | ${dut} | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
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}
215 | Initialize layer bonding
217 | | ... | Bonded interfaces and variables to be created on all DUT's interfaces.
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
226 | | ... | \| Initialize layer bonding \| xor \| l34 \| 1 \|
228 | | [Arguments] | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
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
236 | Initialize layer dot1q on node
238 | | ... | Dot1q interfaces and variables to be created on all DUT's node
239 | | ... | interfaces.
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
249 | | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
251 | | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
253 | | ${dut_str}= | Convert To Lowercase | ${dut}
254 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
255 | | | ${if1_vlan}= | Get Variable Value | \${${dut_str}_vlan1}
256 | | | ${default}= | Evaluate | ${100} + ${id} - ${1}
257 | | | ${if1_vlan}= | Set Variable If | '${if1_vlan}' == '${NONE}'
258 | | | ... | ${default} | ${if1_vlan}
259 | | | ${if2_vlan}= | Get Variable Value | \${${dut_str}_vlan2}
260 | | | ${default}= | Evaluate | ${200} + ${id} - ${1}
261 | | | ${if2_vlan}= | Set Variable If | '${if2_vlan}' == '${NONE}'
262 | | | ... | ${default} | ${if2_vlan}
263 | | | ${if1_name} | ${if1_index}= | Run Keyword If
264 | | | ... | ${create} or ${id} == ${1}
265 | | | ... | Create Vlan Subinterface
266 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
267 | | | ... | ${if1_vlan}
268 | | | ${if2_name} | ${if2_index}= | Run Keyword If
269 | | | ... | ${create} or ${id} == ${1}
270 | | | ... | Create Vlan Subinterface
271 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
272 | | | ... | ${if2_vlan}
273 | | | Run Keyword If | ${create} or ${id} == ${1}
274 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
275 | | | Run Keyword If | ${create} or ${id} == ${1}
276 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
277 | | | Run Keyword If | ${create} or ${id} == ${1}
278 | | | ... | Configure L2 tag rewrite method on interfaces
279 | | | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
280 | | | Run Keyword If | ${create} or ${id} == ${1}
281 | | | ... | Configure L2 tag rewrite method on interfaces
282 | | | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
283 | | | ${if1_index}= | Set Variable If | '${if1_index}' == '${NONE}'
284 | | | ... | ${${dut_str}_dot1q_1_1} | ${if1_index}
285 | | | ${if2_index}= | Set Variable If | '${if2_index}' == '${NONE}'
286 | | | ... | ${${dut_str}_dot1q_1_2} | ${if2_index}
287 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_1} | ${if1_index}
288 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_2} | ${if2_index}
290 | Initialize layer dot1q
292 | | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
294 | | ... | *Arguments:*
295 | | ... | - count - Number of tagged interfaces. Type: integer
296 | | ... | - create - Whether to create vlan for each chain. Type: boolean
298 | | ... | \| Initialize layer dot1q \| 1 \| True \|
300 | | [Arguments] | ${count}=${1} | ${create}=${True}
302 | | :FOR | ${dut} | IN | @{duts}
303 | | | Initialize layer dot1q on node | ${dut} | count=${count}
304 | | | ... | create=${create}
305 | | Set Test Variable | ${prev_layer} | dot1q
307 | Initialize layer ip4vxlan on node
309 | | ... | Setup VXLANoIPv4 between TG and DUTs and DUT to DUT by connecting
310 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
311 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
312 | | ... | towards TG. VXLAN sub-interfaces has same IPv4 address as interfaces.
314 | | ... | *Arguments:*
315 | | ... | - dut - DUT node. Type: string
316 | | ... | - count - Number of vxlan interfaces. Type: integer
320 | | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
322 | | [Arguments] | ${dut} | ${count}=${1}
324 | | ${dut_str}= | Convert To Lowercase | ${dut}
325 | | VPP Interface Set IP Address
326 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
327 | | ... | 172.16.0.1 | 24
328 | | VPP Interface Set IP Address
329 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
330 | | ... | 172.26.0.1 | 24
331 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
332 | | | ${subnet}= | Evaluate | ${id} - 1
333 | | | ${vni}= | Evaluate | ${id} - 1
334 | | | ${ip4vxlan_1}= | Create VXLAN interface
335 | | | ... | ${nodes['${dut}']} | ${vni} | 172.16.0.1 | 172.17.${subnet}.2
336 | | | ${ip4vxlan_2}= | Create VXLAN interface
337 | | | ... | ${nodes['${dut}']} | ${vni} | 172.26.0.1 | 172.27.${subnet}.2
338 | | | ${prev_mac}= | Set Variable If | '${dut}' == 'DUT1'
339 | | | ... | ${tg_if1_mac} | ${dut1_if2_mac}
340 | | | ${next_mac}= | Set Variable If | '${dut}' == 'DUT1' and ${duts_count} == 2
341 | | | ... | ${dut2_if1_mac} | ${tg_if2_mac}
342 | | | VPP Add IP Neighbor
343 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
344 | | | ... | 172.16.${subnet}.2 | ${prev_mac}
345 | | | VPP Add IP Neighbor
346 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
347 | | | ... | 172.26.${subnet}.2 | ${next_mac}
349 | | | ... | ${nodes['${dut}']} | 172.17.${subnet}.0 | 24
350 | | | ... | gateway=172.16.${subnet}.2
351 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_1}
353 | | | ... | ${nodes['${dut}']} | 172.27.${subnet}.0 | 24
354 | | | ... | gateway=172.26.${subnet}.2
355 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_2}
356 | | | Set VXLAN Bypass
357 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
358 | | | Set VXLAN Bypass
359 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
360 | | | Set Test Variable
361 | | | ... | ${${dut_str}_ip4vxlan_${id}_1} | ${ip4vxlan_1}
362 | | | Set Test Variable
363 | | | ... | ${${dut_str}_ip4vxlan_${id}_2} | ${ip4vxlan_2}
365 | Initialize layer ip4vxlan
367 | | ... | VXLAN interfaces and variables to be created on all DUT's interfaces.
369 | | ... | *Arguments:*
370 | | ... | - count - Number of vxlan interfaces. Type: integer
372 | | ... | \| Initialize layer ip4vxlan \| 1 \|
374 | | [Arguments] | ${count}=${1}
376 | | :FOR | ${dut} | IN | @{duts}
377 | | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
378 | | Set Test Variable | ${prev_layer} | ip4vxlan
380 | Configure vhost interfaces
382 | | ... | Create two Vhost-User interfaces on defined VPP node.
384 | | ... | *Arguments:*
385 | | ... | - ${dut_node} - DUT node. Type: dictionary
386 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
387 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
388 | | ... | - ${vhost_if1} - Name of the first Vhost-User interface (Optional).
389 | | ... | Type: string
390 | | ... | - ${vhost_if2} - Name of the second Vhost-User interface (Optional).
391 | | ... | Type: string
393 | | ... | _NOTE:_ This KW sets following test case variable:
394 | | ... | - ${${vhost_if1}} - First Vhost-User interface.
395 | | ... | - ${${vhost_if2}} - Second Vhost-User interface.
399 | | ... | \| Configure vhost interfaces \
400 | | ... | \| ${nodes['DUT1']} \| /tmp/sock1 \| /tmp/sock2 \|
401 | | ... | \| Configure vhost interfaces \
402 | | ... | \| ${nodes['DUT2']} \| /tmp/sock1 \| /tmp/sock2 \| dut2_vhost_if1 \
403 | | ... | \| dut2_vhost_if2 \|
405 | | [Arguments] | ${dut_node} | ${sock1} | ${sock2} | ${vhost_if1}=vhost_if1
406 | | ... | ${vhost_if2}=vhost_if2
408 | | ${vhost_1}= | Vpp Create Vhost User Interface | ${dut_node} | ${sock1}
409 | | ${vhost_2}= | Vpp Create Vhost User Interface | ${dut_node} | ${sock2}
410 | | Set Interface State | ${dut_node} | ${vhost_1} | up
411 | | Set Interface State | ${dut_node} | ${vhost_2} | up
412 | | Set Test Variable | ${${vhost_if1}} | ${vhost_1}
413 | | Set Test Variable | ${${vhost_if2}} | ${vhost_2}