feat(Performance): Add 2M/1G hugepages
[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.NodePath
35 | Library | resources.libraries.python.Namespaces
36 | Library | resources.libraries.python.PapiHistory
37 | Library | resources.libraries.python.SchedUtils
38 | Library | resources.libraries.python.Tap
39 | Library | resources.libraries.python.Tap.TapFeatureMask
40 | Library | resources.libraries.python.TestConfig
41 | Library | resources.libraries.python.TGSetup
42 | Library | resources.libraries.python.topology.Topology
43 | Library | resources.libraries.python.Trace
44 | Library | resources.libraries.python.VhostUser.VirtioFeatureMask
45 | Library | resources.libraries.python.VppCounters
46 | Library | resources.libraries.python.VPPUtil
47 |
48 | Resource | resources/libraries/robot/lb/load_balancer.robot
49 | Resource | resources/libraries/robot/crypto/ipsec.robot
50 | Resource | resources/libraries/robot/features/acl.robot
51 | Resource | resources/libraries/robot/features/policer.robot
52 | Resource | resources/libraries/robot/ip/ip4.robot
53 | Resource | resources/libraries/robot/ip/ip6.robot
54 | Resource | resources/libraries/robot/ip/nat.robot
55 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
56 | Resource | resources/libraries/robot/l2/l2_patch.robot
57 | Resource | resources/libraries/robot/l2/l2_traffic.robot
58 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
59 | Resource | resources/libraries/robot/l2/tagging.robot
60 | Resource | resources/libraries/robot/overlay/srv6.robot
61 | Resource | resources/libraries/robot/overlay/lisp.robot
62 | Resource | resources/libraries/robot/overlay/lispgpe.robot
63 | Resource | resources/libraries/robot/overlay/lisp_api.robot
64 | Resource | resources/libraries/robot/performance/performance_utils.robot
65 | Resource | resources/libraries/robot/shared/interfaces.robot
66 | Resource | resources/libraries/robot/shared/container.robot
67 | Resource | resources/libraries/robot/shared/memif.robot
68 | Resource | resources/libraries/robot/shared/suite_teardown.robot
69 | Resource | resources/libraries/robot/shared/suite_setup.robot
70 | Resource | resources/libraries/robot/shared/test_teardown.robot
71 | Resource | resources/libraries/robot/shared/test_setup.robot
72 | Resource | resources/libraries/robot/shared/traffic.robot
73 | Resource | resources/libraries/robot/shared/vm.robot
74
75 *** Variables ***
76 | ${cpu_alloc_str}= | ${0}
77 | ${page_size}= | ${DEFAULT_HUGEPAGE_SIZE}
78
79 *** Keywords ***
80 | Call Resetter
81 | | [Documentation]
82 | | ... | Check for a presence of test variable \${resetter}.
83 | | ... | If it exists (and not None), call the resetter (as a Python callable).
84 | | ... | This is usually used to reset any state on DUT before next trial.
85 | |
86 | | ... | TODO: Move to a more specific library if needed.
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 Nodaemon
173 | | | Run Keyword | ${dut}.Add Unix Coredump
174 | | | Run Keyword | ${dut}.Add Socksvr | ${SOCKSVR_PATH}
175 | | | Run Keyword | ${dut}.Add Main Heap Size | ${${heap_size_mult}*${2}}G
176 | | | Run Keyword | ${dut}.Add Main Heap Page Size | ${page_size}
177 | | | Run Keyword | ${dut}.Add Default Hugepage Size | ${page_size}
178 | | | Run Keyword | ${dut}.Add Statseg Size | 2G
179 | | | Run Keyword | ${dut}.Add Statseg Page Size | ${page_size}
180 | | | Run Keyword | ${dut}.Add Statseg Per Node Counters | on
181 | | | Run Keyword | ${dut}.Add Plugin | disable | default
182 | | | Run Keyword | ${dut}.Add Plugin | enable | @{plugins_to_enable}
183 | | | Run Keyword | ${dut}.Add IP6 Hash Buckets | 2000000
184 | | | Run Keyword | ${dut}.Add IP6 Heap Size | 4G
185 | | | Run Keyword | ${dut}.Add Graph Node Variant | ${GRAPH_NODE_VARIANT}
186 | | END
187
188 | Add worker threads to all DUTs
189 | | [Documentation] | Setup worker threads in vpp startup configuration on all
190 | | ... | DUTs. Based on the SMT configuration of DUT if enabled keyword will
191 | | ... | automatically map also the sibling logical cores.
192 | | ... | Keyword will automatically set the appropriate test TAGs in format
193 | | ... | mTnC, where m=logical_core_count and n=physical_core_count.
194 | | ... | User can manually override RXQ, RXD, TXD parameters if needed.
195 | |
196 | | ... | *Arguments:*
197 | | ... | - phy_cores - Number of physical cores to use. Type: integer
198 | | ... | - rx_queues - Number of RX queues. Type: integer
199 | | ... | - rxd - Number of RX descriptors. Type: integer
200 | | ... | - txd - Number of TX descriptors. Type: integer
201 | |
202 | | ... | *Example:*
203 | |
204 | | ... | \| Add worker threads to all DUTs \| ${1} \| ${1} \|
205 | |
206 | | [Arguments] | ${phy_cores} | ${rx_queues}=${None} | ${rxd}=${None}
207 | | ... | ${txd}=${None}
208 | |
209 | | FOR | ${dut} | IN | @{duts}
210 | | | &{compute_resource_info}= | Get Affinity Vswitch
211 | | | ... | ${nodes} | ${dut} | ${phy_cores} | rx_queues=${rx_queues}
212 | | | ... | rxd=${rxd} | txd=${txd}
213 | | | Set Test Variable | &{compute_resource_info}
214 | | | Create compute resources variables
215 | | | Run Keyword | ${dut}.Add CPU Main Core | ${cpu_main}
216 | | | Run Keyword If | ${cpu_count_int} > 0
217 | | | ... | ${dut}.Add CPU Corelist Workers | ${cpu_wt}
218 | | | Run Keyword | ${dut}.Add Buffers Per Numa | ${buffers_numa}
219 | | END
220
221 | Create compute resources variables
222 | | [Documentation]
223 | | ... | Create compute resources variables
224 | |
225 | | ... | _NOTE:_ This KW sets various suite variables based on computed
226 | | ... | resources.
227 | |
228 | | ${variables}= | Get Dictionary Keys | ${compute_resource_info}
229 | | FOR | ${variable} | IN | @{variables}
230 | | | ${value}= | Get From Dictionary | ${compute_resource_info} | ${variable}
231 | | | Set Test Variable | ${${variable}} | ${value}
232 | | END
233 | | Run Keyword If | ${dp_count_int} > 1
234 | | ... | Set Tags | MTHREAD | ELSE | Set Tags | STHREAD
235 | | Set Tags | ${dp_count_int}T${cpu_count_int}C
236
237 | Add DPDK VLAN strip offload switch off between DUTs
238 | | [Documentation]
239 | | ... | Add VLAN Strip Offload switch off on PCI devices between DUTs to VPP
240 | | ... | configuration file.
241 | |
242 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
243 | | | ${_even}= | Evaluate | ${pf} % 2
244 | | | Run Keyword Unless | ${even}
245 | | | ... | DUT1.Add DPDK Dev Parameter | ${DUT1_${int}${pf}_pci}[0]
246 | | | ... | vlan-strip-offload | off
247 | | END
248 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
249 | | | ${_even}= | Evaluate | ${pf} % 2
250 | | | Run Keyword If | ${even}
251 | | | ... | DUT2.Add DPDK Dev Parameter | ${DUT2_${int}${pf}_pci}[0]
252 | | | ... | vlan-strip-offload | off
253 | | END
254
255 | Add NAT to all DUTs
256 | | [Documentation] | Add NAT configuration to all DUTs.
257 | |
258 | | ... | *Arguments:*
259 | | ... | - nat_mode - NAT mode; default value: deterministic. Type: string
260 | |
261 | | ... | *Example:*
262 | |
263 | | ... | \| Add NAT to all DUTs \| nat_mode=endpoint-dependent \|
264 | |
265 | | [Arguments] | ${nat_mode}=deterministic
266 | |
267 | | FOR | ${dut} | IN | @{duts}
268 | | | Run Keyword | ${dut}.Add NAT | value=${nat_mode}
269 | | END
270
271 | Add NAT max translations per thread to all DUTs
272 | | [Documentation] | Add NAT maximum number of translations per thread
273 | | ... | configuration.
274 | |
275 | | ... | *Arguments:*
276 | | ... | - max_translations_per_thread - NAT maximum number of translations per
277 | | ... | thread. Type: string
278 | |
279 | | ... | *Example:*
280 | |
281 | | ... | \| Add NAT translation memory to all DUTs \
282 | | ... | \| max_translations_per_thread=2048 \|
283 | |
284 | | [Arguments] | ${max_translations_per_thread}=1024
285 | |
286 | | FOR | ${dut} | IN | @{duts}
287 | | | Run Keyword | ${dut}.Add NAT max translations per thread
288 | | | ... | value=${max_translations_per_thread}
289 | | END
290
291 | Write startup configuration on all VPP DUTs
292 | | [Documentation] | Write VPP startup configuration without restarting VPP.
293 | |
294 | | FOR | ${dut} | IN | @{duts}
295 | | | Run Keyword | ${dut}.Write Config
296 | | END
297
298 | Apply startup configuration on all VPP DUTs
299 | | [Documentation] | Write VPP startup configuration and restart VPP on all
300 | | ... | DUTs.
301 | |
302 | | ... | *Arguments:*
303 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
304 | |
305 | | ... | *Example:*
306 | |
307 | | ... | \| Apply startup configuration on all VPP DUTs \| False \|
308 | |
309 | | [Arguments] | ${with_trace}=${False}
310 | |
311 | | FOR | ${dut} | IN | @{duts}
312 | | | Run Keyword | ${dut}.Apply Config
313 | | END
314 | | Save VPP PIDs
315 | | Enable Coredump Limit VPP on All DUTs | ${nodes}
316 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${True}
317 | | Run Keyword If | ${with_trace} | VPP Enable Traces On All Duts | ${nodes}
318
319 | Apply startup configuration on VPP DUT
320 | | [Documentation] | Write VPP startup configuration and restart VPP DUT.
321 | |
322 | | ... | *Arguments:*
323 | | ... | - dut - DUT on which to apply the configuration. Type: string
324 | | ... | - with_trace - Enable packet trace after VPP restart Type: boolean
325 | |
326 | | [Arguments] | ${dut} | ${with_trace}=${False}
327 | |
328 | | Run Keyword | ${dut}.Apply Config
329 | | Save VPP PIDs on DUT | ${dut}
330 | | Enable Coredump Limit VPP on DUT | ${nodes['${dut}']}
331 | | ${dutnode}= | Copy Dictionary | ${nodes}
332 | | Keep In Dictionary | ${dutnode} | ${dut}
333 | | Update All Interface Data On All Nodes | ${dutnode} | skip_tg=${True}
334 | | Run Keyword If | ${with_trace} | VPP Enable Traces On Dut
335 | | ... | ${nodes['${dut}']}
336
337 | Save VPP PIDs
338 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and\
339 | | ... | set it as a test variable. The PIDs are stored as dictionary items\
340 | | ... | where the key is the host and the value is the PID.
341 | |
342 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
343 | | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
344 | | FOR | ${key} | IN | @{keys}
345 | | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
346 | | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
347 | | END
348 | | Set Test Variable | ${setup_vpp_pids}
349
350 | Save VPP PIDs on DUT
351 | | [Documentation] | Get PID of VPP processes from DUT and\
352 | | ... | set it as a test variable. The PID is stored as dictionary item\
353 | | ... | where the key is the host and the value is the PID.
354 | |
355 | | [Arguments] | ${dut}
356 | |
357 | | ${vpp_pids}= | Get VPP PID | ${nodes['${dut}']}
358 | | Run Keyword If | ${vpp_pids} is None | FAIL
359 | | ... | No VPP PID found on node ${nodes['${dut}']['host']
360 | | ${status} | ${message}= | Run Keyword And Ignore Error
361 | | ... | Variable Should Exist | ${setup_vpp_pids}
362 | | ${setup_vpp_pids}= | Run Keyword If | '${status}' == 'FAIL'
363 | | ... | Create Dictionary | ${nodes['${dut}']['host']}=${vpp_pids}
364 | | ... | ELSE | Set To Dictionary | ${setup_vpp_pids}
365 | | ... | ${nodes['${dut}']['host']}=${vpp_pids}
366 | | Set Test Variable | ${setup_vpp_pids}
367
368 | Verify VPP PID in Teardown
369 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end\
370 | | ... | of test as they were at the begining. If they are not, only a message\
371 | | ... | is printed on console and to log. The test will not fail.
372 | |
373 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
374 | | ${err_msg}= | Catenate | ${SUITE NAME} - ${TEST NAME}
375 | | ... | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
376 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
377 | | ${rc} | ${msg}= | Run Keyword And Ignore Error
378 | | ... | Dictionaries Should Be Equal
379 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
380 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
381 | | ... | console=yes | level=WARN