fix(uti): Add TG type export
[csit.git] / resources / libraries / robot / shared / default.robot
1 # Copyright (c) 2022 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 CLI No Pager
174 | | | Run Keyword | ${dut}.Add Unix Nodaemon
175 | | | Run Keyword | ${dut}.Add Unix Coredump
176 | | | Run Keyword | ${dut}.Add Socksvr | ${SOCKSVR_PATH}
177 | | | Run Keyword | ${dut}.Add Main Heap Size | ${${heap_size_mult}*${2}}G
178 | | | Run Keyword | ${dut}.Add Main Heap Page Size | ${page_size}
179 | | | Run Keyword | ${dut}.Add Default Hugepage Size | ${page_size}
180 | | | Run Keyword | ${dut}.Add Statseg Size | 2G
181 | | | Run Keyword | ${dut}.Add Statseg Page Size | ${page_size}
182 | | | Run Keyword | ${dut}.Add Statseg Per Node Counters | on
183 | | | Run Keyword | ${dut}.Add Plugin | disable | default
184 | | | Run Keyword | ${dut}.Add Plugin | enable | @{plugins_to_enable}
185 | | | Run Keyword | ${dut}.Add IP6 Hash Buckets | 2000000
186 | | | Run Keyword | ${dut}.Add IP6 Heap Size | 4G
187 | | | Run Keyword | ${dut}.Add Graph Node Variant | ${GRAPH_NODE_VARIANT}
188 | | END
189
190 | Add worker threads to all DUTs
191 | | [Documentation] | Setup worker threads in vpp startup configuration on all
192 | | ... | DUTs. Based on the SMT configuration of DUT if enabled keyword will
193 | | ... | automatically map also the sibling logical cores.
194 | | ... | Keyword will automatically set the appropriate test TAGs in format
195 | | ... | mTnC, where m=logical_core_count and n=physical_core_count.
196 | | ... | User can manually override RXQ, RXD, TXD parameters if needed.
197 | |
198 | | ... | *Arguments:*
199 | | ... | - phy_cores - Number of physical cores to use. Type: integer
200 | | ... | - rx_queues - Number of RX queues. Type: integer
201 | | ... | - rxd - Number of RX descriptors. Type: integer
202 | | ... | - txd - Number of TX descriptors. Type: integer
203 | |
204 | | ... | *Example:*
205 | |
206 | | ... | \| Add worker threads to all DUTs \| ${1} \| ${1} \|
207 | |
208 | | [Arguments] | ${phy_cores} | ${rx_queues}=${None} | ${rxd}=${None}
209 | | ... | ${txd}=${None}
210 | |
211 | | FOR | ${dut} | IN | @{duts}
212 | | | &{compute_resource_info}= | Get Affinity Vswitch
213 | | | ... | ${nodes} | ${dut} | ${phy_cores} | rx_queues=${rx_queues}
214 | | | ... | rxd=${rxd} | txd=${txd}
215 | | | Set Test Variable | &{compute_resource_info}
216 | | | Create compute resources variables
217 | | | Run Keyword | ${dut}.Add CPU Main Core | ${cpu_main}
218 | | | Run Keyword If | ${cpu_count_int} > 0
219 | | | ... | ${dut}.Add CPU Corelist Workers | ${cpu_wt}
220 | | | Run Keyword | ${dut}.Add Buffers Per Numa | ${buffers_numa}
221 | | END
222
223 | Create compute resources variables
224 | | [Documentation]
225 | | ... | Create compute resources variables
226 | |
227 | | ... | _NOTE:_ This KW sets various suite variables based on computed
228 | | ... | resources.
229 | |
230 | | ${variables}= | Get Dictionary Keys | ${compute_resource_info}
231 | | FOR | ${variable} | IN | @{variables}
232 | | | ${value}= | Get From Dictionary | ${compute_resource_info} | ${variable}
233 | | | Set Test Variable | ${${variable}} | ${value}
234 | | END
235 | | Run Keyword If | ${dp_count_int} > 1
236 | | ... | Set Tags | MTHREAD | ELSE | Set Tags | STHREAD
237 | | Set Tags | ${dp_count_int}T${cpu_count_int}C
238
239 | Add DPDK VLAN strip offload switch off between DUTs
240 | | [Documentation]
241 | | ... | Add VLAN Strip Offload switch off on PCI devices between DUTs to VPP
242 | | ... | configuration file.
243 | |
244 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
245 | | | ${_even}= | Evaluate | ${pf} % 2
246 | | | Run Keyword Unless | ${even}
247 | | | ... | DUT1.Add DPDK Dev Parameter | ${DUT1_${int}${pf}_pci}[0]
248 | | | ... | vlan-strip-offload | off
249 | | END
250 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
251 | | | ${_even}= | Evaluate | ${pf} % 2
252 | | | Run Keyword If | ${even}
253 | | | ... | DUT2.Add DPDK Dev Parameter | ${DUT2_${int}${pf}_pci}[0]
254 | | | ... | vlan-strip-offload | off
255 | | END
256
257 | Add NAT to all DUTs
258 | | [Documentation] | Add NAT configuration to all DUTs.
259 | |
260 | | ... | *Arguments:*
261 | | ... | - nat_mode - NAT mode; default value: deterministic. Type: string
262 | |
263 | | ... | *Example:*
264 | |
265 | | ... | \| Add NAT to all DUTs \| nat_mode=endpoint-dependent \|
266 | |
267 | | [Arguments] | ${nat_mode}=deterministic
268 | |
269 | | FOR | ${dut} | IN | @{duts}
270 | | | Run Keyword | ${dut}.Add NAT | value=${nat_mode}
271 | | END
272
273 | Add NAT max translations per thread to all DUTs
274 | | [Documentation] | Add NAT maximum number of translations per thread
275 | | ... | configuration.
276 | |
277 | | ... | *Arguments:*
278 | | ... | - max_translations_per_thread - NAT maximum number of translations per
279 | | ... | thread. Type: string
280 | |
281 | | ... | *Example:*
282 | |
283 | | ... | \| Add NAT translation memory to all DUTs \
284 | | ... | \| max_translations_per_thread=2048 \|
285 | |
286 | | [Arguments] | ${max_translations_per_thread}=1024
287 | |
288 | | FOR | ${dut} | IN | @{duts}
289 | | | Run Keyword | ${dut}.Add NAT max translations per thread
290 | | | ... | value=${max_translations_per_thread}
291 | | END
292
293 | Write startup configuration on all VPP DUTs
294 | | [Documentation] | Write VPP startup configuration without restarting VPP.
295 | |
296 | | FOR | ${dut} | IN | @{duts}
297 | | | Run Keyword | ${dut}.Write Config
298 | | END
299
300 | Apply startup configuration on all VPP DUTs
301 | | [Documentation] | Write VPP startup configuration and restart VPP on all
302 | | ... | DUTs.
303 | |
304 | | ... | *Arguments:*
305 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
306 | |
307 | | ... | *Example:*
308 | |
309 | | ... | \| Apply startup configuration on all VPP DUTs \| False \|
310 | |
311 | | [Arguments] | ${with_trace}=${False}
312 | |
313 | | FOR | ${dut} | IN | @{duts}
314 | | | Run Keyword | ${dut}.Apply Config
315 | | END
316 | | Save VPP PIDs
317 | | Enable Coredump Limit VPP on All DUTs | ${nodes}
318 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${True}
319 | | Run Keyword If | ${with_trace} | VPP Enable Traces On All Duts | ${nodes}
320
321 | Apply startup configuration on VPP DUT
322 | | [Documentation] | Write VPP startup configuration and restart VPP DUT.
323 | |
324 | | ... | *Arguments:*
325 | | ... | - dut - DUT on which to apply the configuration. Type: string
326 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
327 | |
328 | | [Arguments] | ${dut} | ${with_trace}=${False}
329 | |
330 | | Run Keyword | ${dut}.Apply Config
331 | | Save VPP PIDs on DUT | ${dut}
332 | | Enable Coredump Limit VPP on DUT | ${nodes['${dut}']}
333 | | ${dutnode}= | Copy Dictionary | ${nodes}
334 | | Keep In Dictionary | ${dutnode} | ${dut}
335 | | Update All Interface Data On All Nodes | ${dutnode} | skip_tg=${True}
336 | | Run Keyword If | ${with_trace} | VPP Enable Traces On Dut
337 | | ... | ${nodes['${dut}']}
338
339 | Save VPP PIDs
340 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and\
341 | | ... | set it as a test variable. The PIDs are stored as dictionary items\
342 | | ... | where the key is the host and the value is the PID.
343 | |
344 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
345 | | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
346 | | FOR | ${key} | IN | @{keys}
347 | | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
348 | | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
349 | | END
350 | | Set Test Variable | ${setup_vpp_pids}
351
352 | Save VPP PIDs on DUT
353 | | [Documentation] | Get PID of VPP processes from DUT and\
354 | | ... | set it as a test variable. The PID is stored as dictionary item\
355 | | ... | where the key is the host and the value is the PID.
356 | |
357 | | [Arguments] | ${dut}
358 | |
359 | | ${vpp_pids}= | Get VPP PID | ${nodes['${dut}']}
360 | | Run Keyword If | ${vpp_pids} is None | FAIL
361 | | ... | No VPP PID found on node ${nodes['${dut}']['host']
362 | | ${status} | ${message}= | Run Keyword And Ignore Error
363 | | ... | Variable Should Exist | ${setup_vpp_pids}
364 | | ${setup_vpp_pids}= | Run Keyword If | '${status}' == 'FAIL'
365 | | ... | Create Dictionary | ${nodes['${dut}']['host']}=${vpp_pids}
366 | | ... | ELSE | Set To Dictionary | ${setup_vpp_pids}
367 | | ... | ${nodes['${dut}']['host']}=${vpp_pids}
368 | | Set Test Variable | ${setup_vpp_pids}
369
370 | Verify VPP PID in Teardown
371 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end\
372 | | ... | of test as they were at the begining. If they are not, only a message\
373 | | ... | is printed on console and to log. The test will not fail.
374 | |
375 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
376 | | ${err_msg}= | Catenate | ${SUITE NAME} - ${TEST NAME}
377 | | ... | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
378 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
379 | | ${rc} | ${msg}= | Run Keyword And Ignore Error
380 | | ... | Dictionaries Should Be Equal
381 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
382 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
383 | | ... | console=yes | level=WARN