Update Honeycomb interface IPv4 test
[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 | Honeycomb sets interface ipv4 address with prefix
124 | | [Documentation] | Uses Honeycomb API to assign an ipv4 address to the\
125 | | ... | specified interface. Any existing addresses will be removed.
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 set. Type: string
131 | | ... | - prefix - length of address network prefix. Type: int
132 | | ...
133 | | ... | *Example:*
134 | | ...
135 | | ... | \| Honeycomb sets interface ipv4 address with prefix \
136 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 24 \|
137 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
138 | | interfaceAPI.Add first ipv4 address
139 | | ... | ${node} | ${interface} | ${address} | ${prefix}
140
141 | IPv4 config from Honeycomb should be
142 | | [Documentation] | Retrieves interface ipv4 configuration through Honeycomb\
143 | | ... | and compares with state supplied in argument.
144 | | ...
145 | | ... | *Arguments:*
146 | | ... | - node - information about a DUT node. Type: dictionary
147 | | ... | - interface - name of an interface on the specified node. Type: string
148 | | ... | - address - IP address to expect. Type: string
149 | | ... | - netmask - subnet mask to expect. Type: string
150 | | ... | - fib_address - IP address to expect in fib table. Type: string
151 | | ... | - fib_mac - MAC address to expect in fib table. Type: string
152 | | ... | - settings - ipv4 interface settings to expect. Type: dictionary
153 | | ...
154 | | ... | *Example:*
155 | | ...
156 | | ... | \| IPv4 config from Honeycomb should be \| ${nodes['DUT1']} \
157 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
158 | | ... | \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
159 | | ... | \| ${{'enabled': True, 'mtu': 1500}} \|
160 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
161 | | ... | ${fib_address} | ${fib_mac} | ${settings}
162 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
163 | | Should be equal | ${address}
164 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['ip']}
165 | | Should be equal | ${netmask}
166 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['netmask']}
167 | | Should be equal | ${fib_address}
168 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['ip']
169 | | Should be equal | ${fib_mac}
170 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['link-layer-address']
171 | | :FOR | ${key} | IN | @{settings.keys()}
172 | | | Should be equal
173 | | | ... | ${settings['{key']} | ${api_data['ietf-ip:ipv4']['{$key}']}
174
175 | IPv4 config from VAT should be
176 | | [Documentation] | Retrieves interface ipv4 configuration through VAT and\
177 | | ... | compares with state supplied in argument.
178 | | ...
179 | | ... | *Arguments:*
180 | | ... | - node - information about a DUT node. Type: dictionary
181 | | ... | - interface - name of an interface on the specified node. Type: string
182 | | ... | - address - IP address to expect. Type: string
183 | | ... | - netmask - subnet mask to expect. Type: string
184 | | ...
185 | | ... | *Example:*
186 | | ...
187 | | ... | \| IPv4 config from VAT should be \| ${nodes['DUT1']} \
188 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
189 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
190 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
191 | | ... | ${node} | ${interface} | ipv4
192 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
193 | | Should be equal | ${vpp_data[0]['netmask']} | ${netmask}
194
195 | Honeycomb sets interface ipv6 configuration
196 | | [Documentation] | Uses Honeycomb API to change ipv6 configuration\
197 | | ... | of the specified interface.
198 | | ...
199 | | ... | *Arguments:*
200 | | ... | - node - information about a DUT node. Type: dictionary
201 | | ... | - interface - name of an interface on the specified node. Type: string
202 | | ... | - address - IP address to set. Type: string
203 | | ... | - prefix - length of subnet prefix to set. Type: string
204 | | ... | - fib_address - IP address to add to fib table. Type: string
205 | | ... | - fib_mac - MAC address to add to fib table. Type: string
206 | | ... | - settings - ipv6 interface settings. Type: dictionary
207 | | ...
208 | | ... | *Example:*
209 | | ...
210 | | ... | \| Honeycomb sets interface ipv6 configuration \| ${nodes['DUT1']} \
211 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \
212 | | ... | \| 10::11 \| 08:00:27:c0:5d:37 \| ${{'enabled': True, 'mtu': 1500}} \|
213 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
214 | | ... | ${fib_address} | ${fib_mac} | ${settings}
215 | | interfaceAPI.Add first ipv6 address
216 | | ... | ${node} | ${interface} | ${address} | ${prefix}
217 | | interfaceAPI.Add first ipv6 neighbor
218 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
219 | | :FOR | ${key} | IN | @{settings.keys()}
220 | | | interfaceAPI.Configure interface ipv6
221 | | | ... | ${node} | ${interface} | ${key} | ${settings['${key}']}
222
223 | IPv6 config from Honeycomb should be
224 | | [Documentation] | Retrieves interface ipv6 configuration through Honeycomb\
225 | | ... | and compares with state supplied in argument.
226 | | ...
227 | | ... | *Arguments:*
228 | | ... | - node - information about a DUT node. Type: dictionary
229 | | ... | - interface - name of an interface on the specified node. Type: string
230 | | ... | - address - IP address to expect. Type: string
231 | | ... | - prefix - length of subnet prefix to expect. Type: string
232 | | ... | - fib_address - IP address to expect in fib table. Type: string
233 | | ... | - fib_mac - MAC address to expect in fib table. Type: string
234 | | ... | - settings - ipv6 interface settings to expect. Type: dictionary
235 | | ...
236 | | ... | *Example:*
237 | | ...
238 | | ... | \| IPv6 config from Honeycomb should be \| ${nodes['DUT1']} \
239 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \
240 | | ... | \| 10::11 \| 08:00:27:c0:5d:37 \| ${{'enabled': True, 'mtu': 1500}} \|
241 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
242 | | ... | ${fib_address} | ${fib_mac} | ${settings}
243 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
244 | | Should be equal | ${address}
245 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['ip']}
246 | | Should be equal | ${prefix}
247 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['prefix-length']}
248 | | Should be equal | ${fib_address}
249 | | ... | ${api_data['ietf-ip:ipv6']['neighbor'][0]['ip']
250 | | Should be equal | ${fib_mac}
251 | | ... | ${api_data['ietf-ip:ipv6']['neighbor'][0]['link-layer-address']
252 | | :FOR | ${key} | IN | @{settings.keys()}
253 | | | Should be equal
254 | | ... | ${settings['{key']} | ${api_data['ietf-ip:ipv6']['{$key}']}
255
256 | IPv6 config from VAT should be
257 | | [Documentation] | Retrieves interface ipv6 configuration through VAT and\
258 | | ... | compares with state supplied in argument.
259 | | ...
260 | | ... | *Arguments:*
261 | | ... | - node - information about a DUT node. Type: dictionary
262 | | ... | - interface - name of an interface on the specified node. Type: string
263 | | ... | - address - IP address to expect. Type: string
264 | | ... | - prefix - length of subnet prefix to expect. Type: string
265 | | ...
266 | | ... | *Example:*
267 | | ...
268 | | ... | \| IPv6 config from VAT should be \| ${nodes['DUT1']} \
269 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
270 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
271 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
272 | | ... | ${node} | ${interface} | ipv6
273 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
274 | | Should be equal | ${vpp_data[0]['prefix-length']} | ${prefix}
275
276 | Honeycomb sets interface ethernet and routing configuration
277 | | [Documentation] | Uses Honeycomb API to change interface configuration.
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 | | ... | - ethernet - interface ethernet settings. Type: dictionary
283 | | ... | - routing - interface routing settings. Type: dictionary
284 | | ...
285 | | ... | *Example:*
286 | | ...
287 | | ... | \| Honeycomb sets interface ethernet and routing configuration \
288 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${{'mtu': 1500}} \
289 | | ... | \| ${{'vrf-if': 2}} \|
290 | | [Arguments] | ${node} | ${interface} | ${ethernet} | ${routing}
291 | | :FOR | ${key} | IN | @{ethernet.keys()}
292 | | | interfaceAPI.Configure interface ethernet
293 | | | ... | ${node} | ${interface} | ${key} | ${ethernet['${key}']}
294 | | :FOR | ${key} | IN | @{routing.keys()}
295 | | | interfaceAPI.Configure interface routing
296 | | | ... | ${node} | ${interface} | ${key} | ${routing['${key}']}
297
298 | Interface ethernet and routing configuration from Honeycomb should be
299 | | [Documentation] | Retrieves interface routing and ethernet configuration\
300 | | ... | through Honeycomb and compares with settings supplied in arguments.
301 | | ...
302 | | ... | *Arguments:*
303 | | ... | - node - information about a DUT node. Type: dictionary
304 | | ... | - interface - name of an interface on the specified node. Type: string
305 | | ... | - ethernet - interface ethernet settings. Type: dictionary
306 | | ... | - routing - interface routing settings. Type: dictionary
307 | | ...
308 | | ... | *Example:*
309 | | ...
310 | | ... | \| Interface ethernet and routing configuration from Honeycomb \
311 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
312 | | ... | \| ${{'mtu': 1500}} \| ${{'vrf-id': 2}} \|
313 | | [Arguments] | ${node} | ${interface} | ${ethernet} | ${routing}
314 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
315 | | :FOR | ${key} | IN | @{ethernet.keys()}
316 | | | Should be equal | ${api_data['${key}']} | ${ethernet['${key}']}
317 | | :FOR | ${key} | IN | @{routing.keys()}
318 | | | Should be equal | ${api_data['${key}']} | ${routing['${key}']}
319
320 | Interface ethernet and routing configuration from VAT should be
321 | | [Documentation] | Retrieves interface routing and ethernet configuration\
322 | | ... | through VAT and compares with settings supplied in arguments.
323 | | ...
324 | | ... | *Arguments:*
325 | | ... | - node - information about a DUT node. Type: dictionary
326 | | ... | - interface - name of an interface on the specified node. Type: string
327 | | ... | - mtu - value of maximum transmission unit expected. Type: integer
328 | | ... | - vrf-id - ID number of a VPN expected on interface. Type: integer
329 | | ...
330 | | ... | *Example:*
331 | | ...
332 | | ... | \| Interface ethernet and routing configuration from VAT \
333 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1500} \
334 | | ... | \| ${2} \|
335 | | [Arguments] | ${node} | ${interface} | ${mtu} | ${vrf-id}
336 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
337 | | Should be equal | ${vat_data['mtu']} | ${mtu}
338 | | Should be equal | ${vat_data['sub_inner_vlan_id']} | ${vrf-id}
339
340 | Honeycomb sets interface VxLAN configuration
341 | | [Documentation] | Uses Honeycomb API to change VxLAN configuration \
342 | | ... | of the specified interface.
343 | | ...
344 | | ... | *Arguments:*
345 | | ... | - node - information about a DUT node. Type: dictionary
346 | | ... | - interface - name of an interface on the specified node. Type: string
347 | | ... | - vxlan_settings - Configuration data for VxLAN. Type: dictionary
348 | | ...
349 | | ... | *Example:*
350 | | ... | \| Honeycomb sets interface VxLAN configuration \
351 | | ... | \|${node} \| ${interface} \| &{vxlan_settings} \|
352 | | ...
353 | | [Arguments] | ${node} | ${interface} | &{vxlan_settings}
354 | | :FOR | ${items} | IN | @{vxlan_settings.items()}
355 | | | interfaceAPI.Configure interface vxlan | ${node} | ${interface} | @{items}
356
357 | VxLAN configuration from Honeycomb should be
358 | | [Documentation] | Retrieves interface VxLAN configuration through Honeycomb\
359 | | ... | and compares with state supplied in argument.
360 | | ...
361 | | ... | *Arguments:*
362 | | ... | - node - information about a DUT node. Type: dictionary
363 | | ... | - interface - name of an interface on the specified node. Type: string
364 | | ... | - vxlan_settings - Configuration data for VxLAN. Type: dictionary
365 | | ...
366 | | ... | *Example:*
367 | | ...
368 | | ... | \| VxLAN configuration from Honeycomb should be \
369 | | ... | \| ${node} \| ${interface} \| &{vxlan_settings} \|
370 | | ...
371 | | [Arguments] | ${node} | ${interface} | &{vxlan_settings}
372 | | ${api_data}= | interfaceAPI.Get interface cfg data | ${node} | ${interface}
373 | | :FOR | ${items} | IN | @{vxlan_settings.items()}
374 | | | Should be equal as strings
375 | | ... | ${api_data['v3po:vxlan']['@{items}[0]']} | ${items[1]}
376 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
377 | | :FOR | ${items} | IN | @{vxlan_settings.items()}
378 | | | Should be equal as strings
379 | | ... | ${api_data['v3po:vxlan']['@{items}[0]']} | ${items[1]}
380
381 | VxLAN configuration from VAT should be
382 | | [Documentation] | Retrieves interface VxLAN configuration through VAT and\
383 | | ... | compares with state supplied in argument.
384 | | ...
385 | | ... | *Arguments:*
386 | | ... | - node - information about a DUT node. Type: dictionary
387 | | ... | - interface - name of an interface on the specified node. Type: string
388 | | ... | - vxlan_settings - Configuration data for VxLAN. Type: dictionary
389 | | ...
390 | | ... | *Example:*
391 | | ...
392 | | ... | \| VxLAN configuration from Honeycomb should be \
393 | | ... | \| ${node} \| ${interface} \| &{vxlan_settings} \|
394 | | ...
395 | | [Arguments] | ${node} | ${interface} | &{vxlan_settings}
396 | | ${vat_data}= | VxLAN Dump | ${node} | ${interface}
397 | | Should be equal as strings
398 | | ... | ${vat_data['dst_address']} | ${vxlan_settings['dst']}
399 | | Should be equal as strings
400 | | ... | ${vat_data['src_address']} | ${vxlan_settings['src']}
401 | | Should be equal as strings | ${vat_data['vni']} | ${vxlan_settings['vni']}
402 | | Should be equal as strings
403 | | ... | ${vat_data['encap-vrf-id']} | ${vxlan_settings['encap_vrf_id']}