Move Honeycomb libraries to honeycomb subdirectory.
[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/honeycomb/HoneycombUtil.py
16 | Library | resources.libraries.python.InterfaceUtil
17 | ...     | WITH NAME | interfaceCLI
18 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
19 | ...     | WITH NAME | InterfaceAPI
20
21 *** Keywords ***
22 | Interface state is
23 | | [Documentation] | Uses VPP binary API to ensure that the interface under\
24 | | ... | test is in the specified admin state.
25 | | ...
26 | | ... | *Arguments:*
27 | | ... | - node - information about a DUT node. Type: dictionary
28 | | ... | - interface - name of an interface on the specified node. Type: string
29 | | ... | - state - state to set on interface. Type:string
30 | | ...
31 | | ... | *Example:*
32 | | ...
33 | | ... | \| Interface state is \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
34 | | ... | \| up \|
35 | | [Arguments] | ${node} | ${interface} | ${state}
36 | | interfaceCLI.Set interface state | ${node} | ${interface} | ${state}
37
38 | Honeycomb sets interface state
39 | | [Documentation] | Uses Honeycomb API to change the admin state\
40 | | ... | of the specified interface.
41 | | ...
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - interface - name of an interface on the specified node. Type: string
45 | | ... | - state - state to set on interface. Type:string
46 | | ...
47 | | ... | *Example:*
48 | | ...
49 | | ... | \| Honeycomb sets interface state \| ${nodes['DUT1']} \
50 | | ... | \| GigabitEthernet0/8/0 \| up \|
51 | | [Arguments] | ${node} | ${interface} | ${state}
52 | | interfaceAPI.Set interface state | ${node} | ${interface} | ${state}
53
54 | Interface state from Honeycomb should be
55 | | [Documentation] | Retrieves interface admin state through Honeycomb and\
56 | | ... | compares with state supplied in argument.
57 | | ...
58 | | ... | *Arguments:*
59 | | ... | - node - information about a DUT node. Type: dictionary
60 | | ... | - interface - name of an interface on the specified node. Type: string
61 | | ... | - state - expected interface state. Type: string
62 | | ...
63 | | ... | *Example:*
64 | | ...
65 | | ... | \| Interface state from Honeycomb should be \| ${nodes['DUT1']} \
66 | | ... | \| GigabitEthernet0/8/0 \| up \|
67 | | [Arguments] | ${node} | ${interface} | ${state}
68 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
69 | | ${api_state}= | Set Variable | ${api_data['admin-status']}
70 | | Should be equal | ${api_state} | ${state}
71
72 | Interface state from VAT should be
73 | | [Documentation] | Retrieves interface admin state through VAT and compares\
74 | | ... | with state supplied in argument.
75 | | ...
76 | | ... | *Arguments:*
77 | | ... | - node - information about a DUT node. Type: dictionary
78 | | ... | - interface - name of an interface on the specified node. Type: string
79 | | ... | - state - expected interface state. Type: string
80 | | ...
81 | | ... | _NOTE:_ Vat returns state as int (1/0) instead of string (up/down).
82 | | ... | This keyword also handles translation.
83 | | ...
84 | | ... | *Example:*
85 | | ...
86 | | ... | \| Interface state from VAT should be \| ${nodes['DUT1']} \
87 | | ... | \| GigabitEthernet0/8/0 \| up \|
88 | | [Arguments] | ${node} | ${interface} | ${state}
89 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
90 | | ${vat_state}= | Set Variable if
91 | | ... | ${vat_data['admin_up_down']} == 1 | up | down
92 | | Should be equal | ${vat_state} | ${state}
93
94 | Honeycomb sets interface ipv4 configuration
95 | | [Documentation] | Uses Honeycomb API to change ipv4 configuration\
96 | | ... | of the specified interface.
97 | | ...
98 | | ... | *Arguments:*
99 | | ... | - node - information about a DUT node. Type: dictionary
100 | | ... | - interface - name of an interface on the specified node. Type: string
101 | | ... | - address - IP address to set. Type: string
102 | | ... | - netmask - subnet mask to set. Type: string
103 | | ... | - fib_address - IP address to add to fib table. Type: string
104 | | ... | - fib_mac - MAC address to add to fib table. Type: string
105 | | ... | - settings - ipv4 interface settings. Type: dictionary
106 | | ...
107 | | ... | *Example:*
108 | | ...
109 | | ... | \| Honeycomb sets interface ipv4 configuration \| ${nodes['DUT1']} \
110 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
111 | | ... | \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
112 | | ... | \| ${{'enabled': True, 'mtu': 1500}} \|
113 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
114 | | ... | ${fib_address} | ${fib_mac} | ${settings}
115 | | interfaceAPI.Add first ipv4 address
116 | | ... | ${node} | ${interface} | ${address} | ${netmask}
117 | | interfaceAPI.Add first ipv4 neighbor
118 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
119 | | :FOR | ${key} | IN | @{settings.keys()}
120 | | | interfaceAPI.Configure interface ipv4
121 | | | ... | ${node} | ${interface} | ${key} | ${settings['${key}']}
122
123 | IPv4 config from Honeycomb should be
124 | | [Documentation] | Retrieves interface ipv4 configuration through Honeycomb\
125 | | ... | and compares with state supplied in argument.
126 | | ...
127 | | ... | *Arguments:*
128 | | ... | - node - information about a DUT node. Type: dictionary
129 | | ... | - interface - name of an interface on the specified node. Type: string
130 | | ... | - address - IP address to expect. Type: string
131 | | ... | - netmask - subnet mask to expect. Type: string
132 | | ... | - fib_address - IP address to expect in fib table. Type: string
133 | | ... | - fib_mac - MAC address to expect in fib table. Type: string
134 | | ... | - settings - ipv4 interface settings to expect. Type: dictionary
135 | | ...
136 | | ... | *Example:*
137 | | ...
138 | | ... | \| IPv4 config from Honeycomb should be \| ${nodes['DUT1']} \
139 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
140 | | ... | \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
141 | | ... | \| ${{'enabled': True, 'mtu': 1500}} \|
142 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
143 | | ... | ${fib_address} | ${fib_mac} | ${settings}
144 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
145 | | Should be equal | ${address}
146 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['ip']}
147 | | Should be equal | ${netmask}
148 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['netmask']}
149 | | Should be equal | ${fib_address}
150 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['ip']
151 | | Should be equal | ${fib_mac}
152 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['link-layer-address']
153 | | :FOR | ${key} | IN | @{settings.keys()}
154 | | | Should be equal
155 | | | ... | ${settings['{key']} | ${api_data['ietf-ip:ipv4']['{$key}']}
156
157 | IPv4 config from VAT should be
158 | | [Documentation] | Retrieves interface ipv4 configuration through VAT and\
159 | | ... | compares with state supplied in argument.
160 | | ...
161 | | ... | *Arguments:*
162 | | ... | - node - information about a DUT node. Type: dictionary
163 | | ... | - interface - name of an interface on the specified node. Type: string
164 | | ... | - address - IP address to expect. Type: string
165 | | ... | - netmask - subnet mask to expect. Type: string
166 | | ...
167 | | ... | *Example:*
168 | | ...
169 | | ... | \| IPv4 config from VAT should be \| ${nodes['DUT1']} \
170 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
171 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
172 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
173 | | ... | ${node} | ${interface} | ipv4
174 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
175 | | Should be equal | ${vpp_data[0]['netmask']} | ${netmask}
176
177 | Honeycomb sets interface ipv6 configuration
178 | | [Documentation] | Uses Honeycomb API to change ipv6 configuration\
179 | | ... | of the specified interface.
180 | | ...
181 | | ... | *Arguments:*
182 | | ... | - node - information about a DUT node. Type: dictionary
183 | | ... | - interface - name of an interface on the specified node. Type: string
184 | | ... | - address - IP address to set. Type: string
185 | | ... | - prefix - length of subnet prefix to set. Type: string
186 | | ... | - fib_address - IP address to add to fib table. Type: string
187 | | ... | - fib_mac - MAC address to add to fib table. Type: string
188 | | ... | - settings - ipv6 interface settings. Type: dictionary
189 | | ...
190 | | ... | *Example:*
191 | | ...
192 | | ... | \| Honeycomb sets interface ipv6 configuration \| ${nodes['DUT1']} \
193 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \
194 | | ... | \| 10::11 \| 08:00:27:c0:5d:37 \| ${{'enabled': True, 'mtu': 1500}} \|
195 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
196 | | ... | ${fib_address} | ${fib_mac} | ${settings}
197 | | interfaceAPI.Add first ipv6 address
198 | | ... | ${node} | ${interface} | ${address} | ${prefix}
199 | | interfaceAPI.Add first ipv6 neighbor
200 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
201 | | :FOR | ${key} | IN | @{settings.keys()}
202 | | | interfaceAPI.Configure interface ipv6
203 | | | ... | ${node} | ${interface} | ${key} | ${settings['${key}']}
204
205 | IPv6 config from Honeycomb should be
206 | | [Documentation] | Retrieves interface ipv6 configuration through Honeycomb\
207 | | ... | and compares with state supplied in argument.
208 | | ...
209 | | ... | *Arguments:*
210 | | ... | - node - information about a DUT node. Type: dictionary
211 | | ... | - interface - name of an interface on the specified node. Type: string
212 | | ... | - address - IP address to expect. Type: string
213 | | ... | - prefix - length of subnet prefix to expect. Type: string
214 | | ... | - fib_address - IP address to expect in fib table. Type: string
215 | | ... | - fib_mac - MAC address to expect in fib table. Type: string
216 | | ... | - settings - ipv6 interface settings to expect. Type: dictionary
217 | | ...
218 | | ... | *Example:*
219 | | ...
220 | | ... | \| IPv6 config from Honeycomb should be \| ${nodes['DUT1']} \
221 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \
222 | | ... | \| 10::11 \| 08:00:27:c0:5d:37 \| ${{'enabled': True, 'mtu': 1500}} \|
223 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
224 | | ... | ${fib_address} | ${fib_mac} | ${settings}
225 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
226 | | Should be equal | ${address}
227 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['ip']}
228 | | Should be equal | ${prefix}
229 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['prefix-length']}
230 | | Should be equal | ${fib_address}
231 | | ... | ${api_data['ietf-ip:ipv6']['neighbor'][0]['ip']
232 | | Should be equal | ${fib_mac}
233 | | ... | ${api_data['ietf-ip:ipv6']['neighbor'][0]['link-layer-address']
234 | | :FOR | ${key} | IN | @{settings.keys()}
235 | | | Should be equal
236 | | ... | ${settings['{key']} | ${api_data['ietf-ip:ipv6']['{$key}']}
237
238 | IPv6 config from VAT should be
239 | | [Documentation] | Retrieves interface ipv6 configuration through VAT and\
240 | | ... | compares with state supplied in argument.
241 | | ...
242 | | ... | *Arguments:*
243 | | ... | - node - information about a DUT node. Type: dictionary
244 | | ... | - interface - name of an interface on the specified node. Type: string
245 | | ... | - address - IP address to expect. Type: string
246 | | ... | - prefix - length of subnet prefix to expect. Type: string
247 | | ...
248 | | ... | *Example:*
249 | | ...
250 | | ... | \| IPv6 config from VAT should be \| ${nodes['DUT1']} \
251 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
252 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
253 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
254 | | ... | ${node} | ${interface} | ipv6
255 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
256 | | Should be equal | ${vpp_data[0]['prefix-length']} | ${prefix}
257
258 | Honeycomb sets interface ethernet and routing configuration
259 | | [Documentation] | Uses Honeycomb API to change interface configuration.
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 | | ... | - ethernet - interface ethernet settings. Type: dictionary
265 | | ... | - routing - interface routing settings. Type: dictionary
266 | | ...
267 | | ... | *Example:*
268 | | ...
269 | | ... | \| Honeycomb sets interface ethernet and routing configuration \
270 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${{'mtu': 1500}} \
271 | | ... | \| ${{'vrf-if': 2}} \|
272 | | [Arguments] | ${node} | ${interface} | ${ethernet} | ${routing}
273 | | :FOR | ${key} | IN | @{ethernet.keys()}
274 | | | interfaceAPI.Configure interface ethernet
275 | | | ... | ${node} | ${interface} | ${key} | ${ethernet['${key}']}
276 | | :FOR | ${key} | IN | @{routing.keys()}
277 | | | interfaceAPI.Configure interface routing
278 | | | ... | ${node} | ${interface} | ${key} | ${routing['${key}']}
279
280 | Interface ethernet and routing configuration from Honeycomb should be
281 | | [Documentation] | Retrieves interface routing and ethernet configuration\
282 | | ... | through Honeycomb and compares with settings supplied in arguments.
283 | | ...
284 | | ... | *Arguments:*
285 | | ... | - node - information about a DUT node. Type: dictionary
286 | | ... | - interface - name of an interface on the specified node. Type: string
287 | | ... | - ethernet - interface ethernet settings. Type: dictionary
288 | | ... | - routing - interface routing settings. Type: dictionary
289 | | ...
290 | | ... | *Example:*
291 | | ...
292 | | ... | \| Interface ethernet and routing configuration from Honeycomb \
293 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
294 | | ... | \| ${{'mtu': 1500}} \| ${{'vrf-id': 2}} \|
295 | | [Arguments] | ${node} | ${interface} | ${ethernet} | ${routing}
296 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
297 | | :FOR | ${key} | IN | @{ethernet.keys()}
298 | | | Should be equal | ${api_data['${key}']} | ${ethernet['${key}']}
299 | | :FOR | ${key} | IN | @{routing.keys()}
300 | | | Should be equal | ${api_data['${key}']} | ${routing['${key}']}
301
302 | Interface ethernet and routing configuration from VAT should be
303 | | [Documentation] | Retrieves interface routing and ethernet configuration\
304 | | ... | through VAT and compares with settings supplied in arguments.
305 | | ...
306 | | ... | *Arguments:*
307 | | ... | - node - information about a DUT node. Type: dictionary
308 | | ... | - interface - name of an interface on the specified node. Type: string
309 | | ... | - mtu - value of maximum transmission unit expected. Type: integer
310 | | ... | - vrf-id - ID number of a VPN expected on interface. Type: integer
311 | | ...
312 | | ... | *Example:*
313 | | ...
314 | | ... | \| Interface ethernet and routing configuration from VAT \
315 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1500} \
316 | | ... | \| ${2} \|
317 | | [Arguments] | ${node} | ${interface} | ${mtu} | ${vrf-id}
318 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
319 | | Should be equal | ${vat_data['mtu']} | ${mtu}
320 | | Should be equal | ${vat_data['sub_inner_vlan_id']} | ${vrf-id}
321
322 | Honeycomb sets interface VxLAN configuration
323 | | [Documentation] | Uses Honeycomb API to change VxLAN configuration \
324 | | ... | of the specified interface.
325 | | ...
326 | | ... | *Arguments:*
327 | | ... | - node - information about a DUT node. Type: dictionary
328 | | ... | - interface - name of an interface on the specified node. Type: string
329 | | ... | - vxlan_settings - Configuration data for VxLAN. Type: dictionary
330 | | ...
331 | | ... | *Example:*
332 | | ... | \| Honeycomb sets interface VxLAN configuration \
333 | | ... | \|${node} \| ${interface} \| &{vxlan_settings} \|
334 | | ...
335 | | [Arguments] | ${node} | ${interface} | &{vxlan_settings}
336 | | :FOR | ${items} | IN | @{vxlan_settings.items()}
337 | | | interfaceAPI.Configure interface vxlan | ${node} | ${interface} | @{items}
338
339 | VxLAN configuration from Honeycomb should be
340 | | [Documentation] | Retrieves interface VxLAN configuration through Honeycomb\
341 | | ... | and compares with state supplied in argument.
342 | | ...
343 | | ... | *Arguments:*
344 | | ... | - node - information about a DUT node. Type: dictionary
345 | | ... | - interface - name of an interface on the specified node. Type: string
346 | | ... | - vxlan_settings - Configuration data for VxLAN. Type: dictionary
347 | | ...
348 | | ... | *Example:*
349 | | ...
350 | | ... | \| VxLAN configuration from Honeycomb should be \
351 | | ... | \| ${node} \| ${interface} \| &{vxlan_settings} \|
352 | | ...
353 | | [Arguments] | ${node} | ${interface} | &{vxlan_settings}
354 | | ${api_data}= | interfaceAPI.Get interface cfg data | ${node} | ${interface}
355 | | :FOR | ${items} | IN | @{vxlan_settings.items()}
356 | | | Should be equal as strings
357 | | ... | ${api_data['v3po:vxlan']['@{items}[0]']} | ${items[1]}
358 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
359 | | :FOR | ${items} | IN | @{vxlan_settings.items()}
360 | | | Should be equal as strings
361 | | ... | ${api_data['v3po:vxlan']['@{items}[0]']} | ${items[1]}
362
363 | VxLAN configuration from VAT should be
364 | | [Documentation] | Retrieves interface VxLAN configuration through VAT and\
365 | | ... | compares with state supplied in argument.
366 | | ...
367 | | ... | *Arguments:*
368 | | ... | - node - information about a DUT node. Type: dictionary
369 | | ... | - interface - name of an interface on the specified node. Type: string
370 | | ... | - vxlan_settings - Configuration data for VxLAN. Type: dictionary
371 | | ...
372 | | ... | *Example:*
373 | | ...
374 | | ... | \| VxLAN configuration from Honeycomb should be \
375 | | ... | \| ${node} \| ${interface} \| &{vxlan_settings} \|
376 | | ...
377 | | [Arguments] | ${node} | ${interface} | &{vxlan_settings}
378 | | ${vat_data}= | VxLAN Dump | ${node} | ${interface}
379 | | Should be equal as strings
380 | | ... | ${vat_data['dst_address']} | ${vxlan_settings['dst']}
381 | | Should be equal as strings
382 | | ... | ${vat_data['src_address']} | ${vxlan_settings['src']}
383 | | Should be equal as strings | ${vat_data['vni']} | ${vxlan_settings['vni']}
384 | | Should be equal as strings
385 | | ... | ${vat_data['encap-vrf-id']} | ${vxlan_settings['encap_vrf_id']}