CSIT-427: Honeycomb ietf-ACL tests - L2
[csit.git] / resources / libraries / robot / honeycomb / 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.honeycomb.HcAPIKwBridgeDomain.BridgeDomainKeywords
17 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ...     | WITH NAME | InterfaceAPI
19 | Library | resources.libraries.python.InterfaceUtil
20 | ...     | WITH NAME | interfaceCLI
21
22 *** Keywords ***
23 | Honeycomb creates first L2 bridge domain
24 | | [Documentation] | Uses Honeycomb API to create a bridge domain on the \
25 | | ... | VPP node. Any other bridge domains will be removed in the process.
26 | | ...
27 | | ... | *Arguments:*
28 | | ... | - node - Information about a DUT node. Type: dictionary
29 | | ... | - bd_name - Name of the created bridge domain. Type: string
30 | | ... | - settings - Settings for the created bridge domain. Type: dictionary
31 | | ...
32 | | ... | *Example:*
33 | | ...
34 | | ... | \| Honeycomb creates first L2 bridge domain \| ${nodes['DUT1']} \
35 | | ... | \| bd-04 \| ${{flood:True, learn:False}} \|
36 | | [Arguments] | ${node} | ${bd_name} | ${settings}
37 | | Add first BD | ${node} | ${bd_name} | &{settings}
38
39 | Honeycomb creates L2 bridge domain
40 | | [Documentation] | Uses Honeycomb API to create a bridge domain on the \
41 | | ... | VPP node.
42 | | ...
43 | | ... | *Arguments:*
44 | | ... | - node - Information about a DUT node. Type: dictionary
45 | | ... | - bd_name - Name of the created bridge domain. Type: string
46 | | ... | - settings - Settings for the created bridge domain. Type: dictionary
47 | | ...
48 | | ... | *Example:*
49 | | ...
50 | | ... | \| Honeycomb creates L2 bridge domain \| ${nodes['DUT1']} \
51 | | ... | \| bd-04 \| ${{flood:True, learn:False}} \|
52 | | [Arguments] | ${node} | ${bd_name} | ${settings}
53 | | Add BD | ${node} | ${bd_name} | &{settings}
54
55 | Bridge domain configuration from Honeycomb should be
56 | | [Documentation] | Uses Honeycomb API to verify bridge domain settings\
57 | | ... | against provided values.
58 | | ...
59 | | ... | *Arguments:*
60 | | ... | - node - Information about a DUT node. Type: dictionary
61 | | ... | - bd_name - Name of the bridge domain. Type: string
62 | | ... | - settings - Expected settings for the bridge domain. Type: dictionary
63 | | ...
64 | | ... | *Example:*
65 | | ...
66 | | ... | \| Bridge domain configuration from Honeycomb should be \
67 | | ... | \| ${nodes['DUT1']} \| bd-04 \| ${{flood:True,learn:False}} \|
68 | | [Arguments] | ${node} | ${bd_name} | ${settings}
69 | | ${api_data}= | Get bd oper data | ${node} | ${bd_name}
70 | | :FOR | ${key} | IN | @{settings.keys()}
71 | | | Should be equal | ${settings['${key}']} | ${api_data['${key}']}
72
73 | Bridge domain configuration from VAT should be
74 | | [Documentation] | Uses VAT to verify bridge domain settings\
75 | | ... | against provided values.
76 | | ...
77 | | ... | *Arguments:*
78 | | ... | - node - Information about a DUT node. Type: dictionary
79 | | ... | - bd_name - Name of the bridge domain. Type: string
80 | | ... | - settings - Expected settings for the bridge domain. Type: dictionary
81 | | ...
82 | | ... | *Example:*
83 | | ...
84 | | ... | \| Bridge domain configuration from VAT should be \
85 | | ... | \| ${nodes['DUT1']} \| bd-04 \| ${{flood:True,learn:False}} \|
86 | | [Arguments] | ${node} | ${bd_index} | ${settings}
87 | | ${vat_data}= | VPP get bridge domain data | ${node}
88 | | ${vat_data}= | Set Variable | ${vat_data[${bd_index}]}
89 | | :FOR | ${key} | IN | @{settings.keys()}
90 | | | Run keyword if | $key in $vat_data.keys()
91 | | | ... | Should be equal | ${settings['${key}']} | ${vat_data['${key}']}
92
93 | Honeycomb adds interfaces to bridge domain
94 | | [Documentation] | Uses Honeycomb API to assign interfaces to a bridge\
95 | | ... | domain.
96 | | ...
97 | | ... | *Arguments:*
98 | | ... | - node - Information about a DUT node. Type: dictionary
99 | | ... | - interface1, interface2 - Names of interfaces to assign to bridge\
100 | | ... | domain. Type: string
101 | | ... | - bd_name - Name of the bridge domain. Type: string
102 | | ... | - settings - Bridge domain specific interface settings.\
103 | | ... | Type: dictionary
104 | | ...
105 | | ... | *Example:*
106 | | ...
107 | | ... | \| Honeycomb adds interfaces to bridge domain \| ${nodes['DUT1']} \
108 | | ... | \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \| bd-04 \
109 | | ... | \| ${{split_horizon_group:2, bvi:False}} \|
110 | | [Arguments] | ${node} | ${interface1} | ${interface2} | ${bd_name}
111 | | ... | ${settings}
112 | | interfaceAPI.Add bridge domain to interface
113 | | ... | ${node} | ${interface1} | ${bd_name} | &{settings}
114 | | interfaceAPI.Add bridge domain to interface
115 | | ... | ${node} | ${interface2} | ${bd_name} | &{settings}
116
117 | Honeycomb should show interfaces assigned to bridge domain
118 | | [Documentation] | Uses Honeycomb API to verify interface assignment to\
119 | | ... | bridge domain.
120 | | ...
121 | | ... | *Arguments:*
122 | | ... | - node - Information about a DUT node. Type: dictionary
123 | | ... | - interface1, interface2 - Names of interfaces to assign to bridge\
124 | | ... | domain. Type: string
125 | | ... | - bd_name - Name of the bridge domain. Type: string
126 | | ... | - settings - Bridge domain specific interface settings.\
127 | | ... | Type: dictionary
128 | | ...
129 | | ... | *Example:*
130 | | ...
131 | | ... | \| Honeycomb should show interfaces assigned to bridge domain \
132 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \
133 | | ... | \| bd-04 \| ${{split_horizon_group:2, bvi:False}} \|
134 | | [Arguments] | ${node} | ${interface1} | ${interface2} | ${bd_name}
135 | | ... | ${settings}
136 | | ${if1_data}= | interfaceAPI.Get interface oper data
137 | | ... | ${node} | ${interface1}
138 | | ${if2_data}= | interfaceAPI.Get interface oper data
139 | | ... | ${node} | ${interface2}
140 | | Should be equal | ${if1_data['v3po:l2']['bridge-domain']}
141 | | ... | ${if2_data['v3po:l2']['bridge-domain']} | ${bd_name}
142 | | Should be equal | ${if1_data['v3po:l2']['split-horizon-group']}
143 | | ... | ${if2_data['v3po:l2']['split-horizon-group']}
144 | | ... | ${settings['split_horizon_group']}
145 | | Should be equal | ${if1_data['v3po:l2']['bridged-virtual-interface']}
146 | | ... | ${if2_data['v3po:l2']['bridged-virtual-interface']}
147 | | ... | ${settings['bvi']}
148
149 | VAT should show interfaces assigned to bridge domain
150 | | [Documentation] | Uses VAT to verify interface assignment to\
151 | | ... | bridge domain.
152 | | ...
153 | | ... | *Arguments:*
154 | | ... | - node - Information about a DUT node. Type: dictionary
155 | | ... | - index - Index of bridge domains on VPP node. Starts from 0,\
156 | | ... | new BDs reuse numbers after a bridge domain is removed. Type: int
157 | | ... | - interface1, interface2 - names of interfaces to check bridge domain\
158 | | ... | assignment on. Type: string
159 | | ... | - settings - bridge domain specific interface settings.\
160 | | ... | Type: dictionary
161 | | ...
162 | | ... | *Example:*
163 | | ...
164 | | ... | \| VAT should show interfaces assigned to bridge domain \
165 | | ... | \| ${nodes['DUT1']} \| ${4} \| GigabitEthernet0/8/0 \
166 | | ... | \| GigabitEthernet0/9/0 \| ${{split_horizon_group:2, bvi:False}} \|
167 | | [Arguments] | ${node} | ${index} | ${interface1} | ${interface2}
168 | | ... | ${settings}
169 | | ${if1_link}= | Get interface by name | ${node} | ${interface1}
170 | | ${if2_link}= | Get interface by name | ${node} | ${interface2}
171 | | ${if_indices}= | Create list
172 | | ... | ${node['interfaces']['${if1_link}']['vpp_sw_index']}
173 | | ... | ${node['interfaces']['${if2_link}']['vpp_sw_index']}
174 | | ${bd_data}= | VPP get bridge domain data | ${node}
175 | | ${bd_interfaces}= | Set Variable | ${bd_data[${index}]['sw_if']}
176 | | @{bd_interfaces}= | Create List | ${bd_interfaces[0]} | ${bd_interfaces[1]}
177 | | :FOR | ${interface} | IN | @{bd_interfaces}
178 | | | Should contain | ${if_indices} | ${interface['sw_if_index']}
179 | | | Should be equal | ${interface['shg']} | ${settings['split_horizon_group']}
180
181 | Honeycomb should not show interfaces assigned to bridge domain
182 | | [Documentation] | Uses Honeycomb API to verify interfaces are not assigned\
183 | | ... | to bridge domain.
184 | | ...
185 | | ... | *Arguments:*
186 | | ... | - node - Information about a DUT node. Type: dictionary
187 | | ... | - interface1, interface2 - Names of interfaces to check\
188 | | ... | bridge domain assignment on. Type: string
189 | | ... | - bd_name - Name of the bridge domain. Type: string
190 | | ...
191 | | ... | *Example:*
192 | | ...
193 | | ... | \| Honeycomb should not show interfaces assigned to bridge domain \
194 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \
195 | | ... | \| bd-04 \|
196 | | [Arguments] | ${node} | ${interface1} | ${interface2} | ${bd_name}
197 | | ${if1_data_oper}= | interfaceAPI.Get interface oper data
198 | | ... | ${node} | ${interface1}
199 | | ${if2_data_oper}= | interfaceAPI.Get interface oper data
200 | | ... | ${node} | ${interface2}
201 | | ${if1_data_cfg}=
202 | | ... | interfaceAPI.Get interface cfg data | ${node} | ${interface1}
203 | | ${if1_data_cfg}=
204 | | ... | interfaceAPI.Get interface cfg data | ${node} | ${interface2}
205 | | Run keyword and expect error | *KeyError: 'v3po:l2'*
206 | | ... | Set Variable | ${if1_data_oper['v3po:l2']}
207 | | Run keyword and expect error | *KeyError: 'v3po:l2'*
208 | | ... | Set Variable | ${if2_data_oper['v3po:l2']}
209 | | Run keyword and expect error | *KeyError: 'v3po:l2'*
210 | | ... | Set Variable | ${if1_data_cfg['v3po:l2']}
211 | | Run keyword and expect error | *KeyError: 'v3po:l2'*
212 | | ... | Set Variable | ${if2_data_cfg['v3po:l2']}
213
214 | Honeycomb removes all bridge domains
215 | | [Documentation] | Uses Honeycomb API to remove all bridge domains from the \
216 | | ... | VPP node.
217 | | ...
218 | | ... | *Arguments:*
219 | | ... | - node - Information about a DUT node. Type: dictionary
220 | | ...
221 | | ... | *Example:*
222 | | ...
223 | | ... | \| Honeycomb removes all bridge domains \| ${nodes['DUT1']} \|
224 | | [Arguments] | ${node} | @{interfaces}
225 | | :FOR | ${interface} | IN | @{interfaces}
226 | | | Remove bridge domain from interface | ${node} | ${interface}
227 | | Remove all bridge domains | ${node}
228
229 | Honeycomb should show no bridge domains
230 | | [Documentation] | Uses Honeycomb API to verify the removal of all\
231 | | ... | bridge domains.
232 | | ...
233 | | ... | *Arguments:*
234 | | ... | - node - Information about a DUT node. Type: dictionary
235 | | ...
236 | | ... | *Example:*
237 | | ...
238 | | ... | \| Honeycomb should show no bridge domains \| ${nodes['DUT1']} \|
239 | | [Arguments] | ${node}
240 | | ${bd_data}= | Get all BDs oper data | ${node}
241 | | Should be empty | ${bd_data}
242
243 | VAT should show no bridge domains
244 | | [Documentation] | Uses VAT to verify the removal of all bridge domains.
245 | | ...
246 | | ... | *Arguments:*
247 | | ... | - node - Information about a DUT node. Type: dictionary
248 | | ...
249 | | ... | *Example:*
250 | | ...
251 | | ... | \| VAT should show no bridge domains \| ${nodes['DUT1']} \|
252 | | [Arguments] | ${node}
253 | | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
254 | | ... | VPP get bridge domain data | ${node}
255
256 | Honeycomb adds interface to bridge domain
257 | | [Documentation] | Uses Honeycomb API to assign interface to a bridge\
258 | | ... | domain.
259 | | ...
260 | | ... | *Arguments:*
261 | | ... | - node - Information about a DUT node. Type: dictionary
262 | | ... | - interface - Name of interface to assign to bridge domain.\
263 | | ... | Type: string
264 | | ... | - bd_name - Name of the bridge domain. Type: string
265 | | ... | - settings - Bridge domain specific interface settings.\
266 | | ... | Type: dictionary
267 | | ...
268 | | ... | *Example:*
269 | | ...
270 | | ... | \| Honeycomb adds interfaces to bridge domain \| ${nodes['DUT1']} \
271 | | ... | \| GigabitEthernet0/8/0 \| bd-04 \
272 | | ... | \| ${{split_horizon_group:2, bvi:False}} \|
273 | | ...
274 | | [Arguments] | ${node} | ${interface} | ${bd_name} | ${settings}
275 | | ...
276 | | interfaceAPI.Add bridge domain to interface
277 | | ... | ${node} | ${interface} | ${bd_name}
278 | | ... | ${settings['split-horizon-group']}
279 | | ... | ${settings['bridged-virtual-interface']}
280
281 | Bridge domain configuration in interface operational data should be empty
282 | | [Documentation] | Get interface operational data and retrieve bridge
283 | | ... | domain configuration from it. It should be empty.
284 | | ...
285 | | ... | *Arguments:*
286 | | ... | - node - Information about a DUT node. Type: dictionary
287 | | ... | - interface - Name of interface where the bridge domain parameters \
288 | | ... | will be checked.Type: string
289 | | ...
290 | | ... | *Example:*
291 | | ... | \| Bridge domain configuration in interface operational data should \
292 | | ... | be empty \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
293 | | ...
294 | | [Arguments] | ${node} | ${interface}
295 | | ...
296 | | ${if_data}= | interfaceAPI.Get BD Oper Data From Interface
297 | | ... | ${node} | ${interface}
298 | | Should be empty | ${if_data}
299
300 | Bridge domain configuration in interface operational data should be
301 | | [Documentation] | Get interface operational data and retrieve bridge
302 | | ... | domain configuration from it. Compare the data to the expected one.
303 | | ...
304 | | ... | *Arguments:*
305 | | ... | - node - Information about a DUT node. Type: dictionary
306 | | ... | - interface - Name of interface where the bridge domain parameters \
307 | | ... | will be checked. Type: string
308 | | ... | - bd_settings - The referential bridge domain data. Type: dictionary
309 | | ...
310 | | ... | *Example:*
311 | | ... | \| Bridge domain configuration in interface operational data should \
312 | | ... | be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${if_bd_settings} \|
313 | | ...
314 | | [Arguments] | ${node} | ${interface} | ${bd_settings}
315 | | ...
316 | | ${if_data}= | interfaceAPI.Get BD Oper Data From Interface
317 | | ... | ${node} | ${interface}
318 | | interfaceAPI.Compare Data Structures | ${if_data} | ${bd_settings}
319
320 | VAT removes bridge domain
321 | | [Documentation] Remove the specified bridge domain using VAT.
322 | | ...
323 | | ... | *Arguments:*
324 | | ... | - node - Information about a DUT node. Type: dictionary
325 | | ... | - bd_id - Bridge domain ID. Type: integer
326 | | ...
327 | | ... | *Example:*
328 | | ... | \| VAT removes bridge domain \
329 | | ... | \| ${nodes['DUT1']} \| 1 \|
330 | | ...
331 | | [Arguments] | ${node} | ${bd_id}
332 | | ...
333 | | Delete Bridge Domain VAT | ${node} | ${bd_id}