FIX: Various issues
[csit.git] / resources / libraries / robot / shared / default.robot
1 # Copyright (c) 2020 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 | Variables | resources/libraries/python/topology.py
16 | Variables | resources/libraries/python/PapiHistory.py
17 | Variables | resources/libraries/python/Constants.py
18 |
19 | Library | Collections
20 | Library | OperatingSystem
21 | Library | String
22 |
23 | Library | resources.libraries.python.Classify
24 | Library | resources.libraries.python.CpuUtils
25 | Library | resources.libraries.python.CoreDumpUtil
26 | Library | resources.libraries.python.Cop
27 | Library | resources.libraries.python.DUTSetup
28 | Library | resources.libraries.python.L2Util
29 | Library | resources.libraries.python.InterfaceUtil
30 | Library | resources.libraries.python.IPUtil
31 | Library | resources.libraries.python.IPv6Util
32 | Library | resources.libraries.python.NodePath
33 | Library | resources.libraries.python.Namespaces
34 | Library | resources.libraries.python.PapiHistory
35 | Library | resources.libraries.python.SchedUtils
36 | Library | resources.libraries.python.Tap
37 | Library | resources.libraries.python.TestConfig
38 | Library | resources.libraries.python.TGSetup
39 | Library | resources.libraries.python.topology.Topology
40 | Library | resources.libraries.python.Trace
41 | Library | resources.libraries.python.VppCounters
42 | Library | resources.libraries.python.VPPUtil
43 |
44 | Resource | resources/libraries/robot/lb/load_balancer.robot
45 | Resource | resources/libraries/robot/crypto/ipsec.robot
46 | Resource | resources/libraries/robot/features/acl.robot
47 | Resource | resources/libraries/robot/features/gbp.robot
48 | Resource | resources/libraries/robot/features/policer.robot
49 | Resource | resources/libraries/robot/ip/ip4.robot
50 | Resource | resources/libraries/robot/ip/ip6.robot
51 | Resource | resources/libraries/robot/ip/nat.robot
52 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
53 | Resource | resources/libraries/robot/l2/l2_patch.robot
54 | Resource | resources/libraries/robot/l2/l2_traffic.robot
55 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
56 | Resource | resources/libraries/robot/l2/tagging.robot
57 | Resource | resources/libraries/robot/overlay/srv6.robot
58 | Resource | resources/libraries/robot/overlay/lisp.robot
59 | Resource | resources/libraries/robot/overlay/lispgpe.robot
60 | Resource | resources/libraries/robot/overlay/lisp_api.robot
61 | Resource | resources/libraries/robot/performance/performance_configuration.robot
62 | Resource | resources/libraries/robot/performance/performance_limits.robot
63 | Resource | resources/libraries/robot/performance/performance_utils.robot
64 | Resource | resources/libraries/robot/shared/interfaces.robot
65 | Resource | resources/libraries/robot/shared/container.robot
66 | Resource | resources/libraries/robot/shared/memif.robot
67 | Resource | resources/libraries/robot/shared/suite_teardown.robot
68 | Resource | resources/libraries/robot/shared/suite_setup.robot
69 | Resource | resources/libraries/robot/shared/test_teardown.robot
70 | Resource | resources/libraries/robot/shared/test_setup.robot
71 | Resource | resources/libraries/robot/shared/testing_path.robot
72 | Resource | resources/libraries/robot/shared/traffic.robot
73 | Resource | resources/libraries/robot/shared/vm.robot
74
75 *** Keywords ***
76 | Configure crypto device on all DUTs
77 | | [Documentation] | Verify if Crypto QAT device virtual functions are
78 | | ... | initialized on all DUTs. If parameter force_init is set to True, then
79 | | ... | try to initialize/disable.
80 | |
81 | | ... | *Arguments:*
82 | | ... | - crypto_type - Crypto device type - HW_DH895xcc or HW_C3xxx.
83 | | ... | Type: string, default value: HW_DH895xcc
84 | | ... | - numvfs - Number of VFs to initialize, 0 - disable the VFs
85 | | ... | Type: integer, default value: ${32}
86 | | ... | - force_init - Force to initialize. Type: boolean
87 | |
88 | | ... | *Example:*
89 | |
90 | | ... | \| Configure crypto device on all DUTs \| HW_DH895xcc \| ${32} \|
91 | |
92 | | [Arguments] | ${crypto_type} | ${numvfs} | ${force_init}=${False}
93 | |
94 | | FOR | ${dut} | IN | @{duts}
95 | | | Crypto Device Verify | ${nodes['${dut}']} | ${crypto_type}
96 | | | ... | ${numvfs} | force_init=${force_init}
97 | | END
98
99 | Configure kernel module on all DUTs
100 | | [Documentation] | Verify if specific kernel module is loaded on all DUTs.
101 | | ... | If parameter force_load is set to True, then try to load.
102 | |
103 | | ... | *Arguments:*
104 | | ... | - module - Module to verify. Type: string
105 | | ... | - force_load - Try to load module. Type: boolean
106 | |
107 | | ... | *Example:*
108 | |
109 | | ... | \| Configure kernel module on all DUTs \| ${True} \|
110 | |
111 | | [Arguments] | ${module} | ${force_load}=${False}
112 | |
113 | | Verify Kernel Module on All DUTs | ${nodes} | ${module}
114 | | ... | force_load=${force_load}
115
116 | Get Keyname for DUT
117 | | [Documentation]
118 | | ... | Get the Keyname for the DUT in the keyname list.
119 | | ... | Returns lowercase keyname value.
120 | |
121 | | ... | *Arguments:*
122 | | ... | - dutx - DUT to find keyname. Type: dict
123 | | ... | - dut_keys - DUT Keynames to search. Type: list
124 | |
125 | | ... | *Example:*
126 | |
127 | | ... | \| Get Keyname for DUT \| ${dutx} \| ${duts} \|
128 | |
129 | | [Arguments] | ${dutx} | ${dut_keys}
130 | |
131 | | FOR | ${key} | IN | @{dut_keys}
132 | | | ${found_key} | ${value}= | Run Keyword and Ignore Error
133 | | | ... | Dictionaries Should Be Equal | ${nodes['${key}']} | ${dutx}
134 | | | Run Keyword If | '${found_key}' == 'PASS' | EXIT FOR LOOP
135 | | END
136 | | Run Keyword If | '${found_key}' != 'PASS'
137 | | ... | Fail | Keyname for ${dutx} not found
138 | | ${keyname}= | Convert To Lowercase | ${key}
139 | | Return From Keyword | ${keyname}
140
141 | Create base startup configuration of VPP on all DUTs
142 | | [Documentation] | Create base startup configuration of VPP to all DUTs.
143 | |
144 | | FOR | ${dut} | IN | @{duts}
145 | | | Import Library | resources.libraries.python.VppConfigGenerator
146 | | | ... | WITH NAME | ${dut}
147 | | | Run keyword | ${dut}.Set Node |  ${nodes['${dut}']} | node_key=${dut}
148 | | | Run keyword | ${dut}.Add Unix Log
149 | | | Run keyword | ${dut}.Add Unix CLI Listen
150 | | | Run keyword | ${dut}.Add Unix Nodaemon
151 | | | Run keyword | ${dut}.Add Unix Coredump
152 | | | Run keyword | ${dut}.Add Socksvr | ${SOCKSVR_PATH}
153 | | | Run keyword | ${dut}.Add Heapsize | 4G
154 | | | Run keyword | ${dut}.Add Statseg size | 4G
155 | | | Run keyword | ${dut}.Add Statseg Per Node Counters | on
156 | | | Run keyword | ${dut}.Add Plugin | disable | default
157 | | | Run keyword | ${dut}.Add Plugin | enable | @{plugins_to_enable}
158 | | | Run keyword | ${dut}.Add IP6 Hash Buckets | 2000000
159 | | | Run keyword | ${dut}.Add IP6 Heap Size | 4G
160 | | | Run keyword | ${dut}.Add IP Heap Size | 4G
161 | | END
162
163 | Add worker threads to all DUTs
164 | | [Documentation] | Setup worker threads in vpp startup configuration on all
165 | | ... | DUTs. Based on the SMT configuration of DUT if enabled keyword will
166 | | ... | automatically map also the sibling logical cores.
167 | | ... | Keyword will automatically set the appropriate test TAGs in format
168 | | ... | mTnC, where m=logical_core_count and n=physical_core_count.
169 | | ... | RXQ are computed automatically by dividing thread count with number 2
170 | | ... | (TODO: Add division by actual number of interfaces). User can manually
171 | | ... | override RX, RXD, TXD parameters if needed.
172 | |
173 | | ... | *Arguments:*
174 | | ... | - phy_cores - Number of physical cores to use. Type: integer
175 | | ... | - rx_queues - Number of RX queues. Type: integer
176 | | ... | - rxd - Number of RX descriptors. Type: integer
177 | | ... | - txd - Number of TX descriptors. Type: integer
178 | |
179 | | ... | *Example:*
180 | |
181 | | ... | \| Add worker threads to all DUTs \| ${1} \| ${1} \|
182 | |
183 | | [Arguments] | ${phy_cores} | ${rx_queues}=${None} | ${rxd}=${None}
184 | | ... | ${txd}=${None}
185 | |
186 | | ${cpu_count_int} | Convert to Integer | ${phy_cores}
187 | | ${thr_count_int} | Convert to Integer | ${phy_cores}
188 | | ${rxd_count_int}= | Set variable | ${rxd}
189 | | ${txd_count_int}= | Set variable | ${txd}
190 | | FOR | ${dut} | IN | @{duts}
191 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
192 | | | ... | Variable Should Exist | ${${dut}_if1}
193 | | | @{if_list}= | Run Keyword If | '${if1_status}' == 'PASS'
194 | | | ... | Create List | ${${dut}_if1}
195 | | | ... | ELSE | Create List | ${${dut}_if1_1} | ${${dut}_if1_2}
196 | | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
197 | | | ... | Variable Should Exist | ${${dut}_if2}
198 | | | Run Keyword If | '${if2_status}' == 'PASS'
199 | | | ... | Append To List | ${if_list} | ${${dut}_if2}
200 | | | ... | ELSE
201 | | | ... | Append To List | ${if_list} | ${${dut}_if2_1} | ${${dut}_if2_2}
202 | | | ${numa}= | Get interfaces numa node | ${nodes['${dut}']} | @{if_list}
203 | | | ${smt_used}= | Is SMT enabled | ${nodes['${dut}']['cpuinfo']}
204 | | | ${skip_cnt}= | Set variable | ${CPU_CNT_SYSTEM}
205 | | | ${cpu_main}= | Cpu list per node str | ${nodes['${dut}']} | ${numa}
206 | | | ... | skip_cnt=${skip_cnt} | cpu_cnt=${CPU_CNT_MAIN}
207 | | | ${skip_cnt}= | Evaluate | ${CPU_CNT_SYSTEM} + ${CPU_CNT_MAIN}
208 | | | ${cpu_wt}= | Run keyword if | ${cpu_count_int} > 0 |
209 | | | ... | Cpu list per node str | ${nodes['${dut}']} | ${numa}
210 | | | ... | skip_cnt=${skip_cnt} | cpu_cnt=${cpu_count_int}
211 | | | ... | smt_used=${smt_used}
212 | | | ${thr_count_int}= | Run keyword if | ${smt_used}
213 | | | ... | Evaluate | int(${cpu_count_int}*2)
214 | | | ... | ELSE | Set variable | ${thr_count_int}
215 | | | ${rxq_count_int}= | Run keyword if | ${rx_queues}
216 | | | ... | Set variable | ${rx_queues}
217 | | | ... | ELSE | Evaluate | int(${thr_count_int}/2)
218 | | | ${rxq_count_int}= | Run keyword if | ${rxq_count_int} == 0
219 | | | ... | Set variable | ${1}
220 | | | ... | ELSE | Set variable | ${rxq_count_int}
221 | | | Run keyword if | ${cpu_count_int} > 0
222 | | | ... | ${dut}.Add CPU Main Core | ${cpu_main}
223 | | | Run keyword if | ${cpu_count_int} > 0
224 | | | ... | ${dut}.Add CPU Corelist Workers | ${cpu_wt}
225 | | | Run keyword if | ${smt_used}
226 | | | ... | Run keyword | ${dut}.Add Buffers Per Numa | ${215040} | ELSE
227 | | | ... | Run keyword | ${dut}.Add Buffers Per Numa | ${107520}
228 | | | ${ipsec} | Get Match Count | ${TEST TAGS} | IPSEC
229 | | | ... | case_insensitive=True
230 | | | Run keyword if | ${ipsec} and ${jumbo}
231 | | | ... | ${dut}.Add Buffers Default Data Size | 9200
232 | | | Run keyword if | ${thr_count_int} > 1
233 | | | ... | Set Tags | MTHREAD | ELSE | Set Tags | STHREAD
234 | | | Set Tags | ${thr_count_int}T${cpu_count_int}C
235 | | END
236 | | Set Test Variable | ${smt_used}
237 | | Set Test Variable | ${thr_count_int}
238 | | Set Test Variable | ${cpu_count_int}
239 | | Set Test Variable | ${rxq_count_int}
240 | | Set Test Variable | ${rxd_count_int}
241 | | Set Test Variable | ${txd_count_int}
242
243 | Add DPDK pci devices to all DUTs
244 | | [Documentation]
245 | | ... | Add PCI devices to VPP configuration file.
246 | |
247 | | FOR | ${dut} | IN | @{duts}
248 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
249 | | | ... | Variable Should Exist | ${${dut}_if1}
250 | | | ${if1_pci}= | Run Keyword If | '${if1_status}' == 'PASS'
251 | | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1}
252 | | | ${if1_1_pci}= | Run Keyword Unless | '${if1_status}' == 'PASS'
253 | | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1_1}
254 | | | ${if1_2_pci}= | Run Keyword Unless | '${if1_status}' == 'PASS'
255 | | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1_2}
256 | | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
257 | | | ... | Variable Should Exist | ${${dut}_if2}
258 | | | ${if2_pci}= | Run Keyword If | '${if2_status}' == 'PASS'
259 | | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if2}
260 | | | ${if2_1_pci}= | Run Keyword Unless | '${if2_status}' == 'PASS'
261 | | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if2_1}
262 | | | ${if2_2_pci}= | Run Keyword Unless | '${if2_status}' == 'PASS'
263 | | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if2_2}
264 | | | @{pci_devs}= | Run Keyword If | '${if1_status}' == 'PASS'
265 | | | ... | Create List | ${if1_pci}
266 | | | ... | ELSE
267 | | | ... | Create List | ${if1_1_pci} | ${if1_2_pci}
268 | | | Run Keyword If | '${if2_status}' == 'PASS'
269 | | | ... | Append To List | ${pci_devs} | ${if2_pci}
270 | | | ... | ELSE
271 | | | ... | Append To List | ${pci_devs} | ${if2_1_pci} | ${if2_2_pci}
272 | | | Run keyword | ${dut}.Add DPDK Dev | @{pci_devs}
273 | | | Run Keyword If | '${if1_status}' == 'PASS'
274 | | | ... | Set Test Variable | ${${dut}_if1_pci} | ${if1_pci}
275 | | | Run Keyword Unless | '${if1_status}' == 'PASS'
276 | | | ... | Set Test Variable | ${${dut}_if1_1_pci} | ${if1_1_pci}
277 | | | Run Keyword Unless | '${if1_status}' == 'PASS'
278 | | | ... | Set Test Variable | ${${dut}_if1_2_pci} | ${if1_2_pci}
279 | | | Run Keyword If | '${if2_status}' == 'PASS'
280 | | | ... | Set Test Variable | ${${dut}_if2_pci} | ${if2_pci}
281 | | | Run Keyword Unless | '${if2_status}' == 'PASS'
282 | | | ... | Set Test Variable | ${${dut}_if2_1_pci} | ${if2_1_pci}
283 | | | Run Keyword Unless | '${if2_status}' == 'PASS'
284 | | | ... | Set Test Variable | ${${dut}_if2_2_pci} | ${if2_2_pci}
285 | | END
286
287 | Add DPDK no PCI to all DUTs
288 | | [Documentation] | Add DPDK no-pci to VPP startup configuration to all DUTs.
289 | |
290 | | FOR | ${dut} | IN | @{duts}
291 | | | Run keyword | ${dut}.Add DPDK no PCI
292 | | END
293
294 | Add VLAN strip offload switch off between DUTs in 3-node single link topology
295 | | [Documentation]
296 | | ... | Add VLAN Strip Offload switch off on PCI devices between DUTs to VPP
297 | | ... | configuration file.
298 | |
299 | | Run keyword | DUT1.Add DPDK Dev Parameter | ${dut1_if2_pci}
300 | | ... | vlan-strip-offload | off
301 | | Run keyword | DUT2.Add DPDK Dev Parameter | ${dut2_if1_pci}
302 | | ... | vlan-strip-offload | off
303
304 | Add VLAN strip offload switch off between DUTs in 3-node double link topology
305 | | [Documentation]
306 | | ... | Add VLAN Strip Offload switch off on PCI devices between DUTs to VPP
307 | | ... | configuration file
308 | |
309 | | Run keyword | DUT1.Add DPDK Dev Parameter | ${dut1_if2_1_pci}
310 | | ... | vlan-strip-offload | off
311 | | Run keyword | DUT1.Add DPDK Dev Parameter | ${dut1_if2_2_pci}
312 | | ... | vlan-strip-offload | off
313 | | Run keyword | DUT2.Add DPDK Dev Parameter | ${dut2_if1_1_pci}
314 | | ... | vlan-strip-offload | off
315 | | Run keyword | DUT2.Add DPDK Dev Parameter | ${dut2_if1_2_pci}
316 | | ... | vlan-strip-offload | off
317
318 | Add NAT to all DUTs
319 | | [Documentation] | Add NAT configuration to all DUTs.
320 | |
321 | | FOR | ${dut} | IN | @{duts}
322 | | | Run keyword | ${dut}.Add NAT
323 | | END
324
325 | Write startup configuration on all VPP DUTs
326 | | [Documentation] | Write VPP startup configuration without restarting VPP.
327 | |
328 | | FOR | ${dut} | IN | @{duts}
329 | | | Run keyword | ${dut}.Write Config
330 | | END
331
332 | Apply startup configuration on all VPP DUTs
333 | | [Documentation] | Write VPP startup configuration and restart VPP on all
334 | | ... | DUTs.
335 | |
336 | | ... | *Arguments:*
337 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
338 | |
339 | | ... | *Example:*
340 | |
341 | | ... | \| Apply startup configuration on all VPP DUTs \| False \|
342 | |
343 | | [Arguments] | ${with_trace}=${False}
344 | |
345 | | FOR | ${dut} | IN | @{duts}
346 | | | Run keyword | ${dut}.Apply Config
347 | | END
348 | | Save VPP PIDs
349 | | Enable Coredump Limit VPP on All DUTs | ${nodes}
350 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${True}
351 | | Run keyword If | ${with_trace} | VPP Enable Traces On All Duts | ${nodes}
352
353 | Apply startup configuration on VPP DUT
354 | | [Documentation] | Write VPP startup configuration and restart VPP DUT.
355 | |
356 | | ... | *Arguments:*
357 | | ... | - dut - DUT on which to apply the configuration. Type: string
358 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
359 | |
360 | | [Arguments] | ${dut} | ${with_trace}=${False}
361 | |
362 | | Run keyword | ${dut}.Apply Config
363 | | Save VPP PIDs on DUT | ${dut}
364 | | Enable Coredump Limit VPP on DUT | ${nodes['${dut}']}
365 | | ${dutnode}= | Copy Dictionary | ${nodes}
366 | | Keep In Dictionary | ${dutnode} | ${dut}
367 | | Update All Interface Data On All Nodes | ${dutnode} | skip_tg=${True}
368 | | Run keyword If | ${with_trace} | VPP Enable Traces On Dut
369 | | ... | ${nodes['${dut}']}
370
371 | Save VPP PIDs
372 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and\
373 | | ... | set it as a test variable. The PIDs are stored as dictionary items\
374 | | ... | where the key is the host and the value is the PID.
375 | |
376 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
377 | | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
378 | | ${duts}= | Get Matches | ${nodes} | DUT*
379 | | FOR | ${key} | IN | @{keys}
380 | | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
381 | | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
382 | | END
383 | | Set Test Variable | ${setup_vpp_pids}
384
385 | Save VPP PIDs on DUT
386 | | [Documentation] | Get PID of VPP processes from DUT and\
387 | | ... | set it as a test variable. The PID is stored as dictionary item\
388 | | ... | where the key is the host and the value is the PID.
389 | |
390 | | [Arguments] | ${dut}
391 | |
392 | | ${vpp_pids}= | Get VPP PID | ${nodes['${dut}']}
393 | | Run Keyword If | ${vpp_pids} is None | FAIL
394 | | ... | No VPP PID found on node ${nodes['${dut}']['host']
395 | | ${status} | ${message}= | Run Keyword And Ignore Error
396 | | ... | Variable Should Exist | ${setup_vpp_pids}
397 | | ${setup_vpp_pids}= | Run Keyword If | '${status}' == 'FAIL'
398 | | ... | Create Dictionary | ${nodes['${dut}']['host']}=${vpp_pids}
399 | | ... | ELSE | Set To Dictionary | ${setup_vpp_pids}
400 | | ... | ${nodes['${dut}']['host']}=${vpp_pids}
401 | | Set Test Variable | ${setup_vpp_pids}
402
403 | Verify VPP PID in Teardown
404 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end\
405 | | ... | of test as they were at the begining. If they are not, only a message\
406 | | ... | is printed on console and to log. The test will not fail.
407 | |
408 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
409 | | ${err_msg}= | Catenate | ${SUITE NAME} - ${TEST NAME}
410 | | ... | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
411 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
412 | | ${rc} | ${msg}= | Run keyword and ignore error
413 | | ... | Dictionaries Should Be Equal
414 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
415 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
416 | | ... | console=yes | level=WARN