3c91c77eb7f2d3af7383edbf0c45700765d21c16
[csit.git] / resources / libraries / robot / honeycomb / interfaces.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
20 *** Keywords ***
21 | Honeycomb sets interface state
22 | | [Documentation] | Uses Honeycomb API to change the admin state\
23 | | ... | of the specified interface.
24 | | ...
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - interface - name of an interface on the specified node. Type: string
28 | | ... | - state - state to set on interface. Type:string
29 | | ...
30 | | ... | *Example:*
31 | | ...
32 | | ... | \| Honeycomb sets interface state \| ${nodes['DUT1']} \
33 | | ... | \| GigabitEthernet0/8/0 \| up \|
34 | | [Arguments] | ${node} | ${interface} | ${state}
35 | | interfaceAPI.Set interface state | ${node} | ${interface} | ${state}
36
37 | Interface state from Honeycomb should be
38 | | [Documentation] | Retrieves interface admin state through Honeycomb and\
39 | | ... | compares with state supplied in argument.
40 | | ...
41 | | ... | *Arguments:*
42 | | ... | - node - information about a DUT node. Type: dictionary
43 | | ... | - interface - name of an interface on the specified node. Type: string
44 | | ... | - state - expected interface state. Type: string
45 | | ...
46 | | ... | *Example:*
47 | | ...
48 | | ... | \| Interface state from Honeycomb should be \| ${nodes['DUT1']} \
49 | | ... | \| GigabitEthernet0/8/0 \| up \|
50 | | [Arguments] | ${node} | ${interface} | ${state}
51 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
52 | | ${api_state}= | Set Variable | ${api_data['admin-status']}
53 | | Should be equal | ${api_state} | ${state}
54
55 | Interface state from VAT should be
56 | | [Documentation] | Retrieves interface admin state through VAT and compares\
57 | | ... | with state supplied in argument.
58 | | ...
59 | | ... | *Arguments:*
60 | | ... | - node - information about a DUT node. Type: dictionary
61 | | ... | - interface - name of an interface on the specified node. Type: string
62 | | ... | - state - expected interface state. Type: string
63 | | ...
64 | | ... | _NOTE:_ Vat returns state as int (1/0) instead of string (up/down).
65 | | ... | This keyword also handles translation.
66 | | ...
67 | | ... | *Example:*
68 | | ...
69 | | ... | \| Interface state from VAT should be \| ${nodes['DUT1']} \
70 | | ... | \| GigabitEthernet0/8/0 \| up \|
71 | | [Arguments] | ${node} | ${interface} | ${state}
72 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
73 | | ${vat_state}= | Set Variable if
74 | | ... | ${vat_data['admin_up_down']} == 1 | up | down
75 | | Should be equal | ${vat_state} | ${state}
76
77 | Honeycomb sets interface ipv4 address
78 | | [Documentation] | Uses Honeycomb API to change ipv4 address\
79 | | ... | of the specified interface.
80 | | ...
81 | | ... | *Arguments:*
82 | | ... | - node - information about a DUT node. Type: dictionary
83 | | ... | - interface - name of an interface on the specified node. Type: string
84 | | ... | - address - IP address to set. Type: string
85 | | ... | - netmask - subnet mask to set. Type: string
86 | | ...
87 | | ... | *Example:*
88 | | ...
89 | | ... | \| Honeycomb sets interface ipv4 address \| ${nodes['DUT1']} \
90 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
91 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
92 | | interfaceAPI.Add first ipv4 address
93 | | ... | ${node} | ${interface} | ${address} | ${netmask}
94
95 | Honeycomb sets interface ipv4 address with prefix
96 | | [Documentation] | Uses Honeycomb API to assign an ipv4 address to the\
97 | | ... | specified interface. Any existing addresses will be removed.
98 | | ...
99 | | ... | *Arguments:*
100 | | ... | - node - information about a DUT node. Type: dictionary
101 | | ... | - interface - name of an interface on the specified node. Type: string
102 | | ... | - address - IP address to set. Type: string
103 | | ... | - prefix - length of address network prefix. Type: int
104 | | ...
105 | | ... | *Example:*
106 | | ...
107 | | ... | \| Honeycomb sets interface ipv4 address with prefix \
108 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 24 \|
109 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
110 | | interfaceAPI.Add first ipv4 address
111 | | ... | ${node} | ${interface} | ${address} | ${prefix}
112
113 | IPv4 address from Honeycomb should be
114 | | [Documentation] | Retrieves interface ipv4 address through Honeycomb\
115 | | ... | and compares with state supplied in argument.
116 | | ...
117 | | ... | *Arguments:*
118 | | ... | - node - information about a DUT node. Type: dictionary
119 | | ... | - interface - name of an interface on the specified node. Type: string
120 | | ... | - address - IP address to expect. Type: string
121 | | ... | - prefix - prefix length to expect. Type: string
122 | | ...
123 | | ... | *Example:*
124 | | ...
125 | | ... | \| IPv4 address from Honeycomb should be \| ${nodes['DUT1']} \
126 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
127 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
128 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
129 | | Should be equal | ${address}
130 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['ip']}
131 | | Should be equal | ${prefix}
132 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['prefix-length']}
133
134 | IPv4 address from VAT should be
135 | | [Documentation] | Retrieves interface ipv4 address through VAT and\
136 | | ... | compares with state supplied in argument.
137 | | ...
138 | | ... | *Arguments:*
139 | | ... | - node - information about a DUT node. Type: dictionary
140 | | ... | - interface - name of an interface on the specified node. Type: string
141 | | ... | - address - IP address to expect. Type: string
142 | | ... | - netmask - subnet mask to expect. Type: string
143 | | ...
144 | | ... | *Example:*
145 | | ...
146 | | ... | \| IPv4 address from VAT should be \| ${nodes['DUT1']} \
147 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
148 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
149 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
150 | | ... | ${node} | ${interface} | ipv4
151 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
152 | | Should be equal | ${vpp_data[0]['netmask']} | ${netmask}
153
154 | Honeycomb removes interface ipv4 addresses
155 | | [Documentation] | Removes all configured ipv4 addresses from the specified\
156 | | ... | interface.
157 | | ...
158 | | ... | *Arguments:*
159 | | ... | - node - information about a DUT node. Type: dictionary
160 | | ... | - interface - name of an interface on the specified node. Type: string
161 | | ...
162 | | ... | *Example:*
163 | | ...
164 | | ... | \| Honeycomb removes interface ipv4 addresses \| ${nodes['DUT1']} \
165 | | ... | \| GigabitEthernet0/8/0 \|
166 | | [Arguments] | ${node} | ${interface}
167 | | Remove all ipv4 addresses | ${node} | ${interface}
168
169 | IPv4 address from Honeycomb should be empty
170 | | [Documentation] | Retrieves interface ipv4 configuration through Honeycomb\
171 | | ... | and expects to find no IPv4 addresses.
172 | | ...
173 | | ... | *Arguments:*
174 | | ... | - node - information about a DUT node. Type: dictionary
175 | | ... | - interface - name of an interface on the specified node. Type: string
176 | | ...
177 | | ... | *Example:*
178 | | ...
179 | | ... | \| IPv4 address from Honeycomb should be empty\| ${nodes['DUT1']} \
180 | | ... | \| GigabitEthernet0/8/0 \|
181 | | [Arguments] | ${node} | ${interface}
182 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
183 | | Run keyword and expect error | *KeyError: 'ietf-ip:ipv4'
184 | | ... | Set Variable | ${api_data['ietf-ip:ipv4']['address']}
185
186 | IPv4 address from VAT should be empty
187 | | [Documentation] | Retrieves interface ipv4 configuration through VAT and\
188 | | ... | and expects to find no ipv4 addresses.
189 | | ...
190 | | ... | *Arguments:*
191 | | ... | - node - information about a DUT node. Type: dictionary
192 | | ... | - interface - name of an interface on the specified node. Type: string
193 | | ...
194 | | ... | *Example:*
195 | | ...
196 | | ... | \| IPv4 config from VAT should be empty \| ${nodes['DUT1']} \
197 | | ... | \| GigabitEthernet0/8/0 \|
198 | | [Arguments] | ${node} | ${interface}
199 | | Run keyword and expect error | *No JSON object could be decoded*
200 | | ... | InterfaceCLI.VPP get interface ip addresses
201 | | ... | ${node} | ${interface} | ipv4
202
203 | Honeycomb adds interface ipv4 neighbor
204 | | [Documentation] | Uses Honeycomb API to assign an ipv4 neighbor to the\
205 | | ... | specified interface.
206 | | ...
207 | | ... | *Arguments:*
208 | | ... | - node - information about a DUT node. Type: dictionary
209 | | ... | - interface - name of an interface on the specified node. Type: string
210 | | ... | - fib_address - IP address to add to fib table. Type: string
211 | | ... | - fib_mac - MAC address to add to fib table. Type: string
212 | | ...
213 | | ... | *Example:*
214 | | ...
215 | | ... | \| Honeycomb adds interface ipv4 neighbor \| ${nodes['DUT1']} \
216 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
217 | | [Arguments] | ${node} | ${interface} | ${fib_address} | ${fib_mac}
218 | | interfaceAPI.Add ipv4 neighbor
219 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
220
221 | IPv4 neighbor from Honeycomb should be
222 | | [Documentation] | Retrieves ipv4 neighbor list through Honeycomb\
223 | | ... | and compares the first entry with addresses supplied in arguments.
224 | | ...
225 | | ... | *Arguments:*
226 | | ... | - node - information about a DUT node. Type: dictionary
227 | | ... | - interface - name of an interface on the specified node. Type: string
228 | | ... | - ip_address - ipv4 address of expected neighbor entry. Type: string
229 | | ... | - mac_address - MAC address of expected neighbor entry. Type: string
230 | | ...
231 | | ... | *Example:*
232 | | ...
233 | | ... | \| IPv4 neighbor from Honeycomb should be \| ${nodes['DUT1']} \
234 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.4 \| 08:00:27:60:26:ab \|
235 | | [Arguments] | ${node} | ${interface} | ${ip_address} | ${mac_address}
236 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
237 | | Should be equal | ${ip_address}
238 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['ip']}
239 | | Should be equal | ${mac_address}
240 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['link-layer-address']}
241
242 | Honeycomb clears all interface ipv4 neighbors
243 | | [Documentation] | Uses Honeycomb API to assign an ipv4 neighbor to the\
244 | | ... | specified interface.
245 | | ...
246 | | ... | *Arguments:*
247 | | ... | - node - information about a DUT node. Type: dictionary
248 | | ... | - interface - name of an interface on the specified node. Type: string
249 | | ...
250 | | ... | *Example:*
251 | | ...
252 | | ... | \| Honeycomb clears all interface ipv4 neighbors \| ${nodes['DUT1']} \
253 | | ... | \| GigabitEthernet0/8/0 \|
254 | | [Arguments] | ${node} | ${interface}
255 | | interfaceAPI.Remove all ipv4 neighbors | ${node} | ${interface}
256
257 | Honeycomb sets interface ipv6 address
258 | | [Documentation] | Uses Honeycomb API to change ipv6 address\
259 | | ... | of the specified interface.
260 | | ...
261 | | ... | *Arguments:*
262 | | ... | - node - information about a DUT node. Type: dictionary
263 | | ... | - interface - name of an interface on the specified node. Type: string
264 | | ... | - address - IP address to set. Type: string
265 | | ... | - prefix - length of subnet prefix to set. Type: string
266 | | ...
267 | | ... | *Example:*
268 | | ...
269 | | ... | \| Honeycomb sets interface ipv6 address \| ${nodes['DUT1']} \
270 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
271 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
272 | | interfaceAPI.Add first ipv6 address
273 | | ... | ${node} | ${interface} | ${address} | ${prefix}
274
275 | IPv6 address from Honeycomb should be
276 | | [Documentation] | Retrieves interface ipv6 address through Honeycomb\
277 | | ... | and compares with state supplied in argument.
278 | | ...
279 | | ... | *Arguments:*
280 | | ... | - node - information about a DUT node. Type: dictionary
281 | | ... | - interface - name of an interface on the specified node. Type: string
282 | | ... | - address - IP address to expect. Type: string
283 | | ... | - prefix - length of subnet prefix to expect. Type: string
284 | | ...
285 | | ... | *Example:*
286 | | ...
287 | | ... | \| IPv6 address from Honeycomb should be \| ${nodes['DUT1']} \
288 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
289 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
290 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
291 | | ${settings}= | Create Dictionary
292 | | ... | ip=${address} | prefix-length=${prefix}
293 | | Should contain | ${api_data['ietf-ip:ipv6']['address']} | ${settings}
294
295 | IPv6 address from VAT should be
296 | | [Documentation] | Retrieves interface ipv6 address through VAT and\
297 | | ... | compares with state supplied in argument.
298 | | ...
299 | | ... | *Arguments:*
300 | | ... | - node - information about a DUT node. Type: dictionary
301 | | ... | - interface - name of an interface on the specified node. Type: string
302 | | ... | - address - IP address to expect. Type: string
303 | | ... | - prefix - length of subnet prefix to expect. Type: string
304 | | ...
305 | | ... | *Example:*
306 | | ...
307 | | ... | \| IPv6 address from VAT should be \| ${nodes['DUT1']} \
308 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
309 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
310 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
311 | | ... | ${node} | ${interface} | ipv6
312 | | ${settings}= | Create Dictionary
313 | | ... | ip=${address} | prefix_length=${prefix}
314 | | Should contain | ${vpp_data} | ${settings}
315
316 | Honeycomb sets interface ethernet configuration
317 | | [Documentation] | Uses Honeycomb API to change interface ethernet\
318 | | ... | configuration.
319 | | ...
320 | | ... | *Arguments:*
321 | | ... | - node - information about a DUT node. Type: dictionary
322 | | ... | - interface - name of an interface on the specified node. Type: string
323 | | ... | - ethernet - interface ethernet settings. Type: dictionary
324 | | ...
325 | | ... | *Example:*
326 | | ...
327 | | ... | \| Honeycomb sets interface ethernet and routing configuration \
328 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${{'mtu': 1500}} \
329 | | [Arguments] | ${node} | ${interface} | ${ethernet}
330 | | :FOR | ${key} | IN | @{ethernet.keys()}
331 | | | interfaceAPI.Configure interface ethernet
332 | | | ... | ${node} | ${interface} | ${key} | ${ethernet['${key}']}
333
334 | Interface ethernet configuration from Honeycomb should be
335 | | [Documentation] | Retrieves interface ethernet configuration\
336 | | ... | through Honeycomb and compares with settings supplied in arguments.
337 | | ...
338 | | ... | *Arguments:*
339 | | ... | - node - information about a DUT node. Type: dictionary
340 | | ... | - interface - name of an interface on the specified node. Type: string
341 | | ... | - ethernet - interface ethernet settings. Type: dictionary
342 | | ...
343 | | ... | *Example:*
344 | | ...
345 | | ... | \| Interface ethernet and routing configuration from Honeycomb \
346 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
347 | | ... | \| ${{'mtu': 1500}} \|
348 | | [Arguments] | ${node} | ${interface} | ${ethernet}
349 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
350 | | :FOR | ${key} | IN | @{ethernet.keys()}
351 | | | Should be equal
352 | | | ... | ${api_data['v3po:ethernet']['${key}']} | ${ethernet['${key}']}
353
354 | Interface ethernet configuration from VAT should be
355 | | [Documentation] | Retrieves interface ethernet configuration\
356 | | ... | through VAT and compares with settings supplied in arguments.
357 | | ...
358 | | ... | *Arguments:*
359 | | ... | - node - information about a DUT node. Type: dictionary
360 | | ... | - interface - name of an interface on the specified node. Type: string
361 | | ... | - mtu - value of maximum transmission unit expected. Type: integer
362 | | ...
363 | | ... | *Example:*
364 | | ...
365 | | ... | \| Interface ethernet and routing configuration from VAT \
366 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1500} \|
367 | | [Arguments] | ${node} | ${interface} | ${mtu}
368 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
369 | | Should be equal | ${vat_data['mtu']} | ${mtu}
370
371 | Interface configuration from Honeycomb should be empty
372 | | [Documentation] | Attempts to retrieve interface configuration through\
373 | | ... | Honeycomb and expects to get empty dictionary.
374 | | ...
375 | | ... | *Arguments:*
376 | | ... | - node - information about a DUT node. Type: dictionary
377 | | ... | - interface - name of a interface on the specified node. Type:\
378 | | ... | string
379 | | ...
380 | | ... | *Example:*
381 | | ... | \| Interface configuration from Honeycomb should be empty\
382 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
383 | | ...
384 | | [Arguments] | ${node} | ${interface}
385 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
386 | | Should be empty | ${api_data}
387
388 | Interface configuration from VAT should be empty
389 | | [Documentation] | Attempts to retrieve Interface configuration through\
390 | | ... | VAT and expects to get empty dictionary.
391 | | ...
392 | | ... | *Arguments:*
393 | | ... | - node - information about a DUT node. Type: dictionary
394 | | ... | - interface - name of a Interface on the specified node. Type:\
395 | | ... | string
396 | | ...
397 | | ... | *Example:*
398 | | ... | \| Interface configuration from VAT should be empty\
399 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
400 | | ...
401 | | [Arguments] | ${node} | ${interface} |
402 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
403 | | Should be empty | ${vat_data}
404
405 | Interface indices from Honeycomb and VAT should correspond
406 | | [Documentation] | Uses VAT and Honeycomb to get operational data about the\
407 | | ... | given interface and compares the interface indexes. The interface
408 | | ... | index from Honeycomb should be greater than index from VAT by one.
409 | | ...
410 | | ... | *Arguments:*
411 | | ... | - node - information about a DUT node. Type: dictionary
412 | | ... | - interface - name of the interface to be checked. Type: string
413 | | ...
414 | | ... | *Example:*
415 | | ...
416 | | ... | \| Interface indices from Honeycomb and VAT should correspond \
417 | | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \|
418 | | ...
419 | | [Arguments] | ${node} | ${interface}
420 | | ...
421 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
422 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
423 | | ${sw_if_index}= | EVALUATE | ${vat_data['sw_if_index']} + 1
424 | | Should be equal as strings
425 | | ... | ${api_data['if-index']} | ${sw_if_index}
426
427 | Get Interface index from oper data
428 | | [Documentation] | Retrieves interface operational data and returns\
429 | | ... | if-index of the specified interface.
430 | | ...
431 | | ... | *Arguments:*
432 | | ... | - node - information about a DUT node. Type: dictionary
433 | | ... | - interface - name of the interface. Type: string
434 | | ...
435 | | ... | *Example:*
436 | | ...
437 | | ... | \| Get Interface index from oper data \| ${nodes['DUT1']} \| local0 \|
438 | | [Arguments] | ${node} | ${interface}
439 | | ${data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
440 | | Return from keyword | ${data['if-index']}
441
442 | Honeycomb should show disabled interface in oper data
443 | | [Documentation] | Retrieves list of disabled interfaces\
444 | | ... | and verifies that there is at least one.
445 | | ...
446 | | ... | *Arguments:*
447 | | ... | - node - information about a DUT node. Type: dictionary
448 | | ... | - index - index of the interface to be checked. Type: string
449 | | ...
450 | | ... | *Example:*
451 | | ...
452 | | ... | \| Honeycomb should show disabled interface in oper data \
453 | | ... | \|${nodes['DUT1']} \| ${vx_interface} \|
454 | | [Arguments] | ${node} | ${index}
455 | | interfaceAPI.check disabled interface | ${node} | ${index}
456
457 | Honeycomb should not show disabled interface in oper data
458 | | [Documentation] | Retrieves list of disabled interfaces\
459 | | ... | and expects to fail with a 404 - not found.
460 | | ...
461 | | ... | *Arguments:*
462 | | ... | - node - information about a DUT node. Type: dictionary
463 | | ... | - index - index of the interface to be checked. Type: string
464 | | ...
465 | | ... | *Example:*
466 | | ...
467 | | ... | \| Honeycomb should not show disabled interface in oper data \
468 | | ... | \|${nodes['DUT1']} \| ${vx_interface} \|
469 | | [Arguments] | ${node} | ${index}
470 | | Run keyword and expect error | *
471 | | ... | Honeycomb should show disabled interface in oper data
472 | | ... | ${node} | ${index}