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