feat(infra): Remove system.d dependency
[csit.git] / resources / libraries / robot / shared / default.robot
1 # Copyright (c) 2023 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.ExportJson
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.VppConfigGenerator.VppInitConfig
47 | Library | resources.libraries.python.VppCounters
48 | Library | resources.libraries.python.VPPUtil
49 |
50 | Resource | resources/libraries/robot/lb/load_balancer.robot
51 | Resource | resources/libraries/robot/crypto/ipsec.robot
52 | Resource | resources/libraries/robot/features/acl.robot
53 | Resource | resources/libraries/robot/features/policer.robot
54 | Resource | resources/libraries/robot/ip/ip4.robot
55 | Resource | resources/libraries/robot/ip/ip6.robot
56 | Resource | resources/libraries/robot/ip/nat.robot
57 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
58 | Resource | resources/libraries/robot/l2/l2_patch.robot
59 | Resource | resources/libraries/robot/l2/l2_traffic.robot
60 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
61 | Resource | resources/libraries/robot/l2/tagging.robot
62 | Resource | resources/libraries/robot/overlay/srv6.robot
63 | Resource | resources/libraries/robot/overlay/lisp.robot
64 | Resource | resources/libraries/robot/overlay/lispgpe.robot
65 | Resource | resources/libraries/robot/overlay/lisp_api.robot
66 | Resource | resources/libraries/robot/performance/performance_utils.robot
67 | Resource | resources/libraries/robot/shared/interfaces.robot
68 | Resource | resources/libraries/robot/shared/container.robot
69 | Resource | resources/libraries/robot/shared/memif.robot
70 | Resource | resources/libraries/robot/shared/suite_teardown.robot
71 | Resource | resources/libraries/robot/shared/suite_setup.robot
72 | Resource | resources/libraries/robot/shared/test_teardown.robot
73 | Resource | resources/libraries/robot/shared/test_setup.robot
74 | Resource | resources/libraries/robot/shared/traffic.robot
75 | Resource | resources/libraries/robot/shared/vm.robot
76
77 *** Variables ***
78 | ${cpu_alloc_str}= | ${0}
79 | ${page_size}= | ${DEFAULT_HUGEPAGE_SIZE}
80
81 *** Keywords ***
82 | Call Resetter
83 | | [Documentation]
84 | | ... | Check for a presence of test variable \${resetter}.
85 | | ... | If it exists (and not None), call the resetter (as a Python callable).
86 | | ... | This is usually used to reset any state on DUT before next trial.
87 | |
88 | | ... | *Example:*
89 | |
90 | | ... | \| Call Resetter \|
91 | |
92 | | ${resetter} = | Get Resetter
93 | | # See http://robotframework.org/robotframework/3.1.2/libraries/BuiltIn.html
94 | | # #Evaluating%20expressions for $variable (without braces) syntax.
95 | | # Parens are there to perform the call.
96 | | Run Keyword If | $resetter | Evaluate | $resetter()
97
98 | Configure crypto device on all DUTs
99 | | [Documentation] | Verify if Crypto QAT device virtual functions are
100 | | ... | initialized on all DUTs. If parameter force_init is set to True, then
101 | | ... | try to initialize/disable.
102 | |
103 | | ... | *Arguments:*
104 | | ... | - crypto_type - Crypto device type - HW_DH895xcc or HW_C3xxx; default
105 | | ... | value: HW_DH895xcc. Type: string
106 | | ... | - numvfs - Number of VFs to initialize, 0 - disable the VFs; default
107 | | ... | value: ${32} Type: integer
108 | | ... | - force_init - Force to initialize. Type: boolean
109 | |
110 | | ... | *Example:*
111 | |
112 | | ... | \| Configure crypto device on all DUTs \| HW_DH895xcc \| ${32} \|
113 | |
114 | | [Arguments] | ${crypto_type} | ${numvfs} | ${force_init}=${False}
115 | |
116 | | FOR | ${dut} | IN | @{duts}
117 | | | Crypto Device Verify | ${nodes['${dut}']} | ${crypto_type}
118 | | | ... | ${numvfs} | force_init=${force_init}
119 | | END
120
121 | Configure kernel module on all DUTs
122 | | [Documentation] | Verify if specific kernel module is loaded on all DUTs.
123 | | ... | If parameter force_load is set to True, then try to load.
124 | |
125 | | ... | *Arguments:*
126 | | ... | - module - Module to verify. Type: string
127 | | ... | - force_load - Try to load module. Type: boolean
128 | |
129 | | ... | *Example:*
130 | |
131 | | ... | \| Configure kernel module on all DUTs \| ${True} \|
132 | |
133 | | [Arguments] | ${module} | ${force_load}=${False}
134 | |
135 | | Verify Kernel Module on All DUTs | ${nodes} | ${module}
136 | | ... | force_load=${force_load}
137
138 | Get Keyname for DUT
139 | | [Documentation]
140 | | ... | Get the Keyname for the DUT in the keyname list.
141 | | ... | Returns lowercase keyname value.
142 | |
143 | | ... | *Arguments:*
144 | | ... | - dutx - DUT to find keyname. Type: dict
145 | | ... | - dut_keys - DUT Keynames to search. Type: list
146 | |
147 | | ... | *Example:*
148 | |
149 | | ... | \| Get Keyname for DUT \| ${dutx} \| ${duts} \|
150 | |
151 | | [Arguments] | ${dutx} | ${dut_keys}
152 | |
153 | | FOR | ${key} | IN | @{dut_keys}
154 | | | ${found_key} | ${value}= | Run Keyword And Ignore Error
155 | | | ... | Dictionaries Should Be Equal | ${nodes['${key}']} | ${dutx}
156 | | | Run Keyword If | '${found_key}' == 'PASS' | EXIT FOR LOOP
157 | | END
158 | | Run Keyword If | '${found_key}' != 'PASS'
159 | | ... | Fail | Keyname for ${dutx} not found
160 | | ${keyname}= | Convert To Lowercase | ${key}
161 | | Return From Keyword | ${keyname}
162
163 | Create base startup configuration of VPP on all DUTs
164 | | [Documentation] | Create base startup configuration of VPP to all DUTs.
165 | |
166 | | FOR | ${dut} | IN | @{duts}
167 | | | Import Library | resources.libraries.python.VppConfigGenerator
168 | | | ... | WITH NAME | ${dut}
169 | | | Run Keyword | ${dut}.Set Node | ${nodes['${dut}']} | node_key=${dut}
170 | | | Run Keyword | ${dut}.Add Unix Log
171 | | | Run Keyword | ${dut}.Add Unix CLI Listen
172 | | | Run Keyword | ${dut}.Add Unix CLI No Pager
173 | | | Run Keyword | ${dut}.Add Unix GID
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 NAT to all DUTs
239 | | [Documentation] | Add NAT configuration to all DUTs.
240 | |
241 | | ... | *Arguments:*
242 | | ... | - nat_mode - NAT mode; default value: deterministic. Type: string
243 | |
244 | | ... | *Example:*
245 | |
246 | | ... | \| Add NAT to all DUTs \| nat_mode=endpoint-dependent \|
247 | |
248 | | [Arguments] | ${nat_mode}=deterministic
249 | |
250 | | FOR | ${dut} | IN | @{duts}
251 | | | Run Keyword | ${dut}.Add NAT | value=${nat_mode}
252 | | END
253
254 | Add NAT max translations per thread to all DUTs
255 | | [Documentation] | Add NAT maximum number of translations per thread
256 | | ... | configuration.
257 | |
258 | | ... | *Arguments:*
259 | | ... | - max_translations_per_thread - NAT maximum number of translations per
260 | | ... | thread. Type: string
261 | |
262 | | ... | *Example:*
263 | |
264 | | ... | \| Add NAT translation memory to all DUTs \
265 | | ... | \| max_translations_per_thread=2048 \|
266 | |
267 | | [Arguments] | ${max_translations_per_thread}=1024
268 | |
269 | | FOR | ${dut} | IN | @{duts}
270 | | | Run Keyword | ${dut}.Add NAT max translations per thread
271 | | | ... | value=${max_translations_per_thread}
272 | | END
273
274 | Write startup configuration on all VPP DUTs
275 | | [Documentation] | Write VPP startup configuration without restarting VPP.
276 | |
277 | | FOR | ${dut} | IN | @{duts}
278 | | | Run Keyword | ${dut}.Write Config
279 | | END
280
281 | Apply startup configuration on all VPP DUTs
282 | | [Documentation] | Write VPP startup configuration and restart VPP on all
283 | | ... | DUTs.
284 | |
285 | | ... | *Arguments:*
286 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
287 | |
288 | | ... | *Example:*
289 | |
290 | | ... | \| Apply startup configuration on all VPP DUTs \| False \|
291 | |
292 | | [Arguments] | ${with_trace}=${False}
293 | |
294 | | FOR | ${dut} | IN | @{duts}
295 | | | Run Keyword | ${dut}.Apply Config
296 | | END
297 | | Save VPP PIDs
298 | | Enable Coredump Limit VPP on All DUTs | ${nodes}
299 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${True}
300 | | Run Keyword If | ${with_trace} | VPP Enable Traces On All Duts | ${nodes}
301
302 | Apply startup configuration on VPP DUT
303 | | [Documentation] | Write VPP startup configuration and restart VPP DUT.
304 | |
305 | | ... | *Arguments:*
306 | | ... | - dut - DUT on which to apply the configuration. Type: string
307 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
308 | |
309 | | [Arguments] | ${dut} | ${with_trace}=${False}
310 | |
311 | | Run Keyword | ${dut}.Apply Config
312 | | Save VPP PIDs on DUT | ${dut}
313 | | Enable Coredump Limit VPP on DUT | ${nodes['${dut}']}
314 | | ${dutnode}= | Copy Dictionary | ${nodes}
315 | | Keep In Dictionary | ${dutnode} | ${dut}
316 | | Update All Interface Data On All Nodes | ${dutnode} | skip_tg=${True}
317 | | Run Keyword If | ${with_trace} | VPP Enable Traces On Dut
318 | | ... | ${nodes['${dut}']}
319
320 | Save VPP PIDs
321 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and\
322 | | ... | set it as a test variable. The PIDs are stored as dictionary items\
323 | | ... | where the key is the host and the value is the PID.
324 | |
325 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
326 | | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
327 | | FOR | ${key} | IN | @{keys}
328 | | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
329 | | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
330 | | END
331 | | Set Test Variable | ${setup_vpp_pids}
332
333 | Save VPP PIDs on DUT
334 | | [Documentation] | Get PID of VPP processes from DUT and\
335 | | ... | set it as a test variable. The PID is stored as dictionary item\
336 | | ... | where the key is the host and the value is the PID.
337 | |
338 | | [Arguments] | ${dut}
339 | |
340 | | ${vpp_pids}= | Get VPP PID | ${nodes['${dut}']}
341 | | Run Keyword If | ${vpp_pids} is None | FAIL
342 | | ... | No VPP PID found on node ${nodes['${dut}']['host']
343 | | ${status} | ${message}= | Run Keyword And Ignore Error
344 | | ... | Variable Should Exist | ${setup_vpp_pids}
345 | | ${setup_vpp_pids}= | Run Keyword If | '${status}' == 'FAIL'
346 | | ... | Create Dictionary | ${nodes['${dut}']['host']}=${vpp_pids}
347 | | ... | ELSE | Set To Dictionary | ${setup_vpp_pids}
348 | | ... | ${nodes['${dut}']['host']}=${vpp_pids}
349 | | Set Test Variable | ${setup_vpp_pids}
350
351 | Verify VPP PID in Teardown
352 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end\
353 | | ... | of test as they were at the begining. If they are not, only a message\
354 | | ... | is printed on console and to log. The test will not fail.
355 | |
356 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
357 | | ${err_msg}= | Catenate | ${SUITE NAME} - ${TEST NAME}
358 | | ... | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
359 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
360 | | ${rc} | ${msg}= | Run Keyword And Ignore Error
361 | | ... | Dictionaries Should Be Equal
362 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
363 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
364 | | ... | console=yes | level=WARN