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