09cec67e4e2669dbdd84e6e1f0f880e54d62fdf3
[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_dut \| DUT1 \|
145 | |
146 | | [Arguments] | ${dut}
147 | |
148 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
149 | | | ${_vf}=
150 | | | ... | Run Keyword | Init ${nic_driver} interface
151 | | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | numvfs=${nic_vfs}
152 | | | ... | 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
180 | | [Documentation]
181 | | ... | Additional Setup for suites which uses performance measurement.
182 | |
183 | | FOR | ${dut} | IN | @{duts}
184 | | | Run Keyword If | ${nic_vfs} > 0
185 | | | ... | Additional Suite Setup Action For performance vf | ${dut}
186 | | END
187 | | Initialize traffic generator
188 | | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
189 | | ... | ${dut1} | ${DUT1_${int}1}[0]
190 | | ... | ${dut${duts_count}} | ${DUT${duts_count}_${int}2}[0]
191 | | ... | ${osi_layer}
192
193 | Additional Suite Setup Action For ipsechw
194 | | [Documentation]
195 | | ... | Additional Setup for suites which uses QAT HW.
196 | |
197 | | ${numvfs}= | Set Variable If
198 | | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
199 | | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
200 | | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
201 | | ... | force_init=${True}
202 | | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
203
204 | Additional Suite Setup Action For nginx
205 | | [Documentation]
206 | | ... | Additional Setup for suites which uses Nginx.
207 | |
208 | | Install NGINX framework on all DUTs | ${nodes} | ${packages_dir}
209 | | ... |  ${nginx_version}
210
211 | Additional Suite Setup Action For ab
212 | | [Documentation]
213 | | ... | Additional Setup for suites which uses ab TG.
214 | |
215 | | Verify Program Installed | ${tg} | ab
216 | | Iface update numa node | ${tg}
217 | | ${running}= | Is TRex running | ${tg}
218 | | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
219 | | ${curr_driver}= | Get PCI dev driver | ${tg}
220 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
221 | | Run keyword if | '${curr_driver}'!='${None}'
222 | | ... | PCI Driver Unbind | ${tg} |
223 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
224 | | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
225 | | PCI Driver Bind | ${tg}
226 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
227 | | ${intf_name}= | Get Linux interface name | ${tg}
228 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
229 | | FOR | ${ip_addr} | IN | @{ab_ip_addrs}
230 | | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
231 | | | ... | ${ip_addr} | ${ab_ip_prefix}
232 | | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
233 | | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${ab_ip_prefix}
234 | | END
235 | | Set Linux interface up | ${tg} | ${intf_name}
236 | | Check ab | ${tg}