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