blob: b17d03eb0234f2afb481b8d06cb2a075a7bc42d3 [file] [log] [blame]
Prashanth Kattif58cce02019-02-06 03:05:14 -06001*** Settings ***
2Documentation Network interface configuration and verification
3 ... tests.
4
George Keishing5d467552019-02-08 23:30:48 -06005Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/bmc_network_utils.robot
7Resource ../../lib/openbmc_ffdc.robot
Prashanth Katti747ce9d2019-02-07 07:23:48 -06008Library ../../lib/bmc_network_utils.py
Vijayde3bf7b2019-04-16 04:56:09 -05009Library Collections
Prashanth Kattif58cce02019-02-06 03:05:14 -060010
11Test Setup Test Setup Execution
12Test Teardown Test Teardown Execution
13
Prashanth Katti23efc6e2019-03-13 06:07:15 -050014*** Variables ***
Vijayde3bf7b2019-04-16 04:56:09 -050015${test_hostname} openbmc
16${test_ipv4_addr} 10.7.7.7
17${test_ipv4_invalid_addr} 0.0.1.a
18${test_subnet_mask} 255.255.0.0
19${test_gateway} 10.7.7.1
Prashanth Kattib36a7522019-05-22 05:32:39 -050020${broadcast_ip} 10.7.7.255
21${loopback_ip} 127.0.0.2
22${multicast_ip} 224.6.6.6
23${out_of_range_ip} 10.7.7.256
Prashanth Katti23efc6e2019-03-13 06:07:15 -050024
Prashanth Katti040c8c12019-05-31 04:42:05 -050025# Valid netmask is 4 bytes long and has continuos block of 1s.
26# Maximum valid value in each octet is 255 and least value is 0.
27# 253 is not valid, as binary value is 11111101.
28${invalid_netmask} 255.255.253.0
29${alpha_netmask} ff.ff.ff.ff
30# Maximum value of octet in netmask is 255.
31${out_of_range_netmask} 255.256.255.0
32${more_byte_netmask} 255.255.255.0.0
33${less_byte_netmask} 255.255.255
34
Prashanth Kattif58cce02019-02-06 03:05:14 -060035*** Test Cases ***
36
37Get IP Address And Verify
38 [Documentation] Get IP Address And Verify.
George Keishing5d467552019-02-08 23:30:48 -060039 [Tags] Get_IP_Address_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060040
41 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060042 \ Verify IP On BMC ${network_configuration['Address']}
43
Prashanth Kattif58cce02019-02-06 03:05:14 -060044Get Netmask And Verify
45 [Documentation] Get Netmask And Verify.
George Keishing5d467552019-02-08 23:30:48 -060046 [Tags] Get_Netmask_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060047
48 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060049 \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
50
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060051Get Gateway And Verify
52 [Documentation] Get gateway and verify it's existence on the BMC.
53 [Tags] Get_Gateway_And_Verify
54
55 : FOR ${network_configuration} IN @{network_configurations}
56 \ Verify Gateway On BMC ${network_configuration['Gateway']}
57
58Get MAC Address And Verify
59 [Documentation] Get MAC address and verify it's existence on the BMC.
60 [Tags] Get_MAC_Address_And_Verify
61
George Keishing97c93942019-03-04 12:45:07 -060062 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060063 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress
64 Validate MAC On BMC ${macaddr}
Prashanth Kattif58cce02019-02-06 03:05:14 -060065
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -060066Verify All Configured IP And Netmask
67 [Documentation] Verify all configured IP and netmask on BMC.
68 [Tags] Verify_All_Configured_IP_And_Netmask
69
70 : FOR ${network_configuration} IN @{network_configurations}
71 \ Verify IP And Netmask On BMC ${network_configuration['Address']}
72 ... ${network_configuration['SubnetMask']}
73
Prashanth Katti23efc6e2019-03-13 06:07:15 -050074Get Hostname And Verify
75 [Documentation] Get hostname via Redfish and verify.
76 [Tags] Get_Hostname_And_Verify
77
78 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
79
80 Validate Hostname On BMC ${hostname}
81
82Configure Hostname And Verify
83 [Documentation] Configure hostname via Redfish and verify.
84 [Tags] Configure_Hostname_And_Verify
85
86 Configure Hostname ${test_hostname}
87
88 Validate Hostname On BMC ${test_hostname}
89
Vijayde3bf7b2019-04-16 04:56:09 -050090Add Valid IPv4 Address And Verify
91 [Documentation] Add IPv4 Address via Redfish and verify.
92 [Tags] Add_Valid_IPv4_Addres_And_Verify
93
94 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
95 Delete IP Address ${test_ipv4_addr}
96
97Add Invalid IPv4 Address And Verify
98 [Documentation] Add Invalid IPv4 Address via Redfish and verify.
99 [Tags] Add_Invalid_IPv4_Addres_And_Verify
100
101 Add IP Address ${test_ipv4_invalid_addr} ${test_subnet_mask}
102 ... ${test_gateway} valid_status_codes=${HTTP_BAD_REQUEST}
103
Prashanth Kattib36a7522019-05-22 05:32:39 -0500104Configure Out Of Range IP
105 [Documentation] Configure out-of-range IP address.
106 [Tags] Configure_Out_Of_Range_IP
107 [Template] Add IP Address
108
109 # ip subnet_mask gateway valid_status_codes
110 ${out_of_range_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
111
112Configure Broadcast IP
113 [Documentation] Configure broadcast IP address.
114 [Tags] Configure_Broadcast_IP
115 [Template] Add IP Address
116
117 # ip subnet_mask gateway valid_status_codes
118 ${broadcast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
119
120Configure Multicast IP
121 [Documentation] Configure multicast IP address.
122 [Tags] Configure_Multicast_IP
123 [Template] Add IP Address
124
125 # ip subnet_mask gateway valid_status_codes
126 ${multicast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
127
128Configure Loopback IP
129 [Documentation] Configure loopback IP address.
130 [Tags] Configure_Loopback_IP
131 [Template] Add IP Address
132
133 # ip subnet_mask gateway valid_status_codes
134 ${loopback_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
135
136Add Valid IPv4 Address And Check Persistency
137 [Documentation] Add IPv4 address and check peristency.
138 [Tags] Add_Valid_IPv4_Addres_And_Check_Persistency
139
140 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
141
142 # Reboot BMC and verify persistency.
143 OBMC Reboot (off)
144 Verify IP On BMC ${test_ipv4_addr}
145 Delete IP Address ${test_ipv4_addr}
Vijayde3bf7b2019-04-16 04:56:09 -0500146
Prashanth Katti6cedca22019-05-30 02:31:11 -0500147Add Fourth Octet Threshold IP And Verify
148 [Documentation] Add fourth octet threshold IP and verify.
149 [Tags] Add_Fourth_Octet_Threshold_IP_And_Verify
150
151 Add IP Address 10.7.7.254 ${test_subnet_mask} ${test_gateway}
152 Delete IP Address 10.7.7.254
153
154Add Fourth Octet Lowest IP And Verify
155 [Documentation] Add fourth octet lowest IP and verify.
156 [Tags] Add_Fourth_Octet_Lowest_IP_And_Verify
157
158 Add IP Address 10.7.7.1 ${test_subnet_mask} ${test_gateway}
159 Delete IP Address 10.7.7.1
160
161Add Third Octet Threshold IP And Verify
162 [Documentation] Add third octet threshold IP and verify.
163 [Tags] Add_Third_Octet_Threshold_IP_And_Verify
164
165 Add IP Address 10.7.255.7 ${test_subnet_mask} ${test_gateway}
166 Delete IP Address 10.7.255.7
167
168Add Third Octet Lowest IP And Verify
169 [Documentation] Add third octet lowest IP and verify.
170 [Tags] Add_Third_Octet_Lowest_IP_And_Verify
171
172 Add IP Address 10.7.0.7 ${test_subnet_mask} ${test_gateway}
173 Delete IP Address 10.7.0.7
174
175Add Second Octet Threshold IP And Verify
176 [Documentation] Add second octet threshold IP and verify.
177 [Tags] Add_Second_Octet_Threshold_IP_And_Verify
178
179 Add IP Address 10.255.7.7 ${test_subnet_mask} ${test_gateway}
180 Delete IP Address 10.255.7.7
181
182Add Second Octet Lowest IP And Verify
183 [Documentation] Add second octet lowest IP and verify.
184 [Tags] Add_Second_Octet_Lowest_IP_And_Verify
185
186 Add IP Address 10.0.7.7 ${test_subnet_mask} ${test_gateway}
187 Delete IP Address 10.0.7.7
188
189Add First Octet Threshold IP And Verify
190 [Documentation] Add first octet threshold IP and verify.
191 [Tags] Add_First_Octet_Threshold_IP_And_Verify
192
193 Add IP Address 223.7.7.7 ${test_subnet_mask} ${test_gateway}
194 Delete IP Address 223.7.7.7
195
196Add First Octet Lowest IP And Verify
197 [Documentation] Add first octet lowest IP and verify.
198 [Tags] Add_First_Octet_Lowest_IP_And_Verify
199
200 Add IP Address 1.7.7.7 ${test_subnet_mask} ${test_gateway}
201 Delete IP Address 1.7.7.7
202
Prashanth Katti040c8c12019-05-31 04:42:05 -0500203Configure Invalid Netmask
204 [Documentation] Verify error while setting invalid netmask.
205 [Tags] Configure_Invalid_Netmask
206 [Template] Add IP Address
207
208 # ip subnet_mask gateway valid_status_codes
209 ${test_ipv4_addr} ${invalid_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
210
211Configure Out Of Range Netmask
212 [Documentation] Verify error while setting out of range netmask.
213 [Tags] Configure_Out_Of_Range_Netmask
214 [Template] Add IP Address
215
216 # ip subnet_mask gateway valid_status_codes
217 ${test_ipv4_addr} ${out_of_range_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
218
219Configure Alpha Netmask
220 [Documentation] Verify error while setting alpha netmask.
221 [Tags] Configure_Alpha_Netmask
222 [Template] Add IP Address
223
224 # ip subnet_mask gateway valid_status_codes
225 ${test_ipv4_addr} ${alpha_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
226
227Configure More Byte Netmask
228 [Documentation] Verify error while setting more byte netmask.
229 [Tags] Configure_More_Byte_Netmask
230 [Template] Add IP Address
231
232 # ip subnet_mask gateway valid_status_codes
233 ${test_ipv4_addr} ${more_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
234
235Configure Less Byte Netmask
236 [Documentation] Verify error while setting less byte netmask.
237 [Tags] Configure_Less_Byte_Netmask
238 [Template] Add IP Address
239
240 # ip subnet_mask gateway valid_status_codes
241 ${test_ipv4_addr} ${less_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
242
Prashanth Kattif58cce02019-02-06 03:05:14 -0600243*** Keywords ***
244
245Test Setup Execution
246 [Documentation] Test setup execution.
247
George Keishing97c93942019-03-04 12:45:07 -0600248 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -0600249
250 @{network_configurations}= Get Network Configuration
251 Set Test Variable @{network_configurations}
252
253 # Get BMC IP address and prefix length.
254 ${ip_data}= Get BMC IP Info
255 Set Test Variable ${ip_data}
256
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600257
Prashanth Kattif58cce02019-02-06 03:05:14 -0600258Get Network Configuration
259 [Documentation] Get network configuration.
260
261 # Sample output:
262 #{
263 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
264 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
265 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
266 # "Description": "Management Network Interface",
267 # "IPv4Addresses": [
268 # {
269 # "Address": "169.254.xx.xx",
270 # "AddressOrigin": "IPv4LinkLocal",
271 # "Gateway": "0.0.0.0",
272 # "SubnetMask": "255.255.0.0"
273 # },
274 # {
275 # "Address": "xx.xx.xx.xx",
276 # "AddressOrigin": "Static",
277 # "Gateway": "xx.xx.xx.1",
278 # "SubnetMask": "xx.xx.xx.xx"
279 # }
280 # ],
281 # "Id": "eth0",
282 # "MACAddress": "xx:xx:xx:xx:xx:xx",
283 # "Name": "Manager Ethernet Interface",
284 # "SpeedMbps": 0,
285 # "VLAN": {
286 # "VLANEnable": false,
287 # "VLANId": 0
288 # }
289
George Keishing97c93942019-03-04 12:45:07 -0600290 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattif58cce02019-02-06 03:05:14 -0600291 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses
292 [Return] @{network_configurations}
293
George Keishing5d467552019-02-08 23:30:48 -0600294
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600295Verify IP On BMC
296 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600297 [Arguments] ${ip}
298
Vijayde3bf7b2019-04-16 04:56:09 -0500299 # Description of argument(s):
300 # ip IP address to be verified (e.g. "10.7.7.7").
Prashanth Kattif58cce02019-02-06 03:05:14 -0600301
302 # Get IP address details on BMC using IP command.
303 @{ip_data}= Get BMC IP Info
304 Should Contain Match ${ip_data} ${ip}/*
305 ... msg=IP address does not exist.
306
Vijayde3bf7b2019-04-16 04:56:09 -0500307Add IP Address
308 [Documentation] Add IP Address To BMC.
309 [Arguments] ${ip} ${subnet_mask} ${gateway}
310 ... ${valid_status_codes}=${HTTP_OK}
311
312 # Description of argument(s):
313 # ip IP address to be added (e.g. "10.7.7.7").
314 # subnet_mask Subnet mask for the IP to be added
315 # (e.g. "255.255.0.0").
316 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
317 # valid_status_codes Expected return code from patch operation
318 # (e.g. "200"). See prolog of rest_request
319 # method in redfish_plut.py for details.
320
321 ${empty_dict}= Create Dictionary
322 ${ip_data}= Create Dictionary Address=${ip}
323 ... AddressOrigin=Static SubnetMask=${subnet_mask}
324 ... Gateway=${gateway}
325
326 ${patch_list}= Create List
327 ${network_configurations}= Get Network Configuration
328 ${num_entries}= Get Length ${network_configurations}
329
330 : FOR ${INDEX} IN RANGE 0 ${num_entries}
331 \ Append To List ${patch_list} ${empty_dict}
332
George Keishing98ffa862019-05-23 10:07:45 -0500333 # We need not check for existence of IP on BMC while adding.
Vijayde3bf7b2019-04-16 04:56:09 -0500334 Append To List ${patch_list} ${ip_data}
335 ${data}= Create Dictionary IPv4Addresses=${patch_list}
336
337 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
338 ... valid_status_codes=[${valid_status_codes}]
339
340 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK}'
341
342 # Note: Network restart takes around 15-18s after patch request processing.
343 Sleep ${NETWORK_TIMEOUT}s
344 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
345
346 Verify IP On BMC ${ip}
347 Validate Network Config On BMC
348
349
350Delete IP Address
351 [Documentation] Delete IP Address Of BMC.
352 [Arguments] ${ip} ${valid_status_codes}=${HTTP_OK}
353
354 # Description of argument(s):
355 # ip IP address to be deleted (e.g. "10.7.7.7").
356 # valid_status_codes Expected return code from patch operation
357 # (e.g. "200"). See prolog of rest_request
358 # method in redfish_plut.py for details.
359
360 ${empty_dict}= Create Dictionary
361 ${patch_list}= Create List
362
363 @{network_configurations}= Get Network Configuration
364 : FOR ${network_configuration} IN @{network_configurations}
365 \ Run Keyword If '${network_configuration['Address']}' == '${ip}'
366 ... Append To List ${patch_list} ${null}
367 ... ELSE Append To List ${patch_list} ${empty_dict}
368
369 ${ip_found}= Run Keyword And Return Status List Should Contain Value
370 ... ${patch_list} ${null} msg=${ip} does not exist on BMC
371 Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC
372
373 # Run patch command only if given IP is found on BMC
374 ${data}= Create Dictionary IPv4Addresses=${patch_list}
375
376 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
377 ... valid_status_codes=[${valid_status_codes}]
378
379 # Note: Network restart takes around 15-18s after patch request processing
380 Sleep ${NETWORK_TIMEOUT}s
381 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
382
383 ${delete_status}= Run Keyword And Return Status Verify IP On BMC ${ip}
384 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
385 ... Should Be True ${delete_status} == ${False}
386 ... ELSE Should Be True ${delete_status} == ${True}
387
388 Validate Network Config On BMC
389
390
391Validate Network Config On BMC
392 [Documentation] Check that network info obtained via redfish matches info
393 ... obtained via CLI.
394
395 @{network_configurations}= Get Network Configuration
396 ${ip_data}= Get BMC IP Info
397 : FOR ${network_configuration} IN @{network_configurations}
398 \ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
399 ... msg=IP address does not exist.
400
George Keishing5d467552019-02-08 23:30:48 -0600401
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600402Verify Netmask On BMC
403 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600404 [Arguments] ${netmask}
405
406 # Description of the argument(s):
407 # netmask netmask value to be verified.
408
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600409 ${prefix_length}= Netmask Prefix Length ${netmask}
410
411 Should Contain Match ${ip_data} */${prefix_length}
412 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600413
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600414Verify Gateway On BMC
415 [Documentation] Verify gateway on BMC.
416 [Arguments] ${gateway_ip}=0.0.0.0
417
418 # Description of argument(s):
419 # gateway_ip Gateway IP address.
420
421 ${route_info}= Get BMC Route Info
422
423 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
424
425 Run Keyword If '${gateway_ip}' == '0.0.0.0'
426 ... Pass Execution Gateway IP is "0.0.0.0".
427 ... ELSE
428 ... Should Contain ${route_info} ${gateway_ip}
429 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600430
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600431Verify IP And Netmask On BMC
432 [Documentation] Verify IP and netmask on BMC.
433 [Arguments] ${ip} ${netmask}
434
435 # Description of the argument(s):
436 # ip IP address to be verified.
437 # netmask netmask value to be verified.
438
439 ${prefix_length}= Netmask Prefix Length ${netmask}
440 @{ip_data}= Get BMC IP Info
441
442 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
443 Should Contain ${ip_data} ${ip_with_netmask}
444 ... msg=IP and netmask pair does not exist.
445
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500446Validate Hostname On BMC
447 [Documentation] Verify that the hostname read via Redfish is the same as the
448 ... hostname configured on system.
449 [Arguments] ${hostname}
450
451 # Description of argument(s):
452 # hostname A hostname value which is to be compared to the hostname
453 # configured on system.
454
455 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500456 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500457 ... ignore_case=True msg=Hostname does not exist.
458
Prashanth Kattif58cce02019-02-06 03:05:14 -0600459Test Teardown Execution
460 [Documentation] Test teardown execution.
461
462 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600463 Redfish.Logout