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