FIX: L2XC with vhost and VLAN
[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 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 | | ${dut2_status} | ${value}= | Run Keyword And Ignore Error
177 | | ... | Variable Should Exist | ${dut2}
178 | |
179 | | Set interfaces in path up
180 | |
181 | | Run Keyword If | '${dut2_status}' == 'PASS'
182 | | ... | Initialize VLAN dot1q sub-interfaces in circular topology
183 | | ... | ${dut1} | ${dut1_if2} | ${dut2} | ${dut2_if1} | ${subid}
184 | | ... | ELSE | Initialize VLAN dot1q sub-interfaces in circular topology
185 | | ... | ${dut1} | ${dut1_if2} | SUB_ID=${subid}
186 | | Run Keyword If | '${dut2_status}' == 'PASS'
187 | | ... | Configure L2 tag rewrite method on interfaces | ${dut1}
188 | | ... | ${subif_index_1} | ${dut2} | ${subif_index_2} | ${tag_rewrite}
189 | | ... | ELSE | Configure L2 tag rewrite method on interfaces
190 | | ... | ${dut1} | ${subif_index_1} | TAG_REWRITE_METHOD=${tag_rewrite}
191 | |
192 | | Configure vhost interfaces
193 | | ... | ${dut1} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
194 | | Configure L2XC | ${dut1} | ${dut1_if1} | ${vhost_if1}
195 | | Configure L2XC | ${dut1} | ${subif_index_1} | ${vhost_if2}
196 | |
197 | | Run Keyword If | '${dut2_status}' == 'PASS'
198 | | ... | Configure vhost interfaces
199 | | ... | ${dut2} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
200 | | Run Keyword If | '${dut2_status}' == 'PASS'
201 | | ... | Configure L2XC | ${dut2} | ${subif_index_2} | ${vhost_if1}
202 | | Run Keyword If | '${dut2_status}' == 'PASS'
203 | | ... | Configure L2XC | ${dut2} | ${dut2_if2} | ${vhost_if2}
204
205 | Initialize L2 xconnect with Vhost-User and VLAN with VPP link bonding in 3-node circular topology
206 | | [Documentation]
207 | | ... | Create two Vhost-User interfaces on all defined VPP nodes. Create one
208 | | ... | link bonding (BondEthernet) interface on both VPP nodes. Enslave one
209 | | ... | physical interface towards next DUT by BondEthernet interface. Setup
210 | | ... | VLAN on BondEthernet interfaces between DUTs. Cross connect one Vhost
211 | | ... | interface with physical interface towards TG and other Vhost interface
212 | | ... | with VLAN sub-interface. All interfaces are brought up.
213 | |
214 | | ... | *Arguments:*
215 | | ... | - subid - ID of the sub-interface to be created. Type: string
216 | | ... | - tag_rewrite - Method of tag rewrite. Type: string
217 | | ... | - bond_mode - Link bonding mode. Type: string
218 | | ... | - lb_mode - Load balance mode. Type: string
219 | |
220 | | ... | *Example:*
221 | |
222 | | ... | \| Initialize L2 xconnect with Vhost-User and VLAN with VPP link\
223 | | ... | bonding in 3-node circular topology \| 10 \| pop-1 \| xor \| l34 \|
224 | |
225 | | [Arguments] | ${subid} | ${tag_rewrite} | ${bond_mode} | ${lb_mode}
226 | |
227 | | Set interfaces in path up
228 | | ${dut1_eth_bond_if1}= | VPP Create Bond Interface | ${dut1} | ${bond_mode}
229 | | ... | ${lb_mode}
230 | | Set Interface State | ${dut1} | ${dut1_eth_bond_if1} | up
231 | | VPP Set interface MTU | ${dut1} | ${dut1_eth_bond_if1}
232 | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
233 | | ... | Variable Should Exist | ${dut1_if2}
234 | | Run Keyword If | '${if2_status}' == 'PASS'
235 | | ... | VPP Enslave Physical Interface | ${dut1} | ${dut1_if2}
236 | | ... | ${dut1_eth_bond_if1}
237 | | ... | ELSE
238 | | ... | VPP Enslave Physical Interface | ${dut1} | ${dut1_if2_1}
239 | | ... | ${dut1_eth_bond_if1}
240 | | Run Keyword Unless | '${if2_status}' == 'PASS'
241 | | ... | VPP Enslave Physical Interface | ${dut1} | ${dut1_if2_2}
242 | | ... | ${dut1_eth_bond_if1}
243 | | ${dut2_eth_bond_if1}= | VPP Create Bond Interface | ${dut2} | ${bond_mode}
244 | | ... | ${lb_mode}
245 | | Set Interface State | ${dut2} | ${dut2_eth_bond_if1} | up
246 | | VPP Set interface MTU | ${dut1} | ${dut1_eth_bond_if1}
247 | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
248 | | ... | Variable Should Exist | ${dut2_if1}
249 | | Run Keyword If | '${if1_status}' == 'PASS'
250 | | ... | VPP Enslave Physical Interface | ${dut2} | ${dut2_if1}
251 | | ... | ${dut2_eth_bond_if1}
252 | | ... | ELSE
253 | | ... | VPP Enslave Physical Interface | ${dut2} | ${dut2_if1_1}
254 | | ... | ${dut2_eth_bond_if1}
255 | | Run Keyword Unless | '${if2_status}' == 'PASS'
256 | | ... | VPP Enslave Physical Interface | ${dut2} | ${dut2_if1_2}
257 | | ... | ${dut2_eth_bond_if1}
258 | | VPP Show Bond Data On All Nodes | ${nodes} | verbose=${TRUE}
259 | | Initialize VLAN dot1q sub-interfaces in circular topology
260 | | ... | ${dut1} | ${dut1_eth_bond_if1} | ${dut2} | ${dut2_eth_bond_if1}
261 | | ... | ${subid}
262 | | Configure L2 tag rewrite method on interfaces
263 | | ... | ${dut1} | ${subif_index_1} | ${dut2} | ${subif_index_2}
264 | | ... | ${tag_rewrite}
265 | | Configure vhost interfaces
266 | | ... | ${dut1} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
267 | | Configure L2XC | ${dut1} | ${dut1_if1} | ${vhost_if1}
268 | | Configure L2XC | ${dut1} | ${subif_index_1} | ${vhost_if2}
269 | | Configure vhost interfaces
270 | | ... | ${dut2} | /var/run/vpp/sock-1-1 | /var/run/vpp/sock-1-2
271 | | Configure L2XC | ${dut2} | ${subif_index_2} | ${vhost_if1}
272 | | Configure L2XC | ${dut2} | ${dut2_if2} | ${vhost_if2}
273
274 | Initialize L2 xconnect with memif pairs on DUT node
275 | | [Documentation]
276 | | ... | Create pairs of Memif interfaces on DUT node. Cross connect each Memif
277 | | ... | interface with one physical interface or virtual interface to create
278 | | ... | a chain accross DUT node.
279 | |
280 | | ... | *Arguments:*
281 | | ... | - dut - DUT node. Type: dictionary
282 | | ... | - count - Number of memif pairs (containers). Type: integer
283 | |
284 | | ... | *Note:*
285 | | ... | Socket paths for Memif are defined in following format:
286 | | ... | - /tmp/memif-\${dut}_CNF\${number}-\${sid}
287 | |
288 | | ... | KW uses test variable \${rxq_count_int} set by KW Add worker threads
289 | | ... | and rxqueues to all DUTs
290 | |
291 | | ... | *Example:*
292 | |
293 | | ... | \| Initialize L2 xconnect with memif pairs on DUT node \| ${dut} \
294 | | ... | \| ${1} \|
295 | |
296 | | [Arguments] | ${dut} | ${count}
297 | |
298 | | FOR | ${number} | IN RANGE | 1 | ${count}+1
299 | | | ${sock1}= | Set Variable | memif-${dut}_CNF
300 | | | ${sock2}= | Set Variable | memif-${dut}_CNF
301 | | | ${prev_index}= | Evaluate | ${number}-1
302 | | | Set up memif interfaces on DUT node | ${nodes['${dut}']}
303 | | | ... | ${sock1} | ${sock2} | ${number} | ${dut}-memif-${number}-if1
304 | | | ... | ${dut}-memif-${number}-if2 | ${rxq_count_int} | ${rxq_count_int}
305 | | | ${xconnect_if1}= | Set Variable If | ${number}==1 | ${${dut}_if1}
306 | | | ... | ${${dut}-memif-${prev_index}-if2}
307 | | | Configure L2XC | ${nodes['${dut}']} | ${xconnect_if1}
308 | | | ... | ${${dut}-memif-${number}-if1}
309 | | | Run Keyword If | ${number}==${count} | Configure L2XC
310 | | | ... | ${nodes['${dut}']} | ${${dut}-memif-${number}-if2} | ${${dut}_if2}
311 | | END
312
313 | Initialize L2 xconnect with memif pairs
314 | | [Documentation]
315 | | ... | Create pairs of Memif interfaces on all defined VPP nodes. Cross
316 | | ... | connect each Memif interface with one physical interface or virtual
317 | | ... | interface to create a chain accross DUT node.
318 | |
319 | | ... | *Arguments:*
320 | | ... | - count - Number of memif pairs (containers). Type: integer
321 | |
322 | | ... | *Example:*
323 | |
324 | | ... | \| Initialize L2 xconnect with memif pairs \| ${1} \|
325 | |
326 | | [Arguments] | ${count}=${1}
327 | |
328 | | FOR | ${dut} | IN | @{duts}
329 | | | Initialize L2 xconnect with memif pairs on DUT node | ${dut} | ${count}
330 | | END
331 | | Set interfaces in path up
332 | | Show Memif on all DUTs | ${nodes}
333 | | VPP round robin RX placement on all DUTs | ${nodes} | prefix=memif
334
335 | Initialize L2 xconnect for single memif
336 | | [Documentation]
337 | | ... | Create single Memif interface on all defined VPP nodes. Cross
338 | | ... | connect Memif interface with one physical interface.
339 | |
340 | | ... | *Arguments:*
341 | | ... | - number - Memif ID. Type: integer
342 | |
343 | | ... | *Note:*
344 | | ... | Socket paths for Memif are defined in following format:
345 | | ... | - /tmp/memif-DUT1_CNF\${number}-\${sid}
346 | |
347 | | ... | KW uses test variable ${rxq_count_int} set by KW Add worker threads
348 | | ... | and rxqueues to all DUTs
349 | |
350 | | ... | *Example:*
351 | |
352 | | ... | \| Initialize L2 xconnect for single memif \| 1 \|
353 | |
354 | | [Arguments] | ${number}=${1}
355 | |
356 | | FOR | ${dut} | IN | @{duts}
357 | | | ${sock}= | Set Variable | memif-${dut}_CNF
358 | | | ${sid}= | Evaluate | (${number} * ${2}) - ${1}
359 | | | Set up single memif interface on DUT node | ${nodes['${dut}']} | ${sock}
360 | | | ... | mid=${number} | sid=${sid} | memif_if=${dut}-memif-${number}-if1
361 | | | ... | rxq=${rxq_count_int} | txq=${rxq_count_int}
362 | | | Configure L2XC | ${nodes['${dut}']} | ${${dut}_if1}
363 | | | ... | ${${dut}-memif-${number}-if1}
364 | | END
365 | | Set single interfaces in path up
366 | | Show Memif on all DUTs | ${nodes}
367 | | VPP round robin RX placement on all DUTs | ${nodes} | prefix=memif