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