suite_setup.robot revision 6518c73a
1# Copyright (c) 2020 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| Variables | resources/libraries/python/Constants.py
24| Resource | resources/libraries/robot/wrk/wrk_utils.robot
25|
26| Documentation | Suite setup keywords.
27
28*** Keywords ***
29| Setup suite single link
30| | [Documentation]
31| | ... | Common suite setup for single link tests.
32| | ... |
33| | ... | Compute path for testing on two given nodes in circular topology
34| | ... | based on interface model provided as an argument and set
35| | ... | corresponding suite variables.
36| |
37| | ... | _NOTE:_ This KW sets following suite variables:
38| | ... | - duts - List of DUT nodes
39| | ... | - duts_count - Number of DUT nodes.
40| | ... | - tg - TG node
41| | ... | - tg_if1 - 1st TG interface towards DUT.
42| | ... | - tg_if1_mac - 1st TG interface MAC address.
43| | ... | - tg_if2 - 2nd TG interface towards DUT.
44| | ... | - tg_if2_mac - 2nd TG interface MAC address.
45| | ... | - dut{n} - DUTx node
46| | ... | - dut{n}_if1 - 1st DUT interface.
47| | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
48| | ... | - dut{n}_if2 - 2nd DUT interface.
49| | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
50| |
51| | ... | *Arguments:*
52| | ... | - ${actions} - Additional setup action. Type: list
53| |
54| | [Arguments] | @{actions}
55| |
56| | ${nic_model_list}= | Create list | ${nic_name}
57| | Append Node | ${nodes['TG']}
58| | ${duts}= | Get Matches | ${nodes} | DUT*
59| | FOR | ${dut} | IN | @{duts}
60| | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
61| | END
62| | Append Node | ${nodes['TG']}
63| | Compute Path | always_same_link=${FALSE}
64| | ${tg_if1} | ${tg}= | Next Interface
65| | FOR | ${dut} | IN | @{duts}
66| | | ${dutx_if1} | ${dutx}= | Next Interface
67| | | ${dutx_if2} | ${dutx}= | Next Interface
68| | | ${dutx_if1_mac}= | Get Interface MAC | ${dutx} | ${dutx_if1}
69| | | ${dutx_if2_mac}= | Get Interface MAC | ${dutx} | ${dutx_if2}
70| | | ${dut_str}= | Convert To Lowercase | ${dut}
71| | | Set Suite Variable | ${${dut_str}} | ${dutx}
72| | | Set Suite Variable | ${${dut_str}_if1} | ${dutx_if1}
73| | | Set Suite Variable | ${${dut_str}_if2} | ${dutx_if2}
74| | | Set Suite Variable | ${${dut_str}_if1_mac} | ${dutx_if1_mac}
75| | | Set Suite Variable | ${${dut_str}_if2_mac} | ${dutx_if2_mac}
76| | END
77| | ${tg_if2} | ${tg}= | Next Interface
78| | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
79| | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
80| | ${duts_count}= | Get Length | ${duts}
81| | Set Suite Variable | ${duts}
82| | Set Suite Variable | ${duts_count}
83| | Set Suite Variable | ${tg}
84| | Set Suite Variable | ${tg_if1}
85| | Set Suite Variable | ${tg_if1_mac}
86| | Set Suite Variable | ${tg_if2}
87| | Set Suite Variable | ${tg_if2_mac}
88| | FOR | ${action} | IN | @{actions}
89| | | Run Keyword | Additional Suite setup Action For ${action}
90| | END
91
92| Setup suite single link no tg
93| | [Documentation]
94| | ... | Common suite setup for single link tests.
95| | ... |
96| | ... | Compute path for testing on two given nodes in circular topology
97| | ... | based on interface model provided as an argument and set
98| | ... | corresponding suite variables.
99| |
100| | ... | _NOTE:_ This KW sets following suite variables:
101| | ... | - duts - List of DUT nodes
102| | ... | - duts_count - Number of DUT nodes.
103| | ... | - dut{n} - DUTx node
104| | ... | - dut{n}_if1 - 1st DUT interface.
105| | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
106| | ... | - dut{n}_if2 - 2nd DUT interface.
107| | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
108| |
109| | ... | *Arguments:*
110| | ... | - ${actions} - Additional setup action. Type: list
111| |
112| | [Arguments] | @{actions}
113| |
114| | ${nic_model_list}= | Create list | ${nic_name}
115| | ${duts}= | Get Matches | ${nodes} | DUT*
116| | FOR | ${dut} | IN | @{duts}
117| | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
118| | END
119| | Append Node | ${nodes['@{duts}[0]']} | filter_list=${nic_model_list}
120| | Compute Path | always_same_link=${TRUE}
121| | FOR | ${i} | IN RANGE | 1 | ${DATAPATH_INTERFACES_MAX}
122| | | ${dutx_if} | ${dutx}= | Next Interface
123| | | Run Keyword If | '${dutx_if}' == 'None' | EXIT FOR LOOP
124| | | ${dutx_if_mac}= | Get Interface MAC | ${dutx} | ${dutx_if}
125| | | ${dutx_if_ip4_addr}= | Get Interface Ip4 | ${dutx} | ${dutx_if}
126| | | ${dutx_if_ip4_prefix_length}= | Get Interface Ip4 Prefix Length
127| | | ... | ${dutx} | ${dutx_if}
128| | | ${dut_str}= | Get Keyname For DUT | ${dutx} | ${duts}
129| | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
130| | | ... | Variable Should Exist | ${${dut_str}_if1}
131| | | ${if_name}= | Set Variable If | '${if1_status}' == 'PASS'
132| | | ... | if2 | if1
133| | | Set Suite Variable | ${${dut_str}} | ${dutx}
134| | | Set Suite Variable | ${${dut_str}_${if_name}} | ${dutx_if}
135| | | Set Suite Variable | ${${dut_str}_${if_name}_mac} | ${dutx_if_mac}
136| | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_addr}
137| | | ... | ${dutx_if_ip4_addr}
138| | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_prefix}
139| | | ... | ${dutx_if_ip4_prefix_length}
140| | END
141| | Run Keyword If | ${i}>${DATAPATH_INTERFACES_MAX}
142| | ... | Fatal Error | Datapath length exceeded
143| | ${duts_count}= | Get Length | ${duts}
144| | Set Suite Variable | ${duts}
145| | Set Suite Variable | ${duts_count}
146| | FOR | ${action} | IN | @{actions}
147| | | Run Keyword | Additional Suite setup Action For ${action}
148| | END
149
150| Setup suite double link
151| | [Documentation]
152| | ... | Common suite setup for double link tests.
153| | ... |
154| | ... | Compute path for testing on three given nodes in circular topology
155| | ... | with double link between DUTs based on interface model provided as an
156| | ... | argument and set corresponding suite variables.
157| |
158| | ... | *Arguments:*
159| | ... | - ${actions} - Additional setup action. Type: list
160| |
161| | ... | _NOTE:_ This KW sets following suite variables:
162| | ... | - duts - List of DUT nodes
163| | ... | - duts_count - Number of DUT nodes.
164| | ... | - tg - TG node
165| | ... | - tg_if1 - 1st TG interface towards DUT.
166| | ... | - tg_if1 - 1st TG interface MAC address.
167| | ... | - tg_if2 - 2nd TG interface towards DUT.
168| | ... | - tg_if2 - 2nd TG interface MAC address.
169| | ... | - dut1 - DUT1 node
170| | ... | - dut1_if1 - DUT1 interface towards TG.
171| | ... | - dut1_if2_1 - DUT1 interface 1 towards DUT2.
172| | ... | - dut1_if2_2 - DUT1 interface 2 towards DUT2.
173| | ... | - dut2 - DUT2 node
174| | ... | - dut2_if1_1 - DUT2 interface 1 towards DUT1.
175| | ... | - dut2_if1_2 - DUT2 interface 2 towards DUT1.
176| | ... | - dut2_if2 - DUT2 interface towards TG.
177| |
178| | [Arguments] | @{actions}
179| |
180| | ${nic_model_list}= | Create list | ${nic_name}
181| | # Compute path TG - DUT1 with single link in between
182| | Append Node | ${nodes['TG']}
183| | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
184| | Append Node | ${nodes['TG']}
185| | Compute Path
186| | ${tg_if1} | ${tg}= | Next Interface
187| | ${dut1_if1} | ${dut1}= | Next Interface
188| | # Compute path TG - DUT2 with single link in between
189| | Clear Path
190| | Append Node | ${nodes['TG']}
191| | Append Node | ${nodes['DUT2']} | filter_list=${nic_model_list}
192| | Append Node | ${nodes['TG']}
193| | Compute Path
194| | ${tg_if2} | ${tg}= | Next Interface
195| | ${dut2_if2} | ${dut2}= | Next Interface
196| | # Compute path DUT1 - DUT2 with double link in between
197| | Clear Path
198| | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
199| | Append Node | ${nodes['DUT2']} | filter_list=${nic_model_list}
200| | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
201| | Compute Path | always_same_link=${FALSE}
202| | ${dut1_if2_1} | ${dut1}= | First Interface
203| | ${dut1_if2_2} | ${dut1}= | Last Interface
204| | ${dut2_if1_1} | ${dut2}= | First Ingress Interface
205| | ${dut2_if1_2} | ${dut2}= | Last Egress Interface
206| | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
207| | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
208| | ${duts_count}= | Set Variable | 2
209| | ${duts}= | Get Matches | ${nodes} | DUT*
210| | # Set suite variables
211| | Set Suite Variable | ${duts}
212| | Set Suite Variable | ${duts_count}
213| | Set Suite Variable | ${tg}
214| | Set Suite Variable | ${tg_if1}
215| | Set Suite Variable | ${tg_if1_mac}
216| | Set Suite Variable | ${tg_if2}
217| | Set Suite Variable | ${tg_if2_mac}
218| | Set Suite Variable | ${dut1}
219| | Set Suite Variable | ${dut1_if1}
220| | Set Suite Variable | ${dut1_if2_1}
221| | Set Suite Variable | ${dut1_if2_2}
222| | Set Suite Variable | ${dut2}
223| | Set Suite Variable | ${dut2_if1_1}
224| | Set Suite Variable | ${dut2_if1_2}
225| | Set Suite Variable | ${dut2_if2}
226| | FOR | ${action} | IN | @{actions}
227| | | Run Keyword | Additional Suite setup Action For ${action}
228| | END
229
230| Additional Suite Setup Action For scapy
231| | [Documentation]
232| | ... | Additional Setup for suites which uses scapy as Traffic generator.
233| |
234| | Set Interface State | ${tg} | ${tg_if1} | up
235| | Set Interface State | ${tg} | ${tg_if2} | up
236
237| Additional Suite Setup Action For dpdk
238| | [Documentation]
239| | ... | Additional Setup for suites which uses dpdk.
240| |
241| | FOR | ${dut} | IN | @{duts}
242| | | ${dut_str}= | Convert To Lowercase | ${dut}
243| | | Initialize DPDK Environment | ${nodes['${dut}']}
244| | | ... | ${${dut_str}_if1} | ${${dut_str}_if2}
245| | END
246
247| Additional Suite Setup Action For performance
248| | [Documentation]
249| | ... | Additional Setup for suites which uses performance measurement.
250| | ...
251| | Run Keyword If | ${duts_count} == 1
252| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
253| | ... | ${dut1} | ${dut1_if1} | ${dut1} | ${dut1_if2} | ${osi_layer}
254| | Run Keyword If | ${duts_count} == 2
255| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
256| | ... | ${dut1} | ${dut1_if1} | ${dut2} | ${dut2_if2} | ${osi_layer}
257
258| Additional Suite Setup Action For performance_rdma
259| | [Documentation]
260| | ... | Additional Setup for suites which uses performance measurement with
261| | ... | RDMA-core driver.
262| | ...
263# TODO: Add functionality for tests that need some.
264| | Additional Suite Setup Action For performance
265
266| Additional Suite Setup Action For performance_avf
267| | [Documentation]
268| | ... | Additional Setup for suites which uses performance measurement over
269| | ... | SRIOV AVF.
270| |
271| | FOR | ${dut} | IN | @{duts}
272| | | ${if1_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if1}
273| | | ... | numvfs=${1} | osi_layer=${osi_layer}
274| | | ${if2_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if2}
275| | | ... | numvfs=${1} | osi_layer=${osi_layer}
276| | # Currently only one AVF is supported.
277| | | Set Suite Variable | ${${dut}_if1_vf0} | ${if1_avf_arr[0]}
278| | | Set Suite Variable | ${${dut}_if2_vf0} | ${if2_avf_arr[0]}
279| | END
280| | Run Keyword If | ${duts_count} == 1
281| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
282| | ... | ${dut1} | ${dut1_if1_vf0} | ${dut1} | ${dut1_if2_vf0} | ${osi_layer}
283| | Run Keyword If | ${duts_count} == 2
284| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
285| | ... | ${dut1} | ${dut1_if1_vf0} | ${dut2} | ${dut2_if2_vf0} | ${osi_layer}
286
287| Additional Suite Setup Action For avf
288| | [Documentation]
289| | ... | Additional Setup for suites which uses SRIOV AVF.
290| |
291| | FOR | ${dut} | IN | @{duts}
292| | # Currently only one AVF is supported.
293| | | Set Suite Variable | ${${dut}_if1_vf0} | ${${dut}_if1}
294| | | Set Suite Variable | ${${dut}_if2_vf0} | ${${dut}_if2}
295| | END
296
297| Additional Suite Setup Action For ipsechw
298| | [Documentation]
299| | ... | Additional Setup for suites which uses QAT HW.
300| |
301| | ${numvfs}= | Set Variable If
302| | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
303| | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
304| | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
305| | ... | force_init=${True}
306| | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
307
308| Additional Suite Setup Action For wrk
309| | [Documentation]
310| | ... | Additional Setup for suites which uses WRK TG.
311| |
312| | Verify Program Installed | ${tg} | wrk
313| | Iface update numa node | ${tg}
314# Make sure TRex is stopped
315| | ${running}= | Is TRex running | ${tg}
316| | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
317| | ${curr_driver}= | Get PCI dev driver | ${tg}
318| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
319| | Run keyword if | '${curr_driver}'!='${None}'
320| | ... | PCI Driver Unbind | ${tg} |
321| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
322# Bind tg_if1 to driver specified in the topology
323| | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
324| | PCI Driver Bind | ${tg}
325| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
326# Set IP on tg_if1
327| | ${intf_name}= | Get Linux interface name | ${tg}
328| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
329| | FOR | ${ip_addr} | IN | @{wrk_ip_addrs}
330| | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
331| | | ... | ${ip_addr} | ${wrk_ip_prefix}
332| | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
333| | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${wrk_ip_prefix}
334| | END
335| | Set Linux interface up | ${tg} | ${intf_name}
336| | Check wrk | ${tg}
337