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