6e1136761cdb1e8fe0a46cf1d3fcd0fed1aad330
[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 | Additional Suite Setup Action For scapy
115 | | [Documentation]
116 | | ... | Additional Setup for suites which uses scapy as Traffic generator.
117 | |
118 | | FOR | ${dut} | IN | @{duts}
119 | | | Set Suite Variable | ${${dut}_vf1} | ${${dut}_${int}1}
120 | | | Set Suite Variable | ${${dut}_vf2} | ${${dut}_${int}2}
121 | | END
122 | | Set Interface State | ${tg} | ${TG_pf1}[0] | up
123 | | Set Interface State | ${tg} | ${TG_pf2}[0] | up
124
125 | Additional Suite Setup Action For dpdk
126 | | [Documentation]
127 | | ... | Additional Setup for suites which uses dpdk.
128 | |
129 | | FOR | ${dut} | IN | @{duts}
130 | | | Initialize DPDK Framework | ${nodes['${dut}']}
131 | | | ... | ${${dut}_${int}1}[0] | ${${dut}_${int}2}[0] | ${nic_driver}
132 | | END
133
134 | Additional Suite Setup Action For performance vf
135 | | [Documentation]
136 | | ... | Additional Setup for suites which uses performance measurement for
137 | | ... | single DUT (inner loop).
138 | |
139 | | ... | *Arguments:*
140 | | ... | - dut - DUT node. Type: string
141 | |
142 | | ... | *Example:*
143 | |
144 | | ... | \| Additional Suite Setup Action For performance vf \| DUT1 \|
145 | |
146 | | [Arguments] | ${dut}
147 | |
148 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
149 | | | ${_vf}=
150 | | | ... | Run Keyword | Init interface
151 | | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | driver=${nic_driver}
152 | | | ... | numvfs=${nic_vfs} | osi_layer=${osi_layer}
153 | | | ${_mac}=
154 | | | ... | Create List | ${EMPTY}
155 | | | ${_ip4_addr}=
156 | | | ... | Create List | ${EMPTY}
157 | | | ${_ip4_prefix}=
158 | | | ... | Create List | ${EMPTY}
159 | | | ${_pci}=
160 | | | ... | Create List | ${EMPTY}
161 | | | ${_vlan}=
162 | | | ... | Create List | ${EMPTY}
163 | | | Set Suite Variable
164 | | | ... | ${${dut}_prevf${pf}} | ${_vf}
165 | | | Set Suite Variable
166 | | | ... | ${${dut}_prevf${pf}_ip4_addr} | ${_ip4_addr}
167 | | | Set Suite Variable
168 | | | ... | ${${dut}_prevf${pf}_ip4_prefix} | ${_ip4_prefix}
169 | | | Set Suite Variable
170 | | | ... | ${${dut}_prevf${pf}_mac} | ${_mac}
171 | | | Set Suite Variable
172 | | | ... | ${${dut}_prevf${pf}_pci} | ${_pci}
173 | | | Set Suite Variable
174 | | | ... | ${${dut}_prevf${pf}_vlan} | ${_vlan}
175 | | END
176 | | Set Suite Variable
177 | | ... | ${int} | prevf
178
179 | Additional Suite Setup Action For performance pf
180 | | [Documentation]
181 | | ... | Additional Setup for suites which uses performance measurement for
182 | | ... | single DUT (inner loop).
183 | |
184 | | ... | *Arguments:*
185 | | ... | - dut - DUT node. Type: string
186 | |
187 | | ... | *Example:*
188 | |
189 | | ... | \| Additional Suite Setup Action For performance pf \| DUT1 \|
190 | |
191 | | [Arguments] | ${dut}
192 | |
193 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
194 | | | Run Keyword | Init interface
195 | | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | driver=${nic_driver}
196 | | | ... | numvfs=${0} | osi_layer=${osi_layer}
197 | | END
198
199 | Additional Suite Setup Action For performance
200 | | [Documentation]
201 | | ... | Additional Setup for suites which uses performance measurement.
202 | |
203 | | FOR | ${dut} | IN | @{duts}
204 | | | Run Keyword If | ${nic_vfs} > 0
205 | | | ... | Additional Suite Setup Action For performance vf | ${dut}
206 | | | ... | ELSE
207 | | | ... | Additional Suite Setup Action For performance pf | ${dut}
208 | | END
209 | | Initialize traffic generator
210 | | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
211 | | ... | ${dut1} | ${DUT1_${int}1}[0]
212 | | ... | ${dut${duts_count}} | ${DUT${duts_count}_${int}2}[0]
213 | | ... | ${osi_layer}
214
215 | Additional Suite Setup Action For ipsechw
216 | | [Documentation]
217 | | ... | Additional Setup for suites which uses QAT HW.
218 | |
219 | | ${numvfs}= | Set Variable If
220 | | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
221 | | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
222 | | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
223 | | ... | force_init=${True}
224 | | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
225
226 | Additional Suite Setup Action For nginx
227 | | [Documentation]
228 | | ... | Additional Setup for suites which uses Nginx.
229 | |
230 | | Install NGINX framework on all DUTs | ${nodes} | ${packages_dir}
231 | | ... |  ${nginx_version}
232
233 | Additional Suite Setup Action For ab
234 | | [Documentation]
235 | | ... | Additional Setup for suites which uses ab TG.
236 | |
237 | | Verify Program Installed | ${tg} | ab
238 | | Iface update numa node | ${tg}
239 | | ${running}= | Is TRex running | ${tg}
240 | | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
241 | | ${curr_driver}= | Get PCI dev driver | ${tg}
242 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
243 | | Run keyword if | '${curr_driver}'!='${None}'
244 | | ... | PCI Driver Unbind | ${tg} |
245 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
246 | | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
247 | | PCI Driver Bind | ${tg}
248 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
249 | | ${intf_name}= | Get Linux interface name | ${tg}
250 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
251 | | FOR | ${ip_addr} | IN | @{ab_ip_addrs}
252 | | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
253 | | | ... | ${ip_addr} | ${ab_ip_prefix}
254 | | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
255 | | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${ab_ip_prefix}
256 | | END
257 | | Set Linux interface up | ${tg} | ${intf_name}
258 | | Check ab | ${tg}