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