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