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