fix(core): TG export
[csit.git] / resources / libraries / robot / shared / suite_setup.robot
1 # Copyright (c) 2022 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 """Keywords used in suite setups."""
15
16 *** Settings ***
17 | Library | resources.libraries.python.DPDK.DPDKTools
18 | Library | resources.libraries.python.InterfaceUtil
19 | Library | resources.libraries.python.NGINX.NGINXTools
20 | Library | resources.tools.ab.ABTools
21 | Library | resources.libraries.python.Iperf3
22 | Library | resources.libraries.python.NodePath
23 | Library | resources.libraries.python.topology.Topology
24 | Library | resources.libraries.python.TrafficGenerator
25 | Variables | resources/libraries/python/Constants.py
26 |
27 | Documentation | Suite setup keywords.
28
29 *** Keywords ***
30 | Create suite topology variables
31 | | [Documentation]
32 | | ... | Create suite topology variables
33 | |
34 | | ... | _NOTE:_ This KW sets various suite variables based on filtered
35 | | ... | topology. All variables are set with also backward compatibility
36 | | ... | format dut{m}_if{n} (where the value type is string).
37 | | ... | List type allows to access physical interfaces in same way as
38 | | ... | virtual interface (e.g. SRIOV). This keeps abstracted compatibility
39 | | ... | between existing L1 and L2 KWs library and underlaying physical
40 | | ... | topology.
41 | |
42 | | ... | - duts - List of DUT nodes (name as seen in topology file).
43 | | ... | - duts_count - Number of DUT nodes.
44 | | ... | - int - Interfacy type (layer).
45 | | ... | Type: string
46 | | ... | - dut{n} - DUTx node.
47 | | ... | Type: dictionary
48 | | ... | - dut{m}_pf{n} - Nth interface of Mth DUT.
49 | | ... | Type: list
50 | | ... | - dut{m}_pf{n}_mac - Nth interface of Mth DUT - MAC address.
51 | | ... | Type: list
52 | | ... | - dut{m}_pf{n}_vlan - Nth interface of Mth DUT - VLAN id.
53 | | ... | Type: list
54 | | ... | - dut{m}_pf{n}_pci - Nth interface of Mth DUT - PCI address.
55 | | ... | Type: list
56 | | ... | - dut{m}_pf{n}_ip4_addr - Nth interface of Mth DUT - IPv4 address.
57 | | ... | Type: list
58 | | ... | - dut{m}_pf{n}_ip4_prefix - Nth interface of Mth DUT - IPv4 prefix.
59 | | ... | Type: list
60 | |
61 | | ... | *Arguments:*
62 | | ... | - @{actions} - Additional setup action. Type: list
63 | |
64 | | [Arguments] | @{actions}
65 | |
66 | | ${variables}= | Get Dictionary Keys | ${topology_info}
67 | | FOR | ${variable} | IN | @{variables}
68 | | | ${value}= | Get From Dictionary | ${topology_info} | ${variable}
69 | | | Set Suite Variable | ${${variable}} | ${value}
70 | | END
71 | | FOR | ${action} | IN | @{actions}
72 | | | Run Keyword | Additional Suite setup Action For ${action}
73 | | END
74
75 | Setup suite topology interfaces
76 | | [Documentation]
77 | | ... | Common suite setup for one to multiple link tests.
78 | | ... |
79 | | ... | Compute path for testing on given topology nodes in circular topology
80 | | ... | based on interface model provided as an argument and set
81 | | ... | corresponding suite variables.
82 | |
83 | | ... | *Arguments:*
84 | | ... | - ${actions} - Additional setup action. Type: list
85 | |
86 | | [Arguments] | @{actions}
87 | |
88 | | Start Suite Setup Export
89 | | ${nic_model_list}= | Create list | ${nic_name}
90 | | &{info}= | Compute Circular Topology
91 | | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
92 | | ... | always_same_link=${False} | topo_has_tg=${True}
93 | | Set suite variable | &{topology_info} | &{info}
94 | | Create suite topology variables | @{actions}
95 | | Finalize Suite Setup Export
96
97 | Setup suite topology interfaces with no TG
98 | | [Documentation]
99 | | ... | Common suite setup for single link tests with no traffic generator
100 | | ... | node.
101 | | ... |
102 | | ... | Compute path for testing on given topology nodes in circular topology
103 | | ... | based on interface model provided as an argument and set
104 | | ... | corresponding suite variables.
105 | |
106 | | ... | *Arguments:*
107 | | ... | - ${actions} - Additional setup action. Type: list
108 | |
109 | | [Arguments] | @{actions}
110 | |
111 | | Start Suite Setup Export
112 | | ${nic_model_list}= | Create list | ${nic_name}
113 | | &{info}= | Compute Circular Topology
114 | | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
115 | | ... | always_same_link=${True} | topo_has_tg=${False}
116 | | Set suite variable | &{topology_info} | &{info}
117 | | Create suite topology variables | @{actions}
118 | | Finalize Suite Setup Export
119
120 | Setup suite topology interfaces with no DUT
121 | | [Documentation]
122 | | ... | Common suite setup for single link tests with no device under test
123 | | ... | node.
124 | | ... |
125 | | ... | Compute path for testing on given topology nodes in circular topology
126 | | ... | based on interface model provided as an argument and set
127 | | ... | corresponding suite variables.
128 | |
129 | | ... | *Arguments:*
130 | | ... | - ${actions} - Additional setup action. Type: list
131 | |
132 | | [Arguments] | @{actions}
133 | |
134 | | Start Suite Setup Export
135 | | ${nic_model_list}= | Create list | ${nic_name}
136 | | &{info}= | Compute Circular Topology
137 | | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
138 | | ... | always_same_link=${True} | topo_has_tg=${True} | topo_has_dut=${False}
139 | | Set suite variable | &{topology_info} | &{info}
140 | | Create suite topology variables | @{actions}
141 | | Finalize Suite Setup Export
142
143 | Additional Suite Setup Action For scapy
144 | | [Documentation]
145 | | ... | Additional Setup for suites which uses scapy as Traffic generator.
146 | |
147 | | Export TG Type And Version | scapy | 2.4.3
148 | | FOR | ${dut} | IN | @{duts}
149 | | | Set Suite Variable | ${${dut}_vf1} | ${${dut}_${int}1}
150 | | | Set Suite Variable | ${${dut}_vf2} | ${${dut}_${int}2}
151 | | END
152 | | Set Interface State | ${tg} | ${TG_pf1}[0] | up
153 | | Set Interface State | ${tg} | ${TG_pf2}[0] | up
154
155 | Additional Suite Setup Action For dpdk
156 | | [Documentation]
157 | | ... | Additional Setup for suites which uses dpdk.
158 | |
159 | | ${version} = | Get Dpdk Version | ${nodes}[DUT1]
160 | | Export Dut Type And Version | dpdk | ${version}
161 | | FOR | ${dut} | IN | @{duts}
162 | | | Initialize DPDK Framework | ${nodes['${dut}']}
163 | | | ... | ${${dut}_${int}1}[0] | ${${dut}_${int}2}[0] | ${nic_driver}
164 | | END
165
166 | Additional Suite Setup Action For performance vf
167 | | [Documentation]
168 | | ... | Additional Setup for suites which uses performance measurement for
169 | | ... | single DUT (inner loop).
170 | |
171 | | ... | *Arguments:*
172 | | ... | - dut - DUT node. Type: string
173 | |
174 | | ... | *Example:*
175 | |
176 | | ... | \| Additional Suite Setup Action For performance vf \| DUT1 \|
177 | |
178 | | [Arguments] | ${dut}
179 | |
180 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
181 | | | ${_vf}=
182 | | | ... | Run Keyword | Init interface
183 | | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | driver=${nic_driver}
184 | | | ... | numvfs=${nic_vfs} | osi_layer=${osi_layer}
185 | | | ${_mac}=
186 | | | ... | Create List | ${EMPTY}
187 | | | ${_ip4_addr}=
188 | | | ... | Create List | ${EMPTY}
189 | | | ${_ip4_prefix}=
190 | | | ... | Create List | ${EMPTY}
191 | | | ${_pci}=
192 | | | ... | Create List | ${EMPTY}
193 | | | ${_vlan}=
194 | | | ... | Create List | ${EMPTY}
195 | | | Set Suite Variable
196 | | | ... | ${${dut}_prevf${pf}} | ${_vf}
197 | | | Set Suite Variable
198 | | | ... | ${${dut}_prevf${pf}_ip4_addr} | ${_ip4_addr}
199 | | | Set Suite Variable
200 | | | ... | ${${dut}_prevf${pf}_ip4_prefix} | ${_ip4_prefix}
201 | | | Set Suite Variable
202 | | | ... | ${${dut}_prevf${pf}_mac} | ${_mac}
203 | | | Set Suite Variable
204 | | | ... | ${${dut}_prevf${pf}_pci} | ${_pci}
205 | | | Set Suite Variable
206 | | | ... | ${${dut}_prevf${pf}_vlan} | ${_vlan}
207 | | END
208 | | Set Suite Variable
209 | | ... | ${int} | prevf
210
211 | Additional Suite Setup Action For performance pf
212 | | [Documentation]
213 | | ... | Additional Setup for suites which uses performance measurement for
214 | | ... | single DUT (inner loop).
215 | |
216 | | ... | *Arguments:*
217 | | ... | - dut - DUT node. Type: string
218 | |
219 | | ... | *Example:*
220 | |
221 | | ... | \| Additional Suite Setup Action For performance pf \| DUT1 \|
222 | |
223 | | [Arguments] | ${dut}
224 | |
225 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
226 | | | Run Keyword | Init interface
227 | | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | driver=${nic_driver}
228 | | | ... | numvfs=${0} | osi_layer=${osi_layer}
229 | | END
230
231 | Additional Suite Setup Action For performance
232 | | [Documentation]
233 | | ... | Additional Setup for suites which uses performance measurement.
234 | |
235 | | FOR | ${dut} | IN | @{duts}
236 | | | Run Keyword If | ${nic_vfs} > 0
237 | | | ... | Additional Suite Setup Action For performance vf | ${dut}
238 | | | ... | ELSE
239 | | | ... | Additional Suite Setup Action For performance pf | ${dut}
240 | | END
241 | | ${type} = | Get TG Type | ${nodes}[TG]
242 | | ${version} = | Get TG Version | ${nodes}[TG]
243 | | Export TG Type And Version | ${type} | ${version}
244 | | Initialize traffic generator
245 | | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
246 | | ... | ${dut1} | ${DUT1_${int}1}[0]
247 | | ... | ${dut${duts_count}} | ${DUT${duts_count}_${int}2}[0]
248 | | ... | ${osi_layer}
249
250 | Additional Suite Setup Action For performance_tg_nic
251 | | [Documentation]
252 | | ... | Additional Setup for suites which uses performance measurement
253 | | ... | for L1 cross connect tests
254 | |
255 | | ${type} = | Get TG Type | ${nodes}[TG]
256 | | ${version} = | Get TG Version | ${nodes}[TG]
257 | | Export Dut Type And Version | ${type} | ${version}
258 | | Export TG Type And Version | ${type} | ${version}
259 | | Initialize traffic generator
260 | | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
261 | | ... | ${tg} | ${TG_pf2}[0]
262 | | ... | ${tg} | ${TG_pf1}[0]
263 | | ... | ${osi_layer}
264
265 | Additional Suite Setup Action For iPerf3
266 | | [Documentation]
267 | | ... | Additional Setup for suites which uses performance measurement over
268 | | ... | iPerf3.
269 | |
270 | | ${type} = | Get iPerf Type | ${nodes}[TG]
271 | | ${version} = | Get iPerf Version | ${nodes}[TG]
272 | | Export TG Type And Version | ${type} | ${version}
273
274 | Additional Suite Setup Action For ipsechw
275 | | [Documentation]
276 | | ... | Additional Setup for suites which uses QAT HW.
277 | |
278 | | ${numvfs}= | Set Variable If
279 | | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
280 | | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
281 | | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
282 | | ... | force_init=${True}
283 | | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
284
285 | Additional Suite Setup Action For nginx
286 | | [Documentation]
287 | | ... | Additional Setup for suites which uses Nginx.
288 | |
289 | | Install NGINX framework on all DUTs | ${nodes} | ${packages_dir}
290 | | ... |  ${nginx_version}
291
292 | Additional Suite Setup Action For vppecho
293 | | [Documentation]
294 | | ... | Additional Setup for suites which uses performance measurement over
295 | | ... | VPP Echo.
296 | |
297 | | Export DUT Type And Version | ${DUT_TYPE} | ${DUT_VERSION}
298
299 | Additional Suite Setup Action For ab
300 | | [Documentation]
301 | | ... | Additional Setup for suites which uses ab TG.
302 | |
303 | | Iface update numa node | ${tg}
304 | | ${running}= | Is TRex running | ${tg}
305 | | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
306 | | ${curr_driver}= | Get PCI dev driver | ${tg}
307 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
308 | | Run keyword if | '${curr_driver}'!='${None}'
309 | | ... | PCI Driver Unbind | ${tg} |
310 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
311 | | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
312 | | PCI Driver Bind | ${tg}
313 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
314 | | ${intf_name}= | Get Linux interface name | ${tg}
315 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
316 | | FOR | ${ip_addr} | IN | @{ab_ip_addrs}
317 | | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
318 | | | ... | ${ip_addr} | ${ab_ip_prefix}
319 | | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
320 | | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${ab_ip_prefix}
321 | | END
322 | | Set Linux interface up | ${nodes}[TG] | ${intf_name}
323 | | Check AB | ${tg}
324 | | ${type} = | Get AB Type | ${nodes}[TG]
325 | | ${version} = | Get AB Version | ${nodes}[TG]
326 | | Export TG Type And Version | ${type} | ${version}