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