Python3: resources and libraries
[csit.git] / resources / libraries / robot / l2 / l2_xconnect.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 *** Settings ***
15 | Library | resources.libraries.python.L2Util
16 | Library | resources.libraries.python.InterfaceUtil
17
18 *** Keywords ***
19 | Configure L2XC
20 | | [Documentation] | Setup Bidirectional Cross Connect on DUTs
21 | | [Arguments] | ${node} | ${if1} | ${if2} |
22 | | Set Interface State | ${node} | ${if1} | up
23 | | Set Interface State | ${node} | ${if2} | up
24 | | Vpp Setup Bidirectional Cross Connect | ${node} | ${if1} | ${if2}
25
26 | Initialize L2 cross connect on node
27 | | [Documentation]
28 | | ... | Setup L2 cross connect topology by connecting RX/TX of two interfaces
29 | | ... | on each DUT. Interfaces are brought up.
30 | |
31 | | ... | *Arguments:*
32 | | ... | - dut - DUT node. Type: string
33 | | ... | - count - Number of interfaces pairs to connect. Type: integer
34 | |
35 | | ... | *Example:*
36 | |
37 | | ... | \| Initialize L2 cross connect on node \| DUT1 \| 1 \|
38 | |
39 | | [Arguments] | ${dut} | ${count}=${1}
40 | |
41 | | FOR | ${id} | IN RANGE | 1 | ${count} + 1
42 | | | ${dut_str}= | Convert To Lowercase | ${dut}
43 | | | VPP Setup Bidirectional Cross Connect | ${nodes['${dut}']}
44 | | | ... | ${${dut_str}_${prev_layer}_${id}_1}
45 | | | ... | ${${dut_str}_${prev_layer}_${id}_2}
46 | | END
47
48 | Initialize L2 cross connect
49 | | [Documentation]
50 | | ... | Setup L2 cross connect topology by connecting RX/TX of two interfaces
51 | | ... | on each DUT. Interfaces are brought up.
52 | |
53 | | ... | *Arguments:*
54 | | ... | - count - Number of interfaces pairs to connect. Type: integer
55 | |
56 | | ... | *Example:*
57 | |
58 | | ... | \| Initialize L2 cross connect \| 1 \|
59 | |
60 | | [Arguments] | ${count}=${1}
61 | |
62 | | FOR | ${dut} | IN | @{duts}
63 | | | Initialize L2 cross connect on node | ${dut} | count=${count}
64 | | END
65
66 | Initialize L2 xconnect in 2-node circular topology
67 | | [Documentation]
68 | | ... | Setup L2 xconnect topology by cross connecting two interfaces on
69 | | ... | each DUT. Interfaces are brought up.
70 | |
71 | | Set interfaces in path up
72 | | VPP Setup Bidirectional Cross Connect | ${dut1} | ${dut1_if1} | ${dut1_if2}
73
74 | Initialize L2 xconnect in 3-node circular topology
75 | | [Documentation]
76 | | ... | Setup L2 xconnect topology by cross connecting two interfaces on
77 | | ... | each DUT. Interfaces are brought up.
78 | | ... |
79 | | Set interfaces in path up
80 | | VPP Setup Bidirectional Cross Connect | ${dut1} | ${dut1_if1} | ${dut1_if2}
81 | | VPP Setup Bidirectional Cross Connect | ${dut2} | ${dut2_if1} | ${dut2_if2}
82
83 | Initialize L2 xconnect with VXLANoIPv4 in 3-node circular topology
84 | | [Documentation]
85 | | ... | Setup L2 xconnect topology with VXLANoIPv4 by cross connecting
86 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
87 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
88 | | ... | between DUTs. VXLAN sub-interfaces has same IPv4 address as
89 | | ... | interfaces.
90 | |
91 | | Set interfaces in path up
92 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if2} | 172.16.0.1 | 24
93 | | VPP Interface Set IP Address | ${dut2} | ${dut2_if1} | 172.16.0.2 | 24
94 | | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 172.16.0.2 | ${dut2_if1_mac}
95 | | VPP Add IP Neighbor | ${dut2} | ${dut2_if1} | 172.16.0.1 | ${dut1_if2_mac}
96 | | ${dut1s_vxlan}= | Create VXLAN interface | ${dut1} | 24
97 | | ... | 172.16.0.1 | 172.16.0.2
98 | | Configure L2XC | ${dut1} | ${dut1_if1} | ${dut1s_vxlan}
99 | | ${dut2s_vxlan}= | Create VXLAN interface | ${dut2} | 24
100 | | ... | 172.16.0.2 | 172.16.0.1
101 | | Configure L2XC | ${dut2} | ${dut2_if2} | ${dut2s_vxlan}
102
103 | Initialize L2 xconnect with Vhost-User on node
104 | | [Documentation]
105 | | ... | Create pairs of Vhost-User interfaces for defined number of VMs on
106 | | ... | defined VPP node. Add each Vhost-User interface into L2 cross-connect
107 | | ... | with with physical inteface or Vhost-User interface of another VM.
108 | |
109 | | ... | *Arguments:*
110 | | ... | - dut - DUT node. Type: string
111 | | ... | - nf_nodes - VM count. Type: integer
112 | |
113 | | ... | *Note:*
114 | | ... | Socket paths for VM are defined in following format:
115 | | ... | - /tmp/sock-\${VM_ID}-1
116 | | ... | - /tmp/sock-\${VM_ID}-2
117 | |
118 | | ... | *Example:*
119 | |
120 | | ... | \| Initialize L2 xconnect with Vhost-User on node \| DUT1 \| 1 \|
121 | |
122 | | [Arguments] | ${dut} | ${nf_nodes}=${1}
123 | |
124 | | FOR | ${number} | IN RANGE | 1 | ${nf_nodes}+1
125 | | | ${sock1}= | Set Variable | /var/run/vpp/sock-${number}-1
126 | | | ${sock2}= | Set Variable | /var/run/vpp/sock-${number}-2
127 | | | ${prev_index}= | Evaluate | ${number}-1
128 | | | Configure vhost interfaces | ${nodes['${dut}']}
129 | | | ... | ${sock1} | ${sock2} | ${dut}-vhost-${number}-if1
130 | | | ... | ${dut}-vhost-${number}-if2
131 | | | ${dut_xconnect_if1}= | Set Variable If | ${number}==1 | ${${dut}_if1}
132 | | | ... | ${${dut}-vhost-${prev_index}-if2}
133 | | | Configure L2XC | ${nodes['${dut}']} | ${dut_xconnect_if1}
134 | | | ... | ${${dut}-vhost-${number}-if1}
135 | | | Run Keyword If | ${number}==${nf_nodes} | Configure L2XC
136 | | | ... | ${nodes['${dut}']} | ${${dut}-vhost-${number}-if2} | ${${dut}_if2}
137 | | END
138
139 | Initialize L2 xconnect with Vhost-User
140 | | [Documentation]
141 | | ... | Create pairs of Vhost-User interfaces for defined number of VMs on
142 | | ... | all VPP nodes. Add each Vhost-User interface into L2 cross-connect
143 | | ... | with with physical inteface or Vhost-User interface of another VM.
144 | |
145 | | ... | *Arguments:*
146 | | ... | - nf_nodes - VM count. Type: integer
147 | |
148 | | ... | *Example:*
149 | |
150 | | ... | \| Initialize L2 xconnect with Vhost-User \| 1 \|
151 | |
152 | | [Arguments] | ${nf_nodes}=${1}
153 | |
154 | | FOR | ${dut} | IN | @{duts}
155 | | | Initialize L2 xconnect with Vhost-User on node | ${dut}
156 | | | ... | nf_nodes=${nf_nodes}
157 | | END
158
159 | Initialize L2 xconnect with Vhost-User and VLAN in 3-node circular topology
160 | | [Documentation]
161 | | ... | Create two Vhost-User interfaces on all defined VPP nodes. Cross
162 | | ... | connect each Vhost interface with one physical interface.
163 | | ... | Setup VLAN between DUTs. All interfaces are brought up.
164 | |
165 | | ... | *Arguments:*
166 | | ... | - subid - ID of the sub-interface to be created. Type: string
167 | | ... | - tag_rewrite - Method of tag rewrite. Type: string
168 | |
169 | | ... | *Example:*
170 | |
171 | | ... | \| L2 xconnect with Vhost-User and VLAN initialized in a 3-node\
172 | | ... | circular topology \| 10 \| pop-1 \|
173 | |
174 | | [Arguments] | ${subid} | ${tag_rewrite}
175 | |
176 | | Set interfaces in path up
177 | | Initialize VLAN dot1q sub-interfaces in circular topology
178 | | ... | ${dut1} | ${dut1_if2} | ${dut2} | ${dut2_if1} | ${subid}
179 | | Configure L2 tag rewrite method on interfaces
180 | | ... | ${dut1} | ${subif_index_1} | ${dut2} | ${subif_index_2}
181 | | ... | ${tag_rewrite}
182 | | Configure vhost interfaces
183 | | ... | ${dut1} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
184 | | Configure L2XC | ${dut1} | ${dut1_if1} | ${vhost_if1}
185 | | Configure L2XC | ${dut1} | ${subif_index_1} | ${vhost_if2}
186 | | Configure vhost interfaces
187 | | ... | ${dut2} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
188 | | Configure L2XC | ${dut2} | ${subif_index_2} | ${vhost_if1}
189 | | Configure L2XC | ${dut2} | ${dut2_if2} | ${vhost_if2}
190
191 | Initialize L2 xconnect with Vhost-User and VLAN with VPP link bonding in 3-node circular topology
192 | | [Documentation]
193 | | ... | Create two Vhost-User interfaces on all defined VPP nodes. Create one
194 | | ... | link bonding (BondEthernet) interface on both VPP nodes. Enslave one
195 | | ... | physical interface towards next DUT by BondEthernet interface. Setup
196 | | ... | VLAN on BondEthernet interfaces between DUTs. Cross connect one Vhost
197 | | ... | interface with physical interface towards TG and other Vhost interface
198 | | ... | with VLAN sub-interface. All interfaces are brought up.
199 | |
200 | | ... | *Arguments:*
201 | | ... | - subid - ID of the sub-interface to be created. Type: string
202 | | ... | - tag_rewrite - Method of tag rewrite. Type: string
203 | | ... | - bond_mode - Link bonding mode. Type: string
204 | | ... | - lb_mode - Load balance mode. Type: string
205 | |
206 | | ... | *Example:*
207 | |
208 | | ... | \| Initialize L2 xconnect with Vhost-User and VLAN with VPP link\
209 | | ... | bonding in 3-node circular topology \| 10 \| pop-1 \| xor \| l34 \|
210 | |
211 | | [Arguments] | ${subid} | ${tag_rewrite} | ${bond_mode} | ${lb_mode}
212 | |
213 | | Set interfaces in path up
214 | | ${dut1_eth_bond_if1}= | VPP Create Bond Interface | ${dut1} | ${bond_mode}
215 | | ... | ${lb_mode}
216 | | Set Interface State | ${dut1} | ${dut1_eth_bond_if1} | up
217 | | VPP Set interface MTU | ${dut1} | ${dut1_eth_bond_if1}
218 | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
219 | | ... | Variable Should Exist | ${dut1_if2}
220 | | Run Keyword If | '${if2_status}' == 'PASS'
221 | | ... | VPP Enslave Physical Interface | ${dut1} | ${dut1_if2}
222 | | ... | ${dut1_eth_bond_if1}
223 | | ... | ELSE
224 | | ... | VPP Enslave Physical Interface | ${dut1} | ${dut1_if2_1}
225 | | ... | ${dut1_eth_bond_if1}
226 | | Run Keyword Unless | '${if2_status}' == 'PASS'
227 | | ... | VPP Enslave Physical Interface | ${dut1} | ${dut1_if2_2}
228 | | ... | ${dut1_eth_bond_if1}
229 | | ${dut2_eth_bond_if1}= | VPP Create Bond Interface | ${dut2} | ${bond_mode}
230 | | ... | ${lb_mode}
231 | | Set Interface State | ${dut2} | ${dut2_eth_bond_if1} | up
232 | | VPP Set interface MTU | ${dut1} | ${dut1_eth_bond_if1}
233 | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
234 | | ... | Variable Should Exist | ${dut2_if1}
235 | | Run Keyword If | '${if1_status}' == 'PASS'
236 | | ... | VPP Enslave Physical Interface | ${dut2} | ${dut2_if1}
237 | | ... | ${dut2_eth_bond_if1}
238 | | ... | ELSE
239 | | ... | VPP Enslave Physical Interface | ${dut2} | ${dut2_if1_1}
240 | | ... | ${dut2_eth_bond_if1}
241 | | Run Keyword Unless | '${if2_status}' == 'PASS'
242 | | ... | VPP Enslave Physical Interface | ${dut2} | ${dut2_if1_2}
243 | | ... | ${dut2_eth_bond_if1}
244 | | VPP Show Bond Data On All Nodes | ${nodes} | verbose=${TRUE}
245 | | Initialize VLAN dot1q sub-interfaces in circular topology
246 | | ... | ${dut1} | ${dut1_eth_bond_if1} | ${dut2} | ${dut2_eth_bond_if1}
247 | | ... | ${subid}
248 | | Configure L2 tag rewrite method on interfaces
249 | | ... | ${dut1} | ${subif_index_1} | ${dut2} | ${subif_index_2}
250 | | ... | ${tag_rewrite}
251 | | Configure vhost interfaces
252 | | ... | ${dut1} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
253 | | Configure L2XC | ${dut1} | ${dut1_if1} | ${vhost_if1}
254 | | Configure L2XC | ${dut1} | ${subif_index_1} | ${vhost_if2}
255 | | Configure vhost interfaces
256 | | ... | ${dut2} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
257 | | Configure L2XC | ${dut2} | ${subif_index_2} | ${vhost_if1}
258 | | Configure L2XC | ${dut2} | ${dut2_if2} | ${vhost_if2}
259
260 | Initialize L2 xconnect with memif pairs on DUT node
261 | | [Documentation]
262 | | ... | Create pairs of Memif interfaces on DUT node. Cross connect each Memif
263 | | ... | interface with one physical interface or virtual interface to create
264 | | ... | a chain accross DUT node.
265 | |
266 | | ... | *Arguments:*
267 | | ... | - dut - DUT node. Type: dictionary
268 | | ... | - count - Number of memif pairs (containers). Type: integer
269 | |
270 | | ... | *Note:*
271 | | ... | Socket paths for Memif are defined in following format:
272 | | ... | - /tmp/memif-\${dut}_CNF\${number}-\${sid}
273 | |
274 | | ... | KW uses test variable \${rxq_count_int} set by KW Add worker threads
275 | | ... | and rxqueues to all DUTs
276 | |
277 | | ... | *Example:*
278 | |
279 | | ... | \| Initialize L2 xconnect with memif pairs on DUT node \| ${dut} \
280 | | ... | \| ${1} \|
281 | |
282 | | [Arguments] | ${dut} | ${count}
283 | |
284 | | FOR | ${number} | IN RANGE | 1 | ${count}+1
285 | | | ${sock1}= | Set Variable | memif-${dut}_CNF
286 | | | ${sock2}= | Set Variable | memif-${dut}_CNF
287 | | | ${prev_index}= | Evaluate | ${number}-1
288 | | | Set up memif interfaces on DUT node | ${nodes['${dut}']}
289 | | | ... | ${sock1} | ${sock2} | ${number} | ${dut}-memif-${number}-if1
290 | | | ... | ${dut}-memif-${number}-if2 | ${rxq_count_int} | ${rxq_count_int}
291 | | | ${xconnect_if1}= | Set Variable If | ${number}==1 | ${${dut}_if1}
292 | | | ... | ${${dut}-memif-${prev_index}-if2}
293 | | | Configure L2XC | ${nodes['${dut}']} | ${xconnect_if1}
294 | | | ... | ${${dut}-memif-${number}-if1}
295 | | | Run Keyword If | ${number}==${count} | Configure L2XC
296 | | | ... | ${nodes['${dut}']} | ${${dut}-memif-${number}-if2} | ${${dut}_if2}
297 | | END
298
299 | Initialize L2 xconnect with memif pairs
300 | | [Documentation]
301 | | ... | Create pairs of Memif interfaces on all defined VPP nodes. Cross
302 | | ... | connect each Memif interface with one physical interface or virtual
303 | | ... | interface to create a chain accross DUT node.
304 | |
305 | | ... | *Arguments:*
306 | | ... | - count - Number of memif pairs (containers). Type: integer
307 | |
308 | | ... | *Example:*
309 | |
310 | | ... | \| Initialize L2 xconnect with memif pairs \| ${1} \|
311 | |
312 | | [Arguments] | ${count}=${1}
313 | |
314 | | FOR | ${dut} | IN | @{duts}
315 | | | Initialize L2 xconnect with memif pairs on DUT node | ${dut} | ${count}
316 | | END
317 | | Set interfaces in path up
318 | | Show Memif on all DUTs | ${nodes}
319 | | VPP round robin RX placement on all DUTs | ${nodes} | prefix=memif
320
321 | Initialize L2 xconnect for single memif
322 | | [Documentation]
323 | | ... | Create single Memif interface on all defined VPP nodes. Cross
324 | | ... | connect Memif interface with one physical interface.
325 | |
326 | | ... | *Arguments:*
327 | | ... | - number - Memif ID. Type: integer
328 | |
329 | | ... | *Note:*
330 | | ... | Socket paths for Memif are defined in following format:
331 | | ... | - /tmp/memif-DUT1_CNF\${number}-\${sid}
332 | |
333 | | ... | KW uses test variable ${rxq_count_int} set by KW Add worker threads
334 | | ... | and rxqueues to all DUTs
335 | |
336 | | ... | *Example:*
337 | |
338 | | ... | \| Initialize L2 xconnect for single memif \| 1 \|
339 | |
340 | | [Arguments] | ${number}=${1}
341 | |
342 | | FOR | ${dut} | IN | @{duts}
343 | | | ${sock}= | Set Variable | memif-${dut}_CNF
344 | | | ${sid}= | Evaluate | (${number} * ${2}) - ${1}
345 | | | Set up single memif interface on DUT node | ${nodes['${dut}']} | ${sock}
346 | | | ... | mid=${number} | sid=${sid} | memif_if=${dut}-memif-${number}-if1
347 | | | ... | rxq=${rxq_count_int} | txq=${rxq_count_int}
348 | | | Configure L2XC | ${nodes['${dut}']} | ${${dut}_if1}
349 | | | ... | ${${dut}-memif-${number}-if1}
350 | | END
351 | | Set single interfaces in path up
352 | | Show Memif on all DUTs | ${nodes}
353 | | VPP round robin RX placement on all DUTs | ${nodes} | prefix=memif