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