7fa0222f786447afacc44b27ff03123ee84b09ec
[csit.git] / resources / libraries / robot / shared / default.robot
1 # Copyright (c) 2021 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.Adl
24 | Library | resources.libraries.python.Classify
25 | Library | resources.libraries.python.CpuUtils
26 | Library | resources.libraries.python.CoreDumpUtil
27 | Library | resources.libraries.python.DUTSetup
28 | Library | resources.libraries.python.FlowUtil
29 | Library | resources.libraries.python.L2Util
30 | Library | resources.libraries.python.InterfaceUtil
31 | Library | resources.libraries.python.IPUtil
32 | Library | resources.libraries.python.IPv6Util
33 | Library | resources.libraries.python.IrqUtil
34 | Library | resources.libraries.python.model.export_json
35 | Library | resources.libraries.python.NodePath
36 | Library | resources.libraries.python.Namespaces
37 | Library | resources.libraries.python.PapiHistory
38 | Library | resources.libraries.python.SchedUtils
39 | Library | resources.libraries.python.Tap
40 | Library | resources.libraries.python.Tap.TapFeatureMask
41 | Library | resources.libraries.python.TestConfig
42 | Library | resources.libraries.python.TGSetup
43 | Library | resources.libraries.python.topology.Topology
44 | Library | resources.libraries.python.Trace
45 | Library | resources.libraries.python.VhostUser.VirtioFeatureMask
46 | Library | resources.libraries.python.VppCounters
47 | Library | resources.libraries.python.VPPUtil
48 |
49 | Resource | resources/libraries/robot/lb/load_balancer.robot
50 | Resource | resources/libraries/robot/crypto/ipsec.robot
51 | Resource | resources/libraries/robot/features/acl.robot
52 | Resource | resources/libraries/robot/features/policer.robot
53 | Resource | resources/libraries/robot/ip/ip4.robot
54 | Resource | resources/libraries/robot/ip/ip6.robot
55 | Resource | resources/libraries/robot/ip/nat.robot
56 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
57 | Resource | resources/libraries/robot/l2/l2_patch.robot
58 | Resource | resources/libraries/robot/l2/l2_traffic.robot
59 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
60 | Resource | resources/libraries/robot/l2/tagging.robot
61 | Resource | resources/libraries/robot/overlay/srv6.robot
62 | Resource | resources/libraries/robot/overlay/lisp.robot
63 | Resource | resources/libraries/robot/overlay/lispgpe.robot
64 | Resource | resources/libraries/robot/overlay/lisp_api.robot
65 | Resource | resources/libraries/robot/performance/performance_utils.robot
66 | Resource | resources/libraries/robot/shared/interfaces.robot
67 | Resource | resources/libraries/robot/shared/container.robot
68 | Resource | resources/libraries/robot/shared/memif.robot
69 | Resource | resources/libraries/robot/shared/suite_teardown.robot
70 | Resource | resources/libraries/robot/shared/suite_setup.robot
71 | Resource | resources/libraries/robot/shared/test_teardown.robot
72 | Resource | resources/libraries/robot/shared/test_setup.robot
73 | Resource | resources/libraries/robot/shared/traffic.robot
74 | Resource | resources/libraries/robot/shared/vm.robot
75
76 *** Variables ***
77 | ${cpu_alloc_str}= | ${0}
78 | ${page_size}= | ${DEFAULT_HUGEPAGE_SIZE}
79
80 *** Keywords ***
81 | Call Resetter
82 | | [Documentation]
83 | | ... | Check for a presence of test variable \${resetter}.
84 | | ... | If it exists (and not None), call the resetter (as a Python callable).
85 | | ... | This is usually used to reset any state on DUT before next trial.
86 | |
87 | | ... | TODO: Move to a more specific library if needed.
88 | |
89 | | ... | *Example:*
90 | |
91 | | ... | \| Call Resetter \|
92 | |
93 | | ${resetter} = | Get Resetter
94 | | # See http://robotframework.org/robotframework/3.1.2/libraries/BuiltIn.html
95 | | # #Evaluating%20expressions for $variable (without braces) syntax.
96 | | # Parens are there to perform the call.
97 | | Run Keyword If | $resetter | Evaluate | $resetter()
98
99 | Configure crypto device on all DUTs
100 | | [Documentation] | Verify if Crypto QAT device virtual functions are
101 | | ... | initialized on all DUTs. If parameter force_init is set to True, then
102 | | ... | try to initialize/disable.
103 | |
104 | | ... | *Arguments:*
105 | | ... | - crypto_type - Crypto device type - HW_DH895xcc or HW_C3xxx; default
106 | | ... | value: HW_DH895xcc. Type: string
107 | | ... | - numvfs - Number of VFs to initialize, 0 - disable the VFs; default
108 | | ... | value: ${32} Type: integer
109 | | ... | - force_init - Force to initialize. Type: boolean
110 | |
111 | | ... | *Example:*
112 | |
113 | | ... | \| Configure crypto device on all DUTs \| HW_DH895xcc \| ${32} \|
114 | |
115 | | [Arguments] | ${crypto_type} | ${numvfs} | ${force_init}=${False}
116 | |
117 | | FOR | ${dut} | IN | @{duts}
118 | | | Crypto Device Verify | ${nodes['${dut}']} | ${crypto_type}
119 | | | ... | ${numvfs} | force_init=${force_init}
120 | | END
121
122 | Configure kernel module on all DUTs
123 | | [Documentation] | Verify if specific kernel module is loaded on all DUTs.
124 | | ... | If parameter force_load is set to True, then try to load.
125 | |
126 | | ... | *Arguments:*
127 | | ... | - module - Module to verify. Type: string
128 | | ... | - force_load - Try to load module. Type: boolean
129 | |
130 | | ... | *Example:*
131 | |
132 | | ... | \| Configure kernel module on all DUTs \| ${True} \|
133 | |
134 | | [Arguments] | ${module} | ${force_load}=${False}
135 | |
136 | | Verify Kernel Module on All DUTs | ${nodes} | ${module}
137 | | ... | force_load=${force_load}
138
139 | Get Keyname for DUT
140 | | [Documentation]
141 | | ... | Get the Keyname for the DUT in the keyname list.
142 | | ... | Returns lowercase keyname value.
143 | |
144 | | ... | *Arguments:*
145 | | ... | - dutx - DUT to find keyname. Type: dict
146 | | ... | - dut_keys - DUT Keynames to search. Type: list
147 | |
148 | | ... | *Example:*
149 | |
150 | | ... | \| Get Keyname for DUT \| ${dutx} \| ${duts} \|
151 | |
152 | | [Arguments] | ${dutx} | ${dut_keys}
153 | |
154 | | FOR | ${key} | IN | @{dut_keys}
155 | | | ${found_key} | ${value}= | Run Keyword And Ignore Error
156 | | | ... | Dictionaries Should Be Equal | ${nodes['${key}']} | ${dutx}
157 | | | Run Keyword If | '${found_key}' == 'PASS' | EXIT FOR LOOP
158 | | END
159 | | Run Keyword If | '${found_key}' != 'PASS'
160 | | ... | Fail | Keyname for ${dutx} not found
161 | | ${keyname}= | Convert To Lowercase | ${key}
162 | | Return From Keyword | ${keyname}
163
164 | Create base startup configuration of VPP on all DUTs
165 | | [Documentation] | Create base startup configuration of VPP to all DUTs.
166 | |
167 | | FOR | ${dut} | IN | @{duts}
168 | | | Import Library | resources.libraries.python.VppConfigGenerator
169 | | | ... | WITH NAME | ${dut}
170 | | | Run Keyword | ${dut}.Set Node | ${nodes['${dut}']} | node_key=${dut}
171 | | | Run Keyword | ${dut}.Add Unix Log
172 | | | Run Keyword | ${dut}.Add Unix CLI Listen
173 | | | Run Keyword | ${dut}.Add Unix Nodaemon
174 | | | Run Keyword | ${dut}.Add Unix Coredump
175 | | | Run Keyword | ${dut}.Add Socksvr | ${SOCKSVR_PATH}
176 | | | Run Keyword | ${dut}.Add Main Heap Size | ${${heap_size_mult}*${2}}G
177 | | | Run Keyword | ${dut}.Add Main Heap Page Size | ${page_size}
178 | | | Run Keyword | ${dut}.Add Default Hugepage Size | ${page_size}
179 | | | Run Keyword | ${dut}.Add Statseg Size | 2G
180 | | | Run Keyword | ${dut}.Add Statseg Page Size | ${page_size}
181 | | | Run Keyword | ${dut}.Add Statseg Per Node Counters | on
182 | | | Run Keyword | ${dut}.Add Plugin | disable | default
183 | | | Run Keyword | ${dut}.Add Plugin | enable | @{plugins_to_enable}
184 | | | Run Keyword | ${dut}.Add IP6 Hash Buckets | 2000000
185 | | | Run Keyword | ${dut}.Add IP6 Heap Size | 4G
186 | | | Run Keyword | ${dut}.Add Graph Node Variant | ${GRAPH_NODE_VARIANT}
187 | | END
188
189 | Add worker threads to all DUTs
190 | | [Documentation] | Setup worker threads in vpp startup configuration on all
191 | | ... | DUTs. Based on the SMT configuration of DUT if enabled keyword will
192 | | ... | automatically map also the sibling logical cores.
193 | | ... | Keyword will automatically set the appropriate test TAGs in format
194 | | ... | mTnC, where m=logical_core_count and n=physical_core_count.
195 | | ... | User can manually override RXQ, RXD, TXD parameters if needed.
196 | |
197 | | ... | *Arguments:*
198 | | ... | - phy_cores - Number of physical cores to use. Type: integer
199 | | ... | - rx_queues - Number of RX queues. Type: integer
200 | | ... | - rxd - Number of RX descriptors. Type: integer
201 | | ... | - txd - Number of TX descriptors. Type: integer
202 | |
203 | | ... | *Example:*
204 | |
205 | | ... | \| Add worker threads to all DUTs \| ${1} \| ${1} \|
206 | |
207 | | [Arguments] | ${phy_cores} | ${rx_queues}=${None} | ${rxd}=${None}
208 | | ... | ${txd}=${None}
209 | |
210 | | FOR | ${dut} | IN | @{duts}
211 | | | &{compute_resource_info}= | Get Affinity Vswitch
212 | | | ... | ${nodes} | ${dut} | ${phy_cores} | rx_queues=${rx_queues}
213 | | | ... | rxd=${rxd} | txd=${txd}
214 | | | Set Test Variable | &{compute_resource_info}
215 | | | Create compute resources variables
216 | | | Run Keyword | ${dut}.Add CPU Main Core | ${cpu_main}
217 | | | Run Keyword If | ${cpu_count_int} > 0
218 | | | ... | ${dut}.Add CPU Corelist Workers | ${cpu_wt}
219 | | | Run Keyword | ${dut}.Add Buffers Per Numa | ${buffers_numa}
220 | | END
221
222 | Create compute resources variables
223 | | [Documentation]
224 | | ... | Create compute resources variables
225 | |
226 | | ... | _NOTE:_ This KW sets various suite variables based on computed
227 | | ... | resources.
228 | |
229 | | ${variables}= | Get Dictionary Keys | ${compute_resource_info}
230 | | FOR | ${variable} | IN | @{variables}
231 | | | ${value}= | Get From Dictionary | ${compute_resource_info} | ${variable}
232 | | | Set Test Variable | ${${variable}} | ${value}
233 | | END
234 | | Run Keyword If | ${dp_count_int} > 1
235 | | ... | Set Tags | MTHREAD | ELSE | Set Tags | STHREAD
236 | | Set Tags | ${dp_count_int}T${cpu_count_int}C
237
238 | Add DPDK VLAN strip offload switch off between DUTs
239 | | [Documentation]
240 | | ... | Add VLAN Strip Offload switch off on PCI devices between DUTs to VPP
241 | | ... | configuration file.
242 | |
243 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
244 | | | ${_even}= | Evaluate | ${pf} % 2
245 | | | Run Keyword Unless | ${even}
246 | | | ... | DUT1.Add DPDK Dev Parameter | ${DUT1_${int}${pf}_pci}[0]
247 | | | ... | vlan-strip-offload | off
248 | | END
249 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
250 | | | ${_even}= | Evaluate | ${pf} % 2
251 | | | Run Keyword If | ${even}
252 | | | ... | DUT2.Add DPDK Dev Parameter | ${DUT2_${int}${pf}_pci}[0]
253 | | | ... | vlan-strip-offload | off
254 | | END
255
256 | Add NAT to all DUTs
257 | | [Documentation] | Add NAT configuration to all DUTs.
258 | |
259 | | ... | *Arguments:*
260 | | ... | - nat_mode - NAT mode; default value: deterministic. Type: string
261 | |
262 | | ... | *Example:*
263 | |
264 | | ... | \| Add NAT to all DUTs \| nat_mode=endpoint-dependent \|
265 | |
266 | | [Arguments] | ${nat_mode}=deterministic
267 | |
268 | | FOR | ${dut} | IN | @{duts}
269 | | | Run Keyword | ${dut}.Add NAT | value=${nat_mode}
270 | | END
271
272 | Add NAT max translations per thread to all DUTs
273 | | [Documentation] | Add NAT maximum number of translations per thread
274 | | ... | configuration.
275 | |
276 | | ... | *Arguments:*
277 | | ... | - max_translations_per_thread - NAT maximum number of translations per
278 | | ... | thread. Type: string
279 | |
280 | | ... | *Example:*
281 | |
282 | | ... | \| Add NAT translation memory to all DUTs \
283 | | ... | \| max_translations_per_thread=2048 \|
284 | |
285 | | [Arguments] | ${max_translations_per_thread}=1024
286 | |
287 | | FOR | ${dut} | IN | @{duts}
288 | | | Run Keyword | ${dut}.Add NAT max translations per thread
289 | | | ... | value=${max_translations_per_thread}
290 | | END
291
292 | Write startup configuration on all VPP DUTs
293 | | [Documentation] | Write VPP startup configuration without restarting VPP.
294 | |
295 | | FOR | ${dut} | IN | @{duts}
296 | | | Run Keyword | ${dut}.Write Config
297 | | END
298
299 | Apply startup configuration on all VPP DUTs
300 | | [Documentation] | Write VPP startup configuration and restart VPP on all
301 | | ... | DUTs.
302 | |
303 | | ... | *Arguments:*
304 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
305 | |
306 | | ... | *Example:*
307 | |
308 | | ... | \| Apply startup configuration on all VPP DUTs \| False \|
309 | |
310 | | [Arguments] | ${with_trace}=${False}
311 | |
312 | | FOR | ${dut} | IN | @{duts}
313 | | | Run Keyword | ${dut}.Apply Config
314 | | END
315 | | Save VPP PIDs
316 | | Enable Coredump Limit VPP on All DUTs | ${nodes}
317 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${True}
318 | | Run Keyword If | ${with_trace} | VPP Enable Traces On All Duts | ${nodes}
319
320 | Apply startup configuration on VPP DUT
321 | | [Documentation] | Write VPP startup configuration and restart VPP DUT.
322 | |
323 | | ... | *Arguments:*
324 | | ... | - dut - DUT on which to apply the configuration. Type: string
325 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
326 | |
327 | | [Arguments] | ${dut} | ${with_trace}=${False}
328 | |
329 | | Run Keyword | ${dut}.Apply Config
330 | | Save VPP PIDs on DUT | ${dut}
331 | | Enable Coredump Limit VPP on DUT | ${nodes['${dut}']}
332 | | ${dutnode}= | Copy Dictionary | ${nodes}
333 | | Keep In Dictionary | ${dutnode} | ${dut}
334 | | Update All Interface Data On All Nodes | ${dutnode} | skip_tg=${True}
335 | | Run Keyword If | ${with_trace} | VPP Enable Traces On Dut
336 | | ... | ${nodes['${dut}']}
337
338 | Get And Export DPDK Version
339 | | [Documentation] | Add version to test export as detected on DUT1.
340 | |
341 | | ... | *Example:*
342 | |
343 | | ... | \| Get And Export DPDK Version \|
344 | |
345 | | ${version} = | Get Dpdk Version | ${nodes}[DUT1]
346 | | Export Dut Type And Version | DPDK | ${version}
347
348 | Save VPP PIDs
349 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and\
350 | | ... | set it as a test variable. The PIDs are stored as dictionary items\
351 | | ... | where the key is the host and the value is the PID.
352 | |
353 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
354 | | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
355 | | FOR | ${key} | IN | @{keys}
356 | | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
357 | | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
358 | | END
359 | | Set Test Variable | ${setup_vpp_pids}
360
361 | Save VPP PIDs on DUT
362 | | [Documentation] | Get PID of VPP processes from DUT and\
363 | | ... | set it as a test variable. The PID is stored as dictionary item\
364 | | ... | where the key is the host and the value is the PID.
365 | |
366 | | [Arguments] | ${dut}
367 | |
368 | | ${vpp_pids}= | Get VPP PID | ${nodes['${dut}']}
369 | | Run Keyword If | ${vpp_pids} is None | FAIL
370 | | ... | No VPP PID found on node ${nodes['${dut}']['host']
371 | | ${status} | ${message}= | Run Keyword And Ignore Error
372 | | ... | Variable Should Exist | ${setup_vpp_pids}
373 | | ${setup_vpp_pids}= | Run Keyword If | '${status}' == 'FAIL'
374 | | ... | Create Dictionary | ${nodes['${dut}']['host']}=${vpp_pids}
375 | | ... | ELSE | Set To Dictionary | ${setup_vpp_pids}
376 | | ... | ${nodes['${dut}']['host']}=${vpp_pids}
377 | | Set Test Variable | ${setup_vpp_pids}
378
379 | Verify VPP PID in Teardown
380 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end\
381 | | ... | of test as they were at the begining. If they are not, only a message\
382 | | ... | is printed on console and to log. The test will not fail.
383 | |
384 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
385 | | ${err_msg}= | Catenate | ${SUITE NAME} - ${TEST NAME}
386 | | ... | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
387 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
388 | | ${rc} | ${msg}= | Run Keyword And Ignore Error
389 | | ... | Dictionaries Should Be Equal
390 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
391 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
392 | | ... | console=yes | level=WARN