513cfe80450ec6c91f5d2c7d9c5b533f0501a055
[csit.git] / resources / libraries / robot / shared / suite_setup.robot
1 # Copyright (c) 2019 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.NodePath
20 | Library | resources.libraries.python.topology.Topology
21 | Library | resources.libraries.python.TrafficGenerator
22 | Library | resources.tools.wrk.wrk
23 |
24 | Documentation | Suite setup keywords.
25
26 *** Keywords ***
27 | Setup suite single link
28 | | [Documentation]
29 | | ... | Common suite setup for single link tests.
30 | | ... |
31 | | ... | Compute path for testing on two given nodes in circular topology
32 | | ... | based on interface model provided as an argument and set
33 | | ... | corresponding suite variables.
34 | |
35 | | ... | _NOTE:_ This KW sets following suite variables:
36 | | ... | - duts - List of DUT nodes
37 | | ... | - duts_count - Number of DUT nodes.
38 | | ... | - tg - TG node
39 | | ... | - tg_if1 - 1st TG interface towards DUT.
40 | | ... | - tg_if1_mac - 1st TG interface MAC address.
41 | | ... | - tg_if2 - 2nd TG interface towards DUT.
42 | | ... | - tg_if2_mac - 2nd TG interface MAC address.
43 | | ... | - dut{n} - DUTx node
44 | | ... | - dut{n}_if1 - 1st DUT interface.
45 | | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
46 | | ... | - dut{n}_if2 - 2nd DUT interface.
47 | | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
48 | |
49 | | ... | *Arguments:*
50 | | ... | - ${actions} - Additional setup action. Type: list
51 | |
52 | | [Arguments] | @{actions}
53 | |
54 | | ${nic_model_list}= | Create list | ${nic_name}
55 | | Append Node | ${nodes['TG']}
56 | | ${duts}= | Get Matches | ${nodes} | DUT*
57 | | FOR | ${dut} | IN | @{duts}
58 | | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
59 | | END
60 | | Append Node | ${nodes['TG']}
61 | | Compute Path | always_same_link=${FALSE}
62 | | ${tg_if1} | ${tg}= | Next Interface
63 | | FOR | ${dut} | IN | @{duts}
64 | | | ${dutx_if1} | ${dutx}= | Next Interface
65 | | | ${dutx_if2} | ${dutx}= | Next Interface
66 | | | ${dutx_if1_mac}= | Get Interface MAC | ${dutx} | ${dutx_if1}
67 | | | ${dutx_if2_mac}= | Get Interface MAC | ${dutx} | ${dutx_if2}
68 | | | ${dut_str}= | Convert To Lowercase | ${dut}
69 | | | Set Suite Variable | ${${dut_str}} | ${dutx}
70 | | | Set Suite Variable | ${${dut_str}_if1} | ${dutx_if1}
71 | | | Set Suite Variable | ${${dut_str}_if2} | ${dutx_if2}
72 | | | Set Suite Variable | ${${dut_str}_if1_mac} | ${dutx_if1_mac}
73 | | | Set Suite Variable | ${${dut_str}_if2_mac} | ${dutx_if2_mac}
74 | | END
75 | | ${tg_if2} | ${tg}= | Next Interface
76 | | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
77 | | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
78 | | ${duts_count}= | Get Length | ${duts}
79 | | Set Suite Variable | ${duts}
80 | | Set Suite Variable | ${duts_count}
81 | | Set Suite Variable | ${tg}
82 | | Set Suite Variable | ${tg_if1}
83 | | Set Suite Variable | ${tg_if1_mac}
84 | | Set Suite Variable | ${tg_if2}
85 | | Set Suite Variable | ${tg_if2_mac}
86 | | FOR | ${action} | IN | @{actions}
87 | | | Run Keyword | Additional Suite setup Action For ${action}
88 | | END
89
90 | Setup suite double link
91 | | [Documentation]
92 | | ... | Common suite setup for double link tests.
93 | | ... |
94 | | ... | Compute path for testing on three given nodes in circular topology
95 | | ... | with double link between DUTs based on interface model provided as an
96 | | ... | argument and set corresponding suite variables.
97 | |
98 | | ... | *Arguments:*
99 | | ... | - ${actions} - Additional setup action. Type: list
100 | |
101 | | ... | _NOTE:_ This KW sets following suite variables:
102 | | ... | - duts - List of DUT nodes
103 | | ... | - duts_count - Number of DUT nodes.
104 | | ... | - tg - TG node
105 | | ... | - tg_if1 - 1st TG interface towards DUT.
106 | | ... | - tg_if1 - 1st TG interface MAC address.
107 | | ... | - tg_if2 - 2nd TG interface towards DUT.
108 | | ... | - tg_if2 - 2nd TG interface MAC address.
109 | | ... | - dut1 - DUT1 node
110 | | ... | - dut1_if1 - DUT1 interface towards TG.
111 | | ... | - dut1_if2_1 - DUT1 interface 1 towards DUT2.
112 | | ... | - dut1_if2_2 - DUT1 interface 2 towards DUT2.
113 | | ... | - dut2 - DUT2 node
114 | | ... | - dut2_if1_1 - DUT2 interface 1 towards DUT1.
115 | | ... | - dut2_if1_2 - DUT2 interface 2 towards DUT1.
116 | | ... | - dut2_if2 - DUT2 interface towards TG.
117 | |
118 | | [Arguments] | @{actions}
119 | |
120 | | ${nic_model_list}= | Create list | ${nic_name}
121 | | # Compute path TG - DUT1 with single link in between
122 | | Append Node | ${nodes['TG']}
123 | | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
124 | | Append Node | ${nodes['TG']}
125 | | Compute Path
126 | | ${tg_if1} | ${tg}= | Next Interface
127 | | ${dut1_if1} | ${dut1}= | Next Interface
128 | | # Compute path TG - DUT2 with single link in between
129 | | Clear Path
130 | | Append Node | ${nodes['TG']}
131 | | Append Node | ${nodes['DUT2']} | filter_list=${nic_model_list}
132 | | Append Node | ${nodes['TG']}
133 | | Compute Path
134 | | ${tg_if2} | ${tg}= | Next Interface
135 | | ${dut2_if2} | ${dut2}= | Next Interface
136 | | # Compute path DUT1 - DUT2 with double link in between
137 | | Clear Path
138 | | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
139 | | Append Node | ${nodes['DUT2']} | filter_list=${nic_model_list}
140 | | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
141 | | Compute Path | always_same_link=${FALSE}
142 | | ${dut1_if2_1} | ${dut1}= | First Interface
143 | | ${dut1_if2_2} | ${dut1}= | Last Interface
144 | | ${dut2_if1_1} | ${dut2}= | First Ingress Interface
145 | | ${dut2_if1_2} | ${dut2}= | Last Egress Interface
146 | | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
147 | | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
148 | | ${duts_count}= | Set Variable | 2
149 | | ${duts}= | Get Matches | ${nodes} | DUT*
150 | | # Set suite variables
151 | | Set Suite Variable | ${duts}
152 | | Set Suite Variable | ${duts_count}
153 | | Set Suite Variable | ${tg}
154 | | Set Suite Variable | ${tg_if1}
155 | | Set Suite Variable | ${tg_if1_mac}
156 | | Set Suite Variable | ${tg_if2}
157 | | Set Suite Variable | ${tg_if2_mac}
158 | | Set Suite Variable | ${dut1}
159 | | Set Suite Variable | ${dut1_if1}
160 | | Set Suite Variable | ${dut1_if2_1}
161 | | Set Suite Variable | ${dut1_if2_2}
162 | | Set Suite Variable | ${dut2}
163 | | Set Suite Variable | ${dut2_if1_1}
164 | | Set Suite Variable | ${dut2_if1_2}
165 | | Set Suite Variable | ${dut2_if2}
166 | | FOR | ${action} | IN | @{actions}
167 | | | Run Keyword | Additional Suite setup Action For ${action}
168 | | END
169
170 | Additional Suite Setup Action For performance
171 | | [Documentation]
172 | | ... | Additional Setup for suites which uses performance measurement.
173 | |
174 | | Run Keyword If | ${duts_count} == 1
175 | | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
176 | | ... | ${dut1} | ${dut1_if1} | ${dut1} | ${dut1_if2} | ${osi_layer}
177 | | Run Keyword If | ${duts_count} == 2
178 | | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
179 | | ... | ${dut1} | ${dut1_if1} | ${dut2} | ${dut2_if2} | ${osi_layer}
180
181 | Additional Suite Setup Action For scapy
182 | | [Documentation]
183 | | ... | Additional Setup for suites which uses scapy as Traffic generator.
184 | |
185 | | Set Interface State | ${tg} | ${tg_if1} | up
186 | | Set Interface State | ${tg} | ${tg_if2} | up
187
188 | Additional Suite Setup Action For dpdk
189 | | [Documentation]
190 | | ... | Additional Setup for suites which uses dpdk.
191 | |
192 | | FOR | ${dut} | IN | @{duts}
193 | | | ${dut_str}= | Convert To Lowercase | ${dut}
194 | | | Initialize DPDK Environment | ${nodes['${dut}']}
195 | | | ... | ${${dut_str}_if1} | ${${dut_str}_if2}
196 | | END
197
198 | Additional Suite Setup Action For performance_avf
199 | | [Documentation]
200 | | ... | Additional Setup for suites which uses performance measurement over
201 | | ... | SRIOV AVF.
202 | |
203 | | FOR | ${dut} | IN | @{duts}
204 | | | ${if1_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if1}
205 | | | ... | numvfs=${1} | osi_layer=${osi_layer}
206 | | | ${if2_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if2}
207 | | | ... | numvfs=${1} | osi_layer=${osi_layer}
208 | | # Currently only one AVF is supported.
209 | | | Set Suite Variable | ${${dut}_if1_vf0} | ${if1_avf_arr[0]}
210 | | | Set Suite Variable | ${${dut}_if2_vf0} | ${if2_avf_arr[0]}
211 | | END
212 | | Run Keyword If | ${duts_count} == 1
213 | | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
214 | | ... | ${dut1} | ${dut1_if1_vf0} | ${dut1} | ${dut1_if2_vf0} | ${osi_layer}
215 | | Run Keyword If | ${duts_count} == 2
216 | | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
217 | | ... | ${dut1} | ${dut1_if1_vf0} | ${dut2} | ${dut2_if2_vf0} | ${osi_layer}
218
219 | Additional Suite Setup Action For avf
220 | | [Documentation]
221 | | ... | Additional Setup for suites which uses SRIOV AVF.
222 | |
223 | | FOR | ${dut} | IN | @{duts}
224 | | # Currently only one AVF is supported.
225 | | | Set Suite Variable | ${${dut}_if1_vf0} | ${${dut}_if1}
226 | | | Set Suite Variable | ${${dut}_if2_vf0} | ${${dut}_if2}
227 | | END
228
229 | Additional Suite Setup Action For ipsechw
230 | | [Documentation]
231 | | ... | Additional Setup for suites which uses QAT HW.
232 | |
233 | | ${numvfs}= | Set Variable If
234 | | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
235 | | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
236 | | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
237 | | ... | force_init=${True}
238 | | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
239
240 | Additional Suite Setup Action For wrk
241 | | [Documentation]
242 | | ... | Additional Setup for suites which uses WRK TG.
243 | |
244 | | Iface update numa node | ${tg}
245 # Make sure TRex is stopped
246 | | ${running}= | Is TRex running | ${tg}
247 | | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
248 | | ${curr_driver}= | Get PCI dev driver | ${tg}
249 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
250 | | Run keyword if | '${curr_driver}'!='${None}'
251 | | ... | PCI Driver Unbind | ${tg} |
252 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
253 # Bind tg_if1 to driver specified in the topology
254 | | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
255 | | PCI Driver Bind | ${tg}
256 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
257 # Set IP on tg_if1
258 | | ${intf_name}= | Get Linux interface name | ${tg}
259 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
260 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.10.1 | 24
261 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.20.1 | 24
262 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.30.1 | 24
263 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.40.1 | 24
264 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.50.1 | 24
265 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.60.1 | 24
266 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.70.1 | 24
267 | | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.80.1 | 24
268 | | Set Linux interface up | ${tg} | ${intf_name}
269 | | Check wrk | ${tg}