Modify tests and keywords for sub-interfaces.
[csit.git] / resources / libraries / robot / honeycomb / sub_interface.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.InterfaceUtil
16 | ...     | WITH NAME | interfaceCLI
17 | Library | resources.libraries.python.L2Util
18 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
19 | ...     | WITH NAME | InterfaceAPI
20 | Resource | resources/libraries/robot/honeycomb/bridge_domain.robot
21 | Documentation | Keywords used to manipulate sub-interfaces.
22
23 *** Keywords ***
24 | Honeycomb creates sub-interface
25 | | [Documentation] | Create a sub-interface using Honeycomb API.
26 | | ...
27 | | ... | *Arguments:*
28 | | ... | - node - Information about a DUT node. Type: dictionary
29 | | ... | - super_interface - Super-interface where a sub-interface will be\
30 | | ... | created. Type: string
31 | | ... | - match - Match type. Type: string
32 | | ... | - tags - List of tags to be set while creating the sub-interface.\
33 | | ... | Type: list
34 | | ... | - sub_interface_settings - Sub-inteface parameters to be set while\
35 | | ... | creating the sub-interface. Type: dictionary
36 | | ...
37 | | ... | *Example:*
38 | | ... | \| Honeycomb creates sub-interface\
39 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0\
40 | | ... | \| vlan-tagged-exact-match \| ${sub_if_1_tags}\
41 | | ... | \| ${sub_if_1_settings} \|
42 | | ...
43 | | [Arguments] | ${node} | ${super_interface}
44 | | ... | ${match} | ${tags} | ${sub_interface_settings}
45 | | ...
46 | | interfaceAPI.Create sub interface | ${node} | ${super_interface}
47 | | ... | ${match} | ${tags} | &{sub_interface_settings}
48
49 | Sub-interface configuration from Honeycomb should be
50 | | [Documentation] | Retrieves sub-interface configuration through Honeycomb\
51 | | ... | and compares it with settings supplied in argument.
52 | | ...
53 | | ... | *Arguments:*
54 | | ... | - node - Information about a DUT node. Type: dictionary
55 | | ... | - super_interface - Super-interface. Type: string
56 | | ... | - identifier - Sub-interface ID. Type: integer or string
57 | | ... | - sub_if_settings - Operational data for sub-interface to be checked.\
58 | | ... | Type: dictionary
59 | | ...
60 | | ... | *Example:*
61 | | ... | \| Sub-interface configuration from Honeycomb should be\
62 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1\
63 | | ... | \| ${sub_if_1_params} \|
64 | | ...
65 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
66 | | ... | ${sub_if_settings}
67 | | ...
68 | | ${api_data}= | interfaceAPI.Get sub interface oper data
69 | | ... | ${node} | ${super_interface} | ${identifier}
70 | | interfaceAPI.Compare Data Structures | ${api_data} | ${sub_if_settings}
71
72 | Sub-interface configuration from Honeycomb should be empty
73 | | [Documentation] | Retrieves sub-interface configuration through Honeycomb \
74 | | ... | and expects no data.
75 | | ...
76 | | ... | *Arguments:*
77 | | ... | - node - Information about a DUT node. Type: dictionary
78 | | ... | - super_interface - Super-interface. Type: string
79 | | ... | - identifier - Sub-interface ID. Type: integer or string
80 | | ...
81 | | ... | *Example:*
82 | | ... | \| Sub-interface configuration from Honeycomb should be empty\
83 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \|
84 | | ...
85 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
86 | | ...
87 | | Run keyword and expect error | *KeyError: 'sub-interface'*
88 | | ... | interfaceAPI.Get sub interface oper data
89 | | ... | ${node} | ${super_interface} | ${identifier}
90
91 | Sub-interface state from Honeycomb should be
92 | | [Documentation] | Retrieves sub-interface configuration through Honeycomb \
93 | | ... | and checks the administrative and operational state.
94 | | ...
95 | | ... | *Arguments:*
96 | | ... | - node - Information about a DUT node. Type: dictionary
97 | | ... | - super_interface - Super-interface. Type: string
98 | | ... | - identifier - Sub-interface ID. Type: integer or string
99 | | ... | - admin_state - Required administrative state - up or down. \
100 | | ... | Type: string
101 | | ... | - oper_state - Required operational state - up or down. Type: string
102 | | ...
103 | | ... | *Example:*
104 | | ... | \| Sub-interface state from Honeycomb should be\
105 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \| up \| up \|
106 | | ...
107 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
108 | | ... | ${admin_state} | ${oper_state}
109 | | ...
110 | | ${api_data}= | interfaceAPI.Get sub interface oper data
111 | | ... | ${node} | ${super_interface} | ${identifier}
112 | | Should be equal | ${api_data['admin-status']} | ${admin_state}
113 | | Should be equal | ${api_data['oper-status']} | ${oper_state}
114
115 | Sub-interface configuration from VAT should be
116 | | [Documentation] | Retrieves sub-interface configuration through VAT and\
117 | | ... | compares it with settings supplied in argument.
118 | | ...
119 | | ... | *Arguments:*
120 | | ... | - node - Information about a DUT node. Type: dictionary
121 | | ... | - sub_interface - Name of an sub-interface on the specified node.\
122 | | ... | Type: string
123 | | ... | - sub_interface_settings - Operational data specific for a\
124 | | ... | sub-interface to be checked. Type: dictionary
125 | | ...
126 | | ... | *Example:*
127 | | ... | \| Sub-interface configuration from VAT should be\
128 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0.1 \| ${sub_if_1_params} \|
129 | | ...
130 | | [Arguments] | ${node} | ${sub_interface} | ${sub_interface_settings}
131 | | ...
132 | | ${vat_data}= | InterfaceCLI.VPP get interface data
133 | | ... | ${node} | ${sub_interface}
134 | | Should be equal as strings | ${vat_data['sub_id']}
135 | | ... | ${sub_interface_settings['identifier']}
136 | | Should be equal as strings
137 | | ... | ${vat_data['interface_name']} | ${sub_interface}
138 | | Run keyword if | ${vat_data['link_up_down']} == 0
139 | | ... | Should be equal as strings
140 | | ... | ${sub_interface_settings['oper-status']} | down
141 | | Run keyword if | ${vat_data['link_up_down']} == 1
142 | | ... | Should be equal as strings
143 | | ... | ${sub_interface_settings['oper-status']} | up
144
145 | Sub-interface state from VAT should be
146 | | [Documentation] | Retrieves sub-interface configuration through VAT and \
147 | | ... | checks the administrative and operational state.
148 | | ...
149 | | ... | *Arguments:*
150 | | ... | - node - Information about a DUT node. Type: dictionary
151 | | ... | - sub_interface - Name of an sub-interface on the specified node. \
152 | | ... | Type: string
153 | | ... | - admin_state - Required administrative state - up or down. \
154 | | ... | Type: string
155 | | ... | - oper_state - Required operational state - up or down. Type: string
156 | | ...
157 | | ... | *Example:*
158 | | ... | \| Sub-interface state from VAT should be \
159 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0.1 \| up \| up \|
160 | | ...
161 | | [Arguments] | ${node} | ${sub_interface} | ${admin_state} | ${oper_state}
162 | | ...
163 | | ${vat_data}= | InterfaceCLI.VPP get interface data
164 | | ... | ${node} | ${sub_interface}
165 | | Run keyword if | '${admin_state}' == 'down'
166 | | ... | Should be equal as strings | ${vat_data['admin_up_down']} | 0
167 | | Run keyword if | '${admin_state}' == 'up'
168 | | ... | Should be equal as strings | ${vat_data['admin_up_down']} | 1
169 | | Run keyword if | '${oper_state}' == 'down'
170 | | ... | Should be equal as strings | ${vat_data['link_up_down']} | 0
171 | | Run keyword if | '${oper_state}' == 'up'
172 | | ... | Should be equal as strings | ${vat_data['link_up_down']} | 1
173
174 | Sub-interface indices from Honeycomb and VAT should correspond
175 | | [Documentation] | Uses VAT and Honeycomb to get operational data about the\
176 | | ... | given sub-interface and compares the interface indexes. The
177 | | ... | sub-interface index from Honeycomb should be greater than index from
178 | | ... | VAT by one.
179 | | ...
180 | | ... | *Arguments:*
181 | | ... | - node - Information about a DUT node. Type: dictionary
182 | | ... | - super_interface - Super-interface. Type: string
183 | | ... | - identifier - Sub-interface ID. Type: integer or string
184 | | ...
185 | | ... | *Example:*
186 | | ...
187 | | ... | \| Sub-interface indices from Honeycomb and VAT should correspond \
188 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \|
189 | | ...
190 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
191 | | ...
192 | | ${api_data}= | interfaceAPI.Get sub interface oper data
193 | | ... | ${node} | ${super_interface} | ${identifier}
194 | | ${vat_data}= | InterfaceCLI.VPP get interface data
195 | | ... | ${node} | ${super_interface}.${identifier}
196 | | ${sw_if_index}= | EVALUATE | ${vat_data['sw_if_index']} + 1
197 | | Should be equal as strings
198 | | ... | ${api_data['if-index']} | ${sw_if_index}
199
200 | Honeycomb sets the sub-interface up
201 | | [Documentation] | Honeycomb sets the sub-interface up.
202 | | ...
203 | | ... | *Arguments:*
204 | | ... | - node - Information about a DUT node. Type: dictionary
205 | | ... | - super_interface - Super-interface. Type: string
206 | | ... | - identifier - Sub-interface ID. Type: integer or string
207 | | ...
208 | | ... | *Example:*
209 | | ... | Honeycomb sets the sub-interface up\
210 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \|
211 | | ...
212 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
213 | | ...
214 | | interfaceAPI.Set sub interface state
215 | | ... | ${node} | ${super_interface} | ${identifier} | up
216
217 | Honeycomb sets the sub-interface down
218 | | [Documentation] | Honeycomb sets the sub-interface down.
219 | | ...
220 | | ... | *Arguments:*
221 | | ... | - node - Information about a DUT node. Type: dictionary
222 | | ... | - super_interface - Super-interface. Type: string
223 | | ... | - identifier - Sub-interface ID. Type: integer or string
224 | | ...
225 | | ... | *Example:*
226 | | ... | Honeycomb sets the sub-interface down\
227 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \|
228 | | ...
229 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
230 | | ...
231 | | interfaceAPI.Set sub interface state
232 | | ... | ${node} | ${super_interface} | ${identifier} | down
233
234 | Honeycomb fails to set sub-interface up
235 | | [Documentation] | Honeycomb tries to set sub-interface up and expects error.
236 | | ...
237 | | ... | *Arguments:*
238 | | ... | - node - Information about a DUT node. Type: dictionary
239 | | ... | - super_interface - Super-interface. Type: string
240 | | ... | - identifier - Sub-interface ID. Type: integer or string
241 | | ...
242 | | ... | *Example:*
243 | | ... | \| Honeycomb fails to set sub-interface up\
244 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \|
245 | | ...
246 | | [Arguments] | ${node} | ${super_interface} | ${identifier}
247 | | ...
248 | | Run keyword and expect error | *HoneycombError: * was not successful. * 500.
249 | | ... | interfaceAPI.Set sub interface state
250 | | ... | ${node} | ${super_interface} | ${identifier} | up
251
252 | Honeycomb adds sub-interface to bridge domain
253 | | [Documentation] | Honeycomb adds the given sub-interface to bridge domain.
254 | | ...
255 | | ... | *Arguments:*
256 | | ... | - node - Information about a DUT node. Type: dictionary
257 | | ... | - super_if - Super-interface. Type: string
258 | | ... | - identifier - Sub-interface ID. Type: integer or string
259 | | ... | - sub_bd_setings - Bridge domain parameters to be set while adding\
260 | | ... | the sub-interface to the bridge domain. Type: dictionary
261 | | ...
262 | | ... | *Example:*
263 | | ... | \| Honeycomb adds sub-interface to bridge domain\
264 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \| ${bd_settings} \|
265 | | ...
266 | | [Arguments] | ${node} | ${super_if} | ${identifier} | ${sub_bd_setings}
267 | | ...
268 | | interfaceAPI.Add bridge domain to sub interface
269 | | ... | ${node} | ${super_if} | ${identifier} | ${sub_bd_setings}
270
271 | Sub-interface bridge domain configuration from Honeycomb should be
272 | | [Documentation] | Uses Honeycomb API to verify sub-interface assignment to\
273 | | ... | a bridge domain.
274 | | ...
275 | | ... | *Arguments:*
276 | | ... | - node - Information about a DUT node. Type: dictionary
277 | | ... | - super_if - Super-interface. Type: string
278 | | ... | - identifier - Sub-interface ID. Type: integer or string
279 | | ... | - settings - Bridge domain parameters to be checked. Type: dictionary
280 | | ...
281 | | ... | *Example:*
282 | | ... | \| Sub-interface bridge domain configuration from Honeycomb should be\
283 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \| ${bd_settings} \|
284 | | ...
285 | | [Arguments] | ${node} | ${super_if} | ${identifier} | ${settings}
286 | | ...
287 | | ${if_data}= | interfaceAPI.Get BD data from sub interface
288 | | ... | ${node} | ${super_if} | ${identifier}
289 | | Should be equal | ${if_data['bridge-domain']}
290 | | ... | ${settings['bridge-domain']}
291
292 | Sub-interface bridge domain configuration from VAT should be
293 | | [Documentation] | Uses VAT to verify sub-interface assignment to a bridge\
294 | | ... | domain.
295 | | ...
296 | | ... | *Arguments:*
297 | | ... | - node - Information about a DUT node. Type: dictionary
298 | | ... | - interface - Name of a sub-interface on the specified node. Type:\
299 | | ... | string
300 | | ... | - setings - Parameters to be checked. Type: dictionary
301 | | ...
302 | | ... | *Example:*
303 | | ... | \| Sub-interface bridge domain configuration from VAT should be\
304 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0.1 \| ${sub_bd_setings} \|
305 | | ...
306 | | [Arguments] | ${node} | ${interface} | ${settings}
307 | | ...
308 | | ${bd_data}= | VPP get bridge domain data | ${node}
309 | | ${bd_intf}= | Set Variable | ${bd_data[0]}
310 | | ${sw_if_data}= | Set Variable | ${bd_intf['sw_if'][0]}
311 | | Should be equal as integers | ${bd_intf['flood']} | ${bd_settings['flood']}
312 | | Should be equal as integers | ${bd_intf['forward']}
313 | | ... | ${bd_settings['forward']}
314 | | Should be equal as integers | ${bd_intf['learn']} | ${bd_settings['learn']}
315 | | Should be equal as strings | ${sw_if_data['shg']}
316 | | ... | ${settings['split-horizon-group']}
317
318 | Honeycomb fails to remove all sub-interfaces
319 | | [Documentation] | Honeycomb tries to remove all sub-interfaces using\
320 | | ... | Honeycomb API. This operation must fail.
321 | | ...
322 | | ... | *Arguments:*
323 | | ... | - node - Information about a DUT node. Type: dictionary
324 | | ... | - super_if - Super-interface. Type: string
325 | | ...
326 | | ... | *Example:*
327 | | ... | \| Honeycomb fails to remove all sub-interfaces\
328 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
329 | | ...
330 | | [Arguments] | ${node} | ${super_if}
331 | | ...
332 | | Run keyword and expect error | *HoneycombError:*not successful. * code: 500.
333 | | ... | interfaceAPI.Remove all sub interfaces
334 | | ... | ${node} | ${super_if}
335
336 | Honeycomb configures tag rewrite
337 | | [Documentation] | Honeycomb configures tag-rewrite
338 | | ...
339 | | ... | *Arguments:*
340 | | ... | - node - Information about a DUT node. Type: dictionary
341 | | ... | - super_if - Super-interface. Type: string
342 | | ... | - identifier - Sub-interface ID. Type: integer or string
343 | | ... | - settings - tag-rewrite parameters. Type: dictionary.
344 | | ...
345 | | ... | *Example:*
346 | | ... | \| Honeycomb configures tag rewrite\
347 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1\
348 | | ... | \| ${tag_rewrite_push} \|
349 | | ...
350 | | [Arguments] | ${node} | ${super_if} | ${identifier} | ${settings}
351 | | ...
352 | | interfaceAPI.Configure tag rewrite
353 | | ... | ${node} | ${super_if} | ${identifier} | ${settings}
354
355 | Rewrite tag from Honeycomb should be empty
356 | | [Documentation] | Checks if the tag-rewrite is empty or does not exist.
357 | | ...
358 | | ... | *Arguments:*
359 | | ... | - node - Information about a DUT node. Type: dictionary
360 | | ... | - super_if - Super-interface. Type: string
361 | | ... | - identifier - Sub-interface ID. Type: integer or string
362 | | ...
363 | | ... | *Example:*
364 | | ... | \| Rewrite tag from Honeycomb should be empty\
365 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1 \|
366 | | ...
367 | | [Arguments] | ${node} | ${super_if} | ${identifier}
368 | | ...
369 | | Run keyword and expect error | *Hon*Error*oper*does not contain*tag-rewrite*
370 | | ... | interfaceAPI.Get tag rewrite oper data
371 | | ... | ${node} | ${super_if} | ${identifier}
372
373 | Rewrite tag from Honeycomb should be
374 | | [Documentation] | Checks if the operational data retrieved from Honeycomb\
375 | | ... | are as expected.
376 | | ...
377 | | ... | *Arguments:*
378 | | ... | - node - Information about a DUT node. Type: dictionary
379 | | ... | - super_if - Super-interface. Type: string
380 | | ... | - identifier - Sub-interface ID. Type: integer or string
381 | | ... | - settings - tag-rewrite operational parameters to be checked.\
382 | | ... | Type: dictionary.
383 | | ...
384 | | ... | *Example:*
385 | | ... | \| Rewrite tag from Honeycomb should be\
386 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1\
387 | | ... | \| ${tag_rewrite_push_oper} \|
388 | | ...
389 | | [Arguments] | ${node} | ${super_if} | ${identifier} | ${settings}
390 | | ${api_data}= | interfaceAPI.Get tag rewrite oper data
391 | | ... | ${node} | ${super_if} | ${identifier}
392 | | interfaceAPI.Compare Data Structures | ${api_data} | ${settings}
393
394 | Rewrite tag from VAT should be
395 | | [Documentation] | Retrieves sub-interface configuration through VAT and\
396 | | ... | compares values of rewrite tag parameters with settings supplied in\
397 | | ... | argument.
398 | | ...
399 | | ... | *Arguments:*
400 | | ... | - node - information about a DUT node. Type: dictionary
401 | | ... | - interface - name of a sub-interface on the specified node.\
402 | | ... | Type: string
403 | | ... | - rw_settings - Parameters to be set while setting the rewrite tag.\
404 | | ... | Type: dictionary
405 | | ...
406 | | ... | *Example:*
407 | | ... | \| Rewrite tag from VAT should be\
408 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0.1 \| ${rw_params} \|
409 | | ...
410 | | [Arguments] | ${node} | ${interface} | ${rw_settings}
411 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
412 | | interfaceAPI.Compare Data Structures | ${vat_data} | ${rw_settings}
413
414 | Honeycomb fails to set wrong rewrite tag
415 | | [Documentation] | Honeycomb tries to set wrong rewrite tag and expects\
416 | | ... | an error.
417 | | ...
418 | | ... | *Arguments:*
419 | | ... | - node - Information about a DUT node. Type: dictionary
420 | | ... | - super_if - Super-interface. Type: string
421 | | ... | - identifier - Sub-interface ID. Type: integer or string
422 | | ... | - settings - tag-rewrite parameters. Type: dictionary.
423 | | ...
424 | | ... | *Example:*
425 | | ... | \| Honeycomb fails to set wrong rewrite tag\
426 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 1\
427 | | ... | \| ${tag_rewrite_push_WRONG} \|
428 | | ...
429 | | [Arguments] | ${node} | ${super_if} | ${identifier} | ${settings}
430 | | Run keyword and expect error | *HoneycombError: * was not successful. *00.
431 | | ... | interfaceAPI.Configure tag rewrite
432 | | ... | ${node} | ${super_if} | ${identifier} | ${settings}
433
434 | VAT disables tag-rewrite
435 | | [Documentation] | The keyword disables the tag-rewrite using VAT.
436 | | ...
437 | | ... | *Arguments:*
438 | | ... | - node - Information about a DUT node. Type: dictionary
439 | | ... | - sub_interface - Name of an sub-interface on the specified node.\
440 | | ... | Type: string
441 | | ...
442 | | ... | *Example:*
443 | | ... | \| VAT disables tag-rewrite\
444 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0.1 \|
445 | | ...
446 | | [Arguments] | ${node} | ${sub_interface}
447 | | ...
448 | | ${sw_if_index}= | interfaceCLI.Get sw if index | ${node} | ${sub_interface}
449 | | L2 tag rewrite | ${node} | ${sw_if_index} | disable