9cd3a70a978d7ab2ec3ca78e7e41ac3f002788c3
[csit.git] / resources / libraries / robot / bridge_domain.robot
1 # Copyright (c) 2016 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 | Library | resources.libraries.python.NodePath
18 | Library | resources.libraries.python.VhostUser
19 | Library | resources.libraries.python.QemuUtils
20 | Resource | resources/libraries/robot/interfaces.robot
21 | Resource | resources/libraries/robot/l2_traffic.robot
22
23 *** Keywords ***
24 | Path for 2-node BD testing is set
25 | | [Documentation] | Compute path for bridge domain testing on two given nodes
26 | | ...             | and set corresponding test case variables.
27 | | ...
28 | | ... | *Arguments:*
29 | | ... | - ${tg_node} - TG node. Type: dictionary
30 | | ... | - ${dut_node} - DUT node. Type: dictionary
31 | | ...
32 | | ... | *Return:*
33 | | ... | - No value returned
34 | | ...
35 | | ... | _NOTE:_ This KW sets following test case variables:
36 | | ... | - ${tg_node} - TG node.
37 | | ... | - ${tg_to_dut_if1} - 1st TG interface towards DUT.
38 | | ... | - ${tg_to_dut_if2} - 2nd TG interface towards DUT.
39 | | ... | - ${dut_node} - DUT node.
40 | | ... | - ${dut_to_tg_if1} - 1st DUT interface towards TG.
41 | | ... | - ${dut_to_tg_if2} - 2nd DUT interface towards TG.
42 | | ...
43 | | ... | *Example:*
44 | | ...
45 | | ... | \| Given Path for 2-node BD testing is set \| ${nodes['TG']} \
46 | | ... | \| ${nodes['DUT1']} \|
47 | | [Arguments] | ${tg_node} | ${dut_node}
48 | | Append Nodes | ${tg_node} | ${dut_node} | ${tg_node}
49 | | Compute Path | always_same_link=${FALSE}
50 | | ${tg_to_dut_if1} | ${tmp}= | First Interface
51 | | ${tg_to_dut_if2} | ${tmp}= | Last Interface
52 | | ${dut_to_tg_if1} | ${tmp}= | First Ingress Interface
53 | | ${dut_to_tg_if2} | ${tmp}= | Last Egress Interface
54 | | Set Test Variable | ${tg_to_dut_if1}
55 | | Set Test Variable | ${tg_to_dut_if2}
56 | | Set Test Variable | ${dut_to_tg_if1}
57 | | Set Test Variable | ${dut_to_tg_if2}
58 | | Set Test Variable | ${tg_node}
59 | | Set Test Variable | ${dut_node}
60
61 | Vpp l2bd forwarding setup
62 | | [Documentation] | Setup BD between 2 interfaces on VPP node and if learning
63 | | ...             | is off set static L2FIB entry on second interface
64 | | [Arguments] | ${node} | ${if1} | ${if2} | ${learn}=${TRUE} | ${mac}=${EMPTY}
65 | | Set Interface State | ${node} | ${if1} | up
66 | | Set Interface State | ${node} | ${if2} | up
67 | | Vpp Add L2 Bridge Domain | ${node} | ${1} | ${if1} | ${if2} | ${learn}
68 | | Run Keyword If | ${learn} == ${FALSE}
69 | | ... | Vpp Add L2fib Entry | ${node} | ${mac} | ${if2} | ${1}
70 | | All Vpp Interfaces Ready Wait | ${nodes}
71
72 | Path for 3-node BD testing is set
73 | | [Documentation] | Compute path for bridge domain testing on three given
74 | | ...             | nodes and set corresponding test case variables.
75 | | ...
76 | | ... | *Arguments:*
77 | | ... | - ${tg_node} - TG node. Type: dictionary
78 | | ... | - ${dut1_node} - DUT1 node. Type: dictionary
79 | | ... | - ${dut2_node} - DUT2 node. Type: dictionary
80 | | ...
81 | | ... | *Return:*
82 | | ... | - No value returned
83 | | ... |
84 | | ... | _NOTE:_ This KW sets following test case variables:
85 | | ... | - ${tg_node} - TG node.
86 | | ... | - ${tg_to_dut1} - TG interface towards DUT1.
87 | | ... | - ${tg_to_dut2} - TG interface towards DUT2.
88 | | ... | - ${dut1_node} - DUT1 node.
89 | | ... | - ${dut1_to_tg} - DUT1 interface towards TG.
90 | | ... | - ${dut1_to_dut2} - DUT1 interface towards DUT2.
91 | | ... | - ${dut2_node} - DUT2 node.
92 | | ... | - ${dut2_to_tg} - DUT2 interface towards TG.
93 | | ... | - ${dut2_to_dut1} - DUT2 interface towards DUT1.
94 | | ...
95 | | ... | *Example:*
96 | | ...
97 | | ... | \| Given Path for 3-node BD testing is set \| ${nodes['TG']} \
98 | | ... | \| ${nodes['DUT1']} \| ${nodes['DUT2']} \|
99 | | [Arguments] | ${tg_node} | ${dut1_node} | ${dut2_node}
100 | | Append Nodes | ${tg_node} | ${dut1_node} | ${dut2_node} | ${tg_node}
101 | | Compute Path
102 | | ${tg_to_dut1} | ${tmp}= | Next Interface
103 | | ${dut1_to_tg} | ${tmp}= | Next Interface
104 | | ${dut1_to_dut2} | ${tmp}= | Next Interface
105 | | ${dut2_to_dut1} | ${tmp}= | Next Interface
106 | | ${dut2_to_tg} | ${tmp}= | Next Interface
107 | | ${tg_to_dut2} | ${tmp}= | Next Interface
108 | | Set Test Variable | ${tg_to_dut1}
109 | | Set Test Variable | ${dut1_to_tg}
110 | | Set Test Variable | ${tg_to_dut2}
111 | | Set Test Variable | ${dut2_to_tg}
112 | | Set Test Variable | ${dut1_to_dut2}
113 | | Set Test Variable | ${dut2_to_dut1}
114 | | Set Test Variable | ${tg_node}
115 | | Set Test Variable | ${dut1_node}
116 | | Set Test Variable | ${dut2_node}
117
118 | Path for 3-node BD-SHG testing is set
119 | | [Documentation] | Compute path for bridge domain split-horizon group testing
120 | | ...             | on three given nodes with following interconnections
121 | | ...             | TG - (2 links) - DUT1 - (1 link) - DUT2 - (2 links) - TG
122 | | ...             | and set corresponding test case variables.
123 | | ...
124 | | ... | *Arguments:*
125 | | ... | - ${tg_node} - TG node. Type: dictionary
126 | | ... | - ${dut1_node} - DUT1 node. Type: dictionary
127 | | ... | - ${dut2_node} - DUT2 node. Type: dictionary
128 | | ...
129 | | ... | *Return:*
130 | | ... | - No value returned
131 | | ... |
132 | | ... | _NOTE:_ This KW sets following test case variables:
133 | | ... | - ${tg_node} - TG node.
134 | | ... | - ${tg_to_dut1_if1} - TG interface 1 towards DUT1.
135 | | ... | - ${tg_to_dut1_if2} - TG interface 2 towards DUT1.
136 | | ... | - ${tg_to_dut2_if1} - TG interface 1 towards DUT2.
137 | | ... | - ${tg_to_dut2_if2} - TG interface 2 towards DUT2.
138 | | ... | - ${dut1_node} - DUT1 node.
139 | | ... | - ${dut1_to_tg_if1} - DUT1 interface 1 towards TG.
140 | | ... | - ${dut1_to_tg_if2} - DUT1 interface 2 towards TG.
141 | | ... | - ${dut1_to_dut2} - DUT1 interface towards DUT2.
142 | | ... | - ${dut2_node} - DUT2 node.
143 | | ... | - ${dut2_to_tg_if1} - DUT2 interface 1 towards TG.
144 | | ... | - ${dut2_to_tg_if2} - DUT2 interface 2 towards TG.
145 | | ... | - ${dut2_to_dut1} - DUT2 interface towards DUT1.
146 | | ...
147 | | ... | *Example:*
148 | | ...
149 | | ... | \| Given Path for 3-node BD-SHG testing is set \| ${nodes['TG']} \
150 | | ... | \| ${nodes['DUT1']} \| ${nodes['DUT2']} \|
151 | | [Arguments] | ${tg_node} | ${dut1_node} | ${dut2_node}
152 | | # Compute path TG - DUT1 with two links in between
153 | | Append Nodes | ${tg_node} | ${dut1_node} | ${tg_node}
154 | | Compute Path | always_same_link=${FALSE}
155 | | ${tg_to_dut1_if1} | ${tmp}= | First Interface
156 | | ${tg_to_dut1_if2} | ${tmp}= | Last Interface
157 | | ${dut1_to_tg_if1} | ${tmp}= | First Ingress Interface
158 | | ${dut1_to_tg_if2} | ${tmp}= | Last Egress Interface
159 | | # Compute path TG - DUT2 with two links in between
160 | | Clear Path
161 | | Append Nodes | ${tg_node} | ${dut2_node} | ${tg_node}
162 | | Compute Path | always_same_link=${FALSE}
163 | | ${tg_to_dut2_if1} | ${tmp}= | First Interface
164 | | ${tg_to_dut2_if2} | ${tmp}= | Last Interface
165 | | ${dut2_to_tg_if1} | ${tmp}= | First Ingress Interface
166 | | ${dut2_to_tg_if2} | ${tmp}= | Last Egress Interface
167 | | # Compute path DUT1 - DUT2 with one link in between
168 | | Clear Path
169 | | Append Nodes | ${dut1_node} | ${dut2_node}
170 | | Compute Path
171 | | ${dut1_to_dut2} | ${tmp}= | Next Interface
172 | | ${dut2_to_dut1} | ${tmp}= | Next Interface
173 | | # Set test variables
174 | | Set Test Variable | ${tg_to_dut1_if1}
175 | | Set Test Variable | ${tg_to_dut1_if2}
176 | | Set Test Variable | ${tg_to_dut2_if1}
177 | | Set Test Variable | ${tg_to_dut2_if2}
178 | | Set Test Variable | ${dut1_to_tg_if1}
179 | | Set Test Variable | ${dut1_to_tg_if2}
180 | | Set Test Variable | ${dut2_to_tg_if1}
181 | | Set Test Variable | ${dut2_to_tg_if2}
182 | | Set Test Variable | ${dut1_to_dut2}
183 | | Set Test Variable | ${dut2_to_dut1}
184 | | Set Test Variable | ${tg_node}
185 | | Set Test Variable | ${dut1_node}
186 | | Set Test Variable | ${dut2_node}
187
188 | Bridge domain on DUT node is created
189 | | [Documentation] | Create bridge domain on given VPP node with defined
190 | | ...             | learning status.
191 | | ...
192 | | ... | *Arguments:*
193 | | ... | - ${dut_node} - DUT node. Type: dictionary
194 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
195 | | ... | - ${learn} - Enable/disable MAC learn. Type: boolean, \
196 | | ... | default value: ${TRUE}
197 | | ...
198 | | ... | *Return:*
199 | | ... | - No value returned
200 | | ...
201 | | ... | *Example:*
202 | | ...
203 | | ... | \| Bridge domain on DUT node is created \| ${nodes['DUT1']} \| 2 \|
204 | | ... | \| Bridge domain on DUT node is created \| ${nodes['DUT1']} \| 5 \
205 | | ... | \| learn=${FALSE} \|
206 | | [Arguments] | ${dut_node} | ${bd_id} | ${learn}=${TRUE}
207 | | ${learn} = | Set Variable If | ${learn} == ${TRUE} | ${1} | ${0}
208 | | Create L2 BD | ${dut_node} | ${bd_id} | learn=${learn}
209
210 | Interface is added to bridge domain
211 | | [Documentation] | Set given interface admin state to up and add this
212 | | ...             | interface to required L2 bridge domain on defined
213 | | ...             | VPP node.
214 | | ...
215 | | ... | *Arguments:*
216 | | ... | - ${dut_node} - DUT node. Type: dictionary
217 | | ... | - ${dut_if} - DUT node interface name. Type: string
218 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
219 | | ... | - ${shg} - Split-horizon group ID. Type: integer, default value: 0
220 | | ...
221 | | ... | *Return:*
222 | | ... | - No value returned
223 | | ...
224 | | ... | *Example:*
225 | | ...
226 | | ... | \| Interface is added to bridge domain \| ${nodes['DUT2']} \
227 | | ... | \| GigabitEthernet0/8/0 \| 3 \|
228 | | [Arguments] | ${dut_node} | ${dut_if} | ${bd_id} | ${shg}=0
229 | | Set Interface State | ${dut_node} | ${dut_if} | up
230 | | Add Interface To L2 BD | ${dut_node} | ${dut_if} | ${bd_id} | ${shg}
231
232 | Destination port is added to L2FIB on DUT node
233 | | [Documentation] | Create a static L2FIB entry for required destination port
234 | | ...             | on defined interface and bridge domain ID
235 | | ...             | of the given VPP node.
236 | | ...
237 | | ... | *Arguments:*
238 | | ... | - ${dest_node} - Destination node. Type: dictionary
239 | | ... | - ${dest_node_if} - Destination node interface name. Type: string
240 | | ... | - ${vpp_node} - DUT node to add L2FIB entry on. Type: dictionary
241 | | ... | - ${vpp_node_if} - DUT node interface name. Type: string
242 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
243 | | ...
244 | | ... | *Return:*
245 | | ... | - No value returned
246 | | ...
247 | | ... | *Example:*
248 | | ...
249 | | ... | \| Destination port is added to L2FIB on DUT node \| ${nodes['TG']} \
250 | | ... | \| eth1 \| ${nodes['DUT2']} \| GigabitEthernet0/8/0 \| 3 \|
251 | | [Arguments] | ${dest_node} | ${dest_node_if} | ${vpp_node}
252 | | ...         | ${vpp_node_if} | ${bd_id}
253 | | ${mac}= | Get Interface Mac | ${dest_node} | ${dest_node_if}
254 | | Vpp Add L2fib Entry | ${vpp_node} | ${mac} | ${vpp_node_if} | ${bd_id}
255
256 | VM for Vhost L2BD forwarding is setup
257 | | [Documentation] | Setup QEMU and start VM with two vhost interfaces.
258 | | ...
259 | | ... | *Arguments:*
260 | | ... | - ${node} - DUT node to start VM on. Type: dictionary
261 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
262 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
263 | | ...
264 | | ... | _NOTE:_ This KW sets following test case variable:
265 | | ... | -${vm_node} - VM node info. Type: dictionary
266 | | ...
267 | | ... | *Example:*
268 | | ...
269 | | ... | \| VM for Vhost L2BD forwarding is setup \| ${nodes['DUT1']} \
270 | | ... | \| /tmp/sock1 \| /tmp/sock2
271 | | [Arguments] | ${node} | ${sock1} | ${sock2}
272 | | Set Test Variable | ${vm_node} | ${None}
273 | | Qemu Set Node | ${node}
274 | | Qemu Add Vhost User If | ${sock1}
275 | | Qemu Add Vhost User If | ${sock2}
276 | | ${vm}= | Qemu Start
277 | | ${br}= | Set Variable | br0
278 | | ${vhost1}= | Get Vhost User If Name By Sock | ${vm} | ${sock1}
279 | | ${vhost2}= | Get Vhost User If Name By Sock | ${vm} | ${sock2}
280 | | Linux Add Bridge | ${vm} | ${br} | ${vhost1} | ${vhost2}
281 | | Set Interface State | ${vm} | ${vhost1} | up
282 | | Set Interface State | ${vm} | ${vhost2} | up
283 | | Set Interface State | ${vm} | ${br} | up
284 | | Set Test Variable | ${vm_node} | ${vm}
285
286 | VPP Vhost interfaces for L2BD forwarding are setup
287 | | [Documentation] | Create two Vhost-User interfaces on defined VPP node.
288 | | ...
289 | | ... | *Arguments:*
290 | | ... | - ${node} - DUT node. Type: dictionary
291 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
292 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
293 | | ...
294 | | ... | _NOTE:_ This KW sets following test case variable:
295 | | ... | - ${vhost_if1} - First Vhost-User interface.
296 | | ... | - ${vhost_if2} - Second Vhost-User interface.
297 | | ...
298 | | ... | *Example:*
299 | | ...
300 | | ... | \| VPP Vhost interfaces for L2BD forwarding are setup \
301 | | ... | \| ${nodes['DUT1']} \| /tmp/sock1 \| /tmp/sock2
302 | | [Arguments] | ${node} | ${sock1} | ${sock2}
303 | | ${vhost_if1}= | Vpp Create Vhost User Interface | ${node} | ${sock1}
304 | | ${vhost_if2}= | Vpp Create Vhost User Interface | ${node} | ${sock2}
305 | | Set Test Variable | ${vhost_if1}
306 | | Set Test Variable | ${vhost_if2}