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