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