dd68e3f22e2c9ece74f8724a09068911523ea76b
[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.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ...     | WITH NAME | InterfaceAPI
19 | Resource | resources/libraries/robot/honeycomb/bridge_domain.robot
20 | Documentation | Keywords used to manipulate sub-interfaces.
21
22 *** Variables ***
23 # Translation table used to convert values received from Honeycomb to values
24 # received from VAT.
25 | &{rewrite_operations}=
26 | ... | disabled=0
27 | ... | push-1=1
28 | ... | push-2=2
29 | ... | pop-1=3
30 | ... | pop-2=4
31 | ... | translate-1-to-1=5
32 | ... | translate-1-to-2=6
33 | ... | translate-2-to-1=7
34 | ... | translate-2-to-2=8
35
36 *** Keywords ***
37 | Honeycomb creates sub-interface
38 | | [Documentation] | Create a sub-interface using Honeycomb API.
39 | | ...
40 | | ... | *Arguments:*
41 | | ... | - node - information about a DUT node. Type: dictionary
42 | | ... | - interface - name of an interface on the specified node. Type: string
43 | | ... | - identifier - ID of sub-interface to be created. Type: integer
44 | | ... | - sub_interface_base_settings - Configuration data for sub-interface.\
45 | | ... | Type: dictionary
46 | | ... | - sub_interface_settings - Configuration data specific for a\
47 | | ... | sub-interface. Type: dictionary
48 | | ...
49 | | ... | *Example:*
50 | | ... | \| Honeycomb creates sub-interface\
51 | | ... | \| ${nodes['DUT1']} \| sub_test \| 10 \| ${sub_interface_settings} \|
52 | | ...
53 | | [Arguments] | ${node} | ${interface} | ${identifier}
54 | | ... | ${sub_interface_base_settings} | ${sub_interface_settings}
55 | | interfaceAPI.Create sub interface | ${node} | ${interface}
56 | | ... | &{sub_interface_base_settings} | &{sub_interface_settings}
57
58 | Honeycomb fails to remove sub-interface
59 | | [Documentation] | Honeycomb tries to remove sub-interface using Honeycomb\
60 | | ... | API. This operation must fail.
61 | | ...
62 | | ... | *Arguments:*
63 | | ... | - node - information about a DUT node. Type: dictionary
64 | | ... | - interface - name of a sub-interface on the specified node.
65 | | ... | Type: string
66 | | ...
67 | | ... | *Example:*
68 | | ... | \| Honeycomb fails to remove sub-interface\
69 | | ... | \| ${nodes['DUT1']} \| sub_test \|
70 | | ...
71 | | [Arguments] | ${node} | ${interface}
72 | | Run keyword and expect error | *HoneycombError: Not possible to remove* 500.
73 | | ... | interfaceAPI.Delete interface | ${node} | ${interface}
74
75 | Sub-interface configuration from Honeycomb should be
76 | | [Documentation] | Retrieves sub-interface configuration through Honeycomb\
77 | | ... | and compares it with settings supplied in argument.
78 | | ...
79 | | ... | *Arguments:*
80 | | ... | - node - information about a DUT node. Type: dictionary
81 | | ... | - interface - name of an interface on the specified node. Type: string
82 | | ... | - base_settings - Configuration data for sub-interface.\
83 | | ... | Type: dictionary
84 | | ... | - sub_settings - Configuration data specific for a sub-interface.\
85 | | ... | Type: dictionary
86 | | ...
87 | | ... | *Example:*
88 | | ... | \| Sub-interface configuration from Honeycomb should be\
89 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${sub_interface_base_settings}\
90 | | ... | \| ${sub_interface_settings} \|
91 | | ...
92 | | [Arguments] | ${node} | ${interface} | ${base_settings} | ${sub_settings}
93 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
94 | | ${api_sub}= | Set Variable | ${api_data['v3po:sub-interface']}
95 | | :FOR | ${key} | IN | @{base_settings.keys()}
96 | | | Should be equal | ${api_data['${key}']} | ${base_settings['${key}']}
97 | | Should be equal as strings
98 | | ... | ${api_sub['super-interface']} | ${sub_settings['super-interface']}
99 | | Should be equal as strings
100 | | ... | ${api_sub['identifier']} | ${sub_settings['identifier']}
101 | | Should be equal as strings
102 | | ... | ${api_sub['vlan-type']} | ${sub_settings['vlan-type']}
103 | | Should be equal as strings
104 | | ... | ${api_sub['number-of-tags']} | ${sub_settings['number-of-tags']}
105 | | Run keyword if | ${sub_settings['match-any-outer-id']} == ${TRUE}
106 | | ... | Should be equal | ${api_sub['match-any-outer-id'][0]} | ${None}
107 | | Run keyword if | ${sub_settings['match-any-inner-id']} == ${TRUE}
108 | | ... | Should be equal | ${api_sub['match-any-inner-id'][0]} | ${None}
109 | | Run keyword if | ${sub_settings['exact-match']} == ${TRUE}
110 | | ... | Should be equal | ${api_sub['exact-match'][0]} | ${None}
111 | | Run keyword if | ${sub_settings['default-subif']} == ${TRUE}
112 | | ... | Should be equal | ${api_sub['default-subif'][0]} | ${None}
113
114 | Sub-interface configuration from VAT should be
115 | | [Documentation] | Retrieves sub-interface configuration through VAT and\
116 | | ... | compares it with settings supplied in argument.
117 | | ...
118 | | ... | *Arguments:*
119 | | ... | - node - information about a DUT node. Type: dictionary
120 | | ... | - interface - name of an interface on the specified node. Type: string
121 | | ... | - sub_settings - Configuration data specific for a sub-interface.\
122 | | ... | Type: dictionary
123 | | ...
124 | | ... | *Example:*
125 | | ... | \| Sub-interface configuration from VAT should be\
126 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${sub_interface_base_settings}\
127 | | ... | \| ${sub_interface_settings} \|
128 | | ...
129 | | [Arguments] | ${node} | ${interface} | ${sub_settings}
130 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
131 | | Should be equal as strings | ${vat_data['sub_id']}
132 | | ... | ${sub_settings['identifier']}
133 | | Should be equal as strings | ${vat_data['sub_number_of_tags']}
134 | | ... | ${sub_settings['number-of-tags']}
135 | | Run keyword if | ${sub_settings['match-any-outer-id']} == ${TRUE}
136 | | ... | Should be equal as integers | ${vat_data['sub_outer_vlan_id_any']}
137 | | ... | ${sub_settings['match-any-outer-id']}
138 | | Run keyword if | ${sub_settings['match-any-inner-id']} == ${TRUE}
139 | | ... | Should be equal as integers | ${vat_data['sub_inner_vlan_id_any']}
140 | | ... | ${sub_settings['match-any-inner-id']}
141 | | Run keyword if | ${sub_settings['exact-match']} == ${TRUE}
142 | | ... | Should be equal as integers | ${vat_data['sub_exact_match']}
143 | | ... | ${sub_settings['exact-match']}
144 | | Run keyword if | ${sub_settings['default-subif']} == ${TRUE}
145 | | ... | Should be equal as integers | ${vat_data['sub_default']}
146 | | ... | ${sub_settings['default-subif']}
147
148 | Sub-interface configuration from Honeycomb should be empty
149 | | [Documentation] | Attempts to retrieve sub-interface configuration through\
150 | | ... | Honeycomb and expects to get empty dictionary.
151 | | ...
152 | | ... | *Arguments:*
153 | | ... | - node - information about a DUT node. Type: dictionary
154 | | ... | - interface - name of a sub-interface on the specified node. Type:\
155 | | ... | string
156 | | ...
157 | | ... | *Example:*
158 | | ... | \| Sub-interface configuration from Honeycomb should be empty\
159 | | ... | \| ${nodes['DUT1']} \| sub_test \|
160 | | ...
161 | | [Arguments] | ${node} | ${interface}
162 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
163 | | Should be empty | ${api_data}
164
165 | Sub-interface configuration from VAT should be empty
166 | | [Documentation] | Attempts to retrieve sub-interface configuration through\
167 | | ... | VAT and expects to get empty dictionary.
168 | | ...
169 | | ... | *Arguments:*
170 | | ... | - node - information about a DUT node. Type: dictionary
171 | | ... | - interface - name of a sub-interface on the specified node. Type:\
172 | | ... | string
173 | | ...
174 | | ... | *Example:*
175 | | ... | \| Sub-interface configuration from VAT should be empty\
176 | | ... | \| ${nodes['DUT1']} \| sub_test \|
177 | | ...
178 | | [Arguments] | ${node} | ${interface} |
179 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
180 | | Should be empty | ${vat_data}
181
182 | Honeycomb adds sub-interface to bridge domain
183 | | [Documentation] | Honeycomb adds the given sub-interface to bridge domain.
184 | | ...
185 | | ... | *Arguments:*
186 | | ... | - node - information about a DUT node. Type: dictionary
187 | | ... | - interface - name of an sub-interface on the specified node. Type:\
188 | | ... | string
189 | | ... | - bd_name - The name of bridge domain where the sub-interface will be\
190 | | ... | added. Type: string
191 | | ... | - sub_bd_setings - Parameters to be set while adding the\
192 | | ... | sub-interface to the bridge domain. Type: dictionary
193 | | ...
194 | | ... | *Example:*
195 | | ... | \| Honeycomb adds sub-interface to bridge domain\
196 | | ... | \| ${nodes['DUT1']} \| sub_test \| test_bd \| ${sub_bd_setings} \|
197 | | ...
198 | | [Arguments] | ${node} | ${interface} | ${bd_name} | ${sub_bd_setings}
199 | | interfaceAPI.Add bridge domain to interface
200 | | ... | ${node} | ${interface} | ${bd_name}
201 | | ... | split_horizon_group=${sub_bd_setings['split-horizon-group']}
202 | | ... | bvi=${sub_bd_setings['bridged-virtual-interface']}
203
204 | Sub-interface bridge domain configuration from Honeycomb should be
205 | | [Documentation] | Uses Honeycomb API to verify sub-interface assignment to\
206 | | ... | a bridge domain.
207 | | ...
208 | | ... | *Arguments:*
209 | | ... | - node - information about a DUT node. Type: dictionary
210 | | ... | - interface - name of a sub-interface on the specified node. Type:\
211 | | ... | string
212 | | ... | - setings - Parameters to be checked. Type: dictionary
213 | | ...
214 | | ... | *Example:*
215 | | ... | \| Sub-interface bridge domain configuration from Honeycomb should be\
216 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${sub_bd_setings} \|
217 | | ...
218 | | [Arguments] | ${node} | ${interface} | ${settings}
219 | | ${if_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
220 | | Should be equal | ${if_data['v3po:l2']['bridge-domain']}
221 | | ... | ${settings['bridge-domain']}
222 | | Should be equal | disabled
223 | | ... | ${if_data['v3po:l2']['vlan-tag-rewrite']['rewrite-operation']}
224
225 | Sub-interface bridge domain configuration from VAT should be
226 | | [Documentation] | Uses VAT to verify sub-interface assignment to a bridge\
227 | | ... | domain.
228 | | ...
229 | | ... | *Arguments:*
230 | | ... | - node - information about a DUT node. Type: dictionary
231 | | ... | - interface - name of a sub-interface on the specified node. Type:\
232 | | ... | string
233 | | ... | - setings - Parameters to be checked. Type: dictionary
234 | | ...
235 | | ... | *Example:*
236 | | ... | \| Sub-interface bridge domain configuration from VAT should be\
237 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${sub_bd_setings} \|
238 | | ...
239 | | [Arguments] | ${node} | ${interface} | ${settings}
240 | | ${bd_data}= | VPP get bridge domain data | ${node}
241 | | ${bd_intf}= | Set Variable | ${bd_data[0]}
242 | | ${sw_if_data}= | Set Variable | ${bd_intf['sw_if'][0]}
243 | | Should be equal as integers | ${bd_intf['flood']} | ${bd_settings['flood']}
244 | | Should be equal as integers | ${bd_intf['forward']}
245 | | ... | ${bd_settings['forward']}
246 | | Should be equal as integers | ${bd_intf['learn']} | ${bd_settings['learn']}
247 | | Should be equal as strings | ${sw_if_data['shg']}
248 | | ... | ${settings['split-horizon-group']}
249
250 | Sub-interface configuration with bd and rw from Honeycomb should be
251 | | [Documentation] | Retrieves sub-interface configuration through Honeycomb\
252 | | ... | and compares it with settings supplied in argument.
253 | | ...
254 | | ... | *Arguments:*
255 | | ... | - node - information about a DUT node. Type: dictionary
256 | | ... | - interface - name of an interface on the specified node. Type: string
257 | | ... | - base_settings - Configuration data for sub-interface.\
258 | | ... | Type: dictionary
259 | | ... | - sub_settings - Configuration data specific for a sub-interface.\
260 | | ... | Type: dictionary
261 | | ...
262 | | ... | *Example:*
263 | | ... | \| Sub-interface configuration with bd and rw from Honeycomb should be\
264 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${sub_interface_base_settings}\
265 | | ... | \| ${sub_interface_settings} \|
266 | | ...
267 | | [Arguments] | ${node} | ${interface} | ${base_settings} | ${sub_settings}
268 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
269 | | ${api_sub}= | Set Variable | ${api_data['v3po:sub-interface']}
270 | | Should be equal as strings | ${api_data['name']} | ${base_settings['name']}
271 | | Should be equal as strings | ${api_data['type']} | ${base_settings['type']}
272 | | Should be equal as strings
273 | | ... | ${api_sub['super-interface']} | ${sub_settings['super-interface']}
274 | | Should be equal as strings
275 | | ... | ${api_sub['identifier']} | ${sub_settings['identifier']}
276 | | Should be equal as strings
277 | | ... | ${api_sub['vlan-type']} | ${sub_settings['vlan-type']}
278 | | Should be equal as strings
279 | | ... | ${api_sub['number-of-tags']} | ${sub_settings['number-of-tags']}
280 | | Run keyword if | ${sub_settings['match-any-outer-id']} == ${TRUE}
281 | | ... | Should be equal | ${api_sub['match-any-outer-id'][0]} | ${None}
282 | | Run keyword if | ${sub_settings['match-any-inner-id']} == ${TRUE}
283 | | ... | Should be equal | ${api_sub['match-any-inner-id'][0]} | ${None}
284 | | Run keyword if | ${sub_settings['exact-match']} == ${TRUE}
285 | | ... | Should be equal | ${api_sub['exact-match'][0]} | ${None}
286 | | Run keyword if | ${sub_settings['default-subif']} == ${TRUE}
287 | | ... | Should be equal | ${api_sub['default-subif'][0]} | ${None}
288 | | Should be equal | ${api_data['v3po:l2']['bridge-domain']}
289 | | ... | ${base_settings['v3po:l2']['bridge-domain']}
290 | | ${rw_data}= | Set Variable | ${api_data['v3po:l2']['vlan-tag-rewrite']}
291 | | ${rw_params}= | Set Variable
292 | | ... | ${base_settings['v3po:l2']['vlan-tag-rewrite']}
293 | | Should be equal as strings | ${rw_data['rewrite-operation']}
294 | | ... | ${rw_params['rewrite-operation']}
295 | | Should be equal as strings | ${rw_data['first-pushed']}
296 | | ... | ${rw_params['first-pushed']}
297
298 | Rewrite tag configuration from VAT should be
299 | | [Documentation] | Retrieves sub-interface configuration through VAT and\
300 | | ... | compares values of rewrite tag parameters with settings supplied in\
301 | | ... | argument.
302 | | ...
303 | | ... | *Arguments:*
304 | | ... | - node - information about a DUT node. Type: dictionary
305 | | ... | - interface - name of an interface on the specified node. Type: string
306 | | ... | - rw_settings - Parameters to be set while setting the rewrite tag.\
307 | | ... | Type: dictionary
308 | | ...
309 | | ... | *Example:*
310 | | ... | \| Rewrite tag configuration from VAT should be\
311 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${rw_params} \|
312 | | ...
313 | | [Arguments] | ${node} | ${interface} | ${rw_settings}
314 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
315 | | Should be equal as strings | ${vat_data['vtr_op']}
316 | | ... | ${rewrite_operations['${rw_settings['rewrite-operation']}']}
317 | | Run keyword if | '${rw_settings['rewrite-operation']}' == 'push-1'
318 | | ... | Should be equal as strings
319 | | ... | ${vat_data['vtr_tag1']} | ${rw_settings['tag1']}
320
321 | Honeycomb sets rewrite tag
322 | | [Documentation] | Set the rewrite tag for sub-interface using Honeycomb API.
323 | | ...
324 | | ... | *Arguments:*
325 | | ... | - node - information about a DUT node. Type: dictionary
326 | | ... | - sub_interface - name of an sub-interface on the specified node.\
327 | | ... | Type: string
328 | | ... | - rw_params - Parameters to be set while setting the rewrite tag.\
329 | | ... | Type: dictionary
330 | | ...
331 | | ... | *Example:*
332 | | ... | \| Honeycomb sets rewrite tag\
333 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${rw_params} \|
334 | | ...
335 | | [Arguments] | ${node} | ${sub_interface} | ${rw_params}
336 | | interfaceAPI.Add vlan tag rewrite to sub interface
337 | | ... | ${node} | ${sub_interface} | &{rw_params}
338
339 | Honeycomb removes rewrite tag
340 | | [Documentation] | Remove the rewrite tag from sub-interface using Honeycomb\
341 | | ... | API.
342 | | ...
343 | | ... | *Arguments:*
344 | | ... | - node - information about a DUT node. Type: dictionary
345 | | ... | - sub_interface - name of an sub-interface on the specified node.\
346 | | ... | Type: string
347 | | ...
348 | | ... | *Example:*
349 | | ... | \| Honeycomb removes rewrite tag \| ${nodes['DUT1']} \| sub_test \|
350 | | ...
351 | | [Arguments] | ${node} | ${sub_interface}
352 | | interfaceAPI.Remove vlan tag rewrite from sub interface
353 | | ... | ${node} | ${sub_interface}
354
355 | Rewrite tag from Honeycomb should be
356 | | [Documentation] | Uses Honeycomb API to verify if the rewrite tag is set\
357 | | ... | with correct parameters.
358 | | ...
359 | | ... | *Arguments:*
360 | | ... | - node - information about a DUT node. Type: dictionary
361 | | ... | - sub_interface - name of an sub-interface on the specified node.\
362 | | ... | Type: string
363 | | ... | - rw_params - Parameters to be checked. Type: dictionary
364 | | ...
365 | | ... | *Example:*
366 | | ... | \| Rewrite tag from Honeycomb should be\
367 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${rw_params} \|
368 | | ...
369 | | [Arguments] | ${node} | ${sub_interface} | ${rw_params}
370 | | ${if_data}= | interfaceAPI.Get interface oper data | ${node}
371 | | ... | ${sub_interface}
372 | | ${rw_data}= | Set Variable | ${if_data['v3po:l2']["vlan-tag-rewrite"]}
373 | | Should be equal as strings | ${rw_data['rewrite-operation']}
374 | | ... | ${rw_params['rewrite-operation']}
375 | | Should be equal as strings | ${rw_data['first-pushed']}
376 | | ... | ${rw_params['first-pushed']}
377
378 | Honeycomb fails to set wrong rewrite tag
379 | | [Documentation] | Honeycomb tries to set wrong rewrite tag and expects\
380 | | ... | error.
381 | | ...
382 | | ... | *Arguments:*
383 | | ... | - node - information about a DUT node. Type: dictionary
384 | | ... | - sub_interface - name of an sub-interface on the specified node.\
385 | | ... | Type: string
386 | | ... | - rw_params - Parameters to be set while setting the rewrite tag.\
387 | | ... | Type: dictionary
388 | | ...
389 | | ... | *Example:*
390 | | ... | \| Honeycomb fails to set wrong rewrite tag\
391 | | ... | \| ${nodes['DUT1']} \| sub_test \| ${rw_params} \|
392 | | ...
393 | | [Arguments] | ${node} | ${sub_interface} | ${rw_params}
394 | | Run keyword and expect error | *HoneycombError: * was not successful. * 400.
395 | | ... | interfaceAPI.Add vlan tag rewrite to sub interface | ${node}
396 | | ... | ${sub_interface} | &{rw_params}
397
398 | Honeycomb fails to set sub-interface up
399 | | [Documentation] | Honeycomb tries to set sub-interface up and expects error.
400 | | ...
401 | | ... | *Arguments:*
402 | | ... | - node - information about a DUT node. Type: dictionary
403 | | ... | - sub_interface - name of an sub-interface on the specified node.\
404 | | ... | Type: string
405 | | ...
406 | | ... | *Example:*
407 | | ... | \| Honeycomb fails to set sub-interface up\
408 | | ... | \| ${node} \| sub_test \|
409 | | ...
410 | | [Arguments] | ${node} | ${sub_interface}
411 | | Run keyword and expect error | *HoneycombError: * was not successful. * 500.
412 | | ... | interfaceAPI.Set interface up | ${node} | ${sub_interface}