blob: 5f75d401f8d221a5e790a3d35e9bbd3e88aa5a07 [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
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -050086 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
Prashanth Katti23efc6e2019-03-13 06:07:15 -050087
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -050088 Configure Hostname ${test_hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -050089 Validate Hostname On BMC ${test_hostname}
90
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -050091 # Revert back to initial hostname.
92 Configure Hostname ${hostname}
93 Validate Hostname On BMC ${hostname}
94
Vijayde3bf7b2019-04-16 04:56:09 -050095Add Valid IPv4 Address And Verify
96 [Documentation] Add IPv4 Address via Redfish and verify.
97 [Tags] Add_Valid_IPv4_Addres_And_Verify
98
99 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
100 Delete IP Address ${test_ipv4_addr}
101
102Add Invalid IPv4 Address And Verify
103 [Documentation] Add Invalid IPv4 Address via Redfish and verify.
104 [Tags] Add_Invalid_IPv4_Addres_And_Verify
105
106 Add IP Address ${test_ipv4_invalid_addr} ${test_subnet_mask}
107 ... ${test_gateway} valid_status_codes=${HTTP_BAD_REQUEST}
108
Prashanth Kattib36a7522019-05-22 05:32:39 -0500109Configure Out Of Range IP
110 [Documentation] Configure out-of-range IP address.
111 [Tags] Configure_Out_Of_Range_IP
112 [Template] Add IP Address
113
114 # ip subnet_mask gateway valid_status_codes
115 ${out_of_range_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
116
117Configure Broadcast IP
118 [Documentation] Configure broadcast IP address.
119 [Tags] Configure_Broadcast_IP
120 [Template] Add IP Address
121
122 # ip subnet_mask gateway valid_status_codes
123 ${broadcast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
124
Prashanth Kattia8442512019-06-07 06:47:09 -0500125 [Teardown] Clear IP Settings On Fail ${broadcast_ip}
126
Prashanth Kattib36a7522019-05-22 05:32:39 -0500127Configure Multicast IP
128 [Documentation] Configure multicast IP address.
129 [Tags] Configure_Multicast_IP
130 [Template] Add IP Address
131
132 # ip subnet_mask gateway valid_status_codes
133 ${multicast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
134
Prashanth Kattia8442512019-06-07 06:47:09 -0500135 [Teardown] Clear IP Settings On Fail ${multicast_ip}
136
Prashanth Kattib36a7522019-05-22 05:32:39 -0500137Configure Loopback IP
138 [Documentation] Configure loopback IP address.
139 [Tags] Configure_Loopback_IP
140 [Template] Add IP Address
141
142 # ip subnet_mask gateway valid_status_codes
143 ${loopback_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
144
Prashanth Kattia8442512019-06-07 06:47:09 -0500145 [Teardown] Clear IP Settings On Fail ${loopback_ip}
146
Prashanth Kattib36a7522019-05-22 05:32:39 -0500147Add Valid IPv4 Address And Check Persistency
148 [Documentation] Add IPv4 address and check peristency.
149 [Tags] Add_Valid_IPv4_Addres_And_Check_Persistency
150
151 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
152
153 # Reboot BMC and verify persistency.
154 OBMC Reboot (off)
155 Verify IP On BMC ${test_ipv4_addr}
156 Delete IP Address ${test_ipv4_addr}
Vijayde3bf7b2019-04-16 04:56:09 -0500157
Prashanth Katti6cedca22019-05-30 02:31:11 -0500158Add Fourth Octet Threshold IP And Verify
159 [Documentation] Add fourth octet threshold IP and verify.
160 [Tags] Add_Fourth_Octet_Threshold_IP_And_Verify
161
162 Add IP Address 10.7.7.254 ${test_subnet_mask} ${test_gateway}
163 Delete IP Address 10.7.7.254
164
165Add Fourth Octet Lowest IP And Verify
166 [Documentation] Add fourth octet lowest IP and verify.
167 [Tags] Add_Fourth_Octet_Lowest_IP_And_Verify
168
169 Add IP Address 10.7.7.1 ${test_subnet_mask} ${test_gateway}
170 Delete IP Address 10.7.7.1
171
172Add Third Octet Threshold IP And Verify
173 [Documentation] Add third octet threshold IP and verify.
174 [Tags] Add_Third_Octet_Threshold_IP_And_Verify
175
176 Add IP Address 10.7.255.7 ${test_subnet_mask} ${test_gateway}
177 Delete IP Address 10.7.255.7
178
179Add Third Octet Lowest IP And Verify
180 [Documentation] Add third octet lowest IP and verify.
181 [Tags] Add_Third_Octet_Lowest_IP_And_Verify
182
183 Add IP Address 10.7.0.7 ${test_subnet_mask} ${test_gateway}
184 Delete IP Address 10.7.0.7
185
186Add Second Octet Threshold IP And Verify
187 [Documentation] Add second octet threshold IP and verify.
188 [Tags] Add_Second_Octet_Threshold_IP_And_Verify
189
190 Add IP Address 10.255.7.7 ${test_subnet_mask} ${test_gateway}
191 Delete IP Address 10.255.7.7
192
193Add Second Octet Lowest IP And Verify
194 [Documentation] Add second octet lowest IP and verify.
195 [Tags] Add_Second_Octet_Lowest_IP_And_Verify
196
197 Add IP Address 10.0.7.7 ${test_subnet_mask} ${test_gateway}
198 Delete IP Address 10.0.7.7
199
200Add First Octet Threshold IP And Verify
201 [Documentation] Add first octet threshold IP and verify.
202 [Tags] Add_First_Octet_Threshold_IP_And_Verify
203
204 Add IP Address 223.7.7.7 ${test_subnet_mask} ${test_gateway}
205 Delete IP Address 223.7.7.7
206
207Add First Octet Lowest IP And Verify
208 [Documentation] Add first octet lowest IP and verify.
209 [Tags] Add_First_Octet_Lowest_IP_And_Verify
210
211 Add IP Address 1.7.7.7 ${test_subnet_mask} ${test_gateway}
212 Delete IP Address 1.7.7.7
213
Prashanth Katti040c8c12019-05-31 04:42:05 -0500214Configure Invalid Netmask
215 [Documentation] Verify error while setting invalid netmask.
216 [Tags] Configure_Invalid_Netmask
217 [Template] Add IP Address
218
219 # ip subnet_mask gateway valid_status_codes
220 ${test_ipv4_addr} ${invalid_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
221
222Configure Out Of Range Netmask
223 [Documentation] Verify error while setting out of range netmask.
224 [Tags] Configure_Out_Of_Range_Netmask
225 [Template] Add IP Address
226
227 # ip subnet_mask gateway valid_status_codes
228 ${test_ipv4_addr} ${out_of_range_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
229
230Configure Alpha Netmask
231 [Documentation] Verify error while setting alpha netmask.
232 [Tags] Configure_Alpha_Netmask
233 [Template] Add IP Address
234
235 # ip subnet_mask gateway valid_status_codes
236 ${test_ipv4_addr} ${alpha_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
237
238Configure More Byte Netmask
239 [Documentation] Verify error while setting more byte netmask.
240 [Tags] Configure_More_Byte_Netmask
241 [Template] Add IP Address
242
243 # ip subnet_mask gateway valid_status_codes
244 ${test_ipv4_addr} ${more_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
245
246Configure Less Byte Netmask
247 [Documentation] Verify error while setting less byte netmask.
248 [Tags] Configure_Less_Byte_Netmask
249 [Template] Add IP Address
250
251 # ip subnet_mask gateway valid_status_codes
252 ${test_ipv4_addr} ${less_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
253
Prashanth Kattif58cce02019-02-06 03:05:14 -0600254*** Keywords ***
255
256Test Setup Execution
257 [Documentation] Test setup execution.
258
George Keishing97c93942019-03-04 12:45:07 -0600259 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -0600260
261 @{network_configurations}= Get Network Configuration
262 Set Test Variable @{network_configurations}
263
264 # Get BMC IP address and prefix length.
265 ${ip_data}= Get BMC IP Info
266 Set Test Variable ${ip_data}
267
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600268
Prashanth Kattif58cce02019-02-06 03:05:14 -0600269Get Network Configuration
270 [Documentation] Get network configuration.
271
272 # Sample output:
273 #{
274 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
275 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
276 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
277 # "Description": "Management Network Interface",
278 # "IPv4Addresses": [
279 # {
280 # "Address": "169.254.xx.xx",
281 # "AddressOrigin": "IPv4LinkLocal",
282 # "Gateway": "0.0.0.0",
283 # "SubnetMask": "255.255.0.0"
284 # },
285 # {
286 # "Address": "xx.xx.xx.xx",
287 # "AddressOrigin": "Static",
288 # "Gateway": "xx.xx.xx.1",
289 # "SubnetMask": "xx.xx.xx.xx"
290 # }
291 # ],
292 # "Id": "eth0",
293 # "MACAddress": "xx:xx:xx:xx:xx:xx",
294 # "Name": "Manager Ethernet Interface",
295 # "SpeedMbps": 0,
296 # "VLAN": {
297 # "VLANEnable": false,
298 # "VLANId": 0
299 # }
300
George Keishing97c93942019-03-04 12:45:07 -0600301 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattif58cce02019-02-06 03:05:14 -0600302 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses
303 [Return] @{network_configurations}
304
George Keishing5d467552019-02-08 23:30:48 -0600305
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600306Verify IP On BMC
307 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600308 [Arguments] ${ip}
309
Vijayde3bf7b2019-04-16 04:56:09 -0500310 # Description of argument(s):
311 # ip IP address to be verified (e.g. "10.7.7.7").
Prashanth Kattif58cce02019-02-06 03:05:14 -0600312
313 # Get IP address details on BMC using IP command.
314 @{ip_data}= Get BMC IP Info
315 Should Contain Match ${ip_data} ${ip}/*
316 ... msg=IP address does not exist.
317
Vijayde3bf7b2019-04-16 04:56:09 -0500318Add IP Address
319 [Documentation] Add IP Address To BMC.
320 [Arguments] ${ip} ${subnet_mask} ${gateway}
321 ... ${valid_status_codes}=${HTTP_OK}
322
323 # Description of argument(s):
324 # ip IP address to be added (e.g. "10.7.7.7").
325 # subnet_mask Subnet mask for the IP to be added
326 # (e.g. "255.255.0.0").
327 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
328 # valid_status_codes Expected return code from patch operation
329 # (e.g. "200"). See prolog of rest_request
330 # method in redfish_plut.py for details.
331
332 ${empty_dict}= Create Dictionary
333 ${ip_data}= Create Dictionary Address=${ip}
334 ... AddressOrigin=Static SubnetMask=${subnet_mask}
335 ... Gateway=${gateway}
336
337 ${patch_list}= Create List
338 ${network_configurations}= Get Network Configuration
339 ${num_entries}= Get Length ${network_configurations}
340
341 : FOR ${INDEX} IN RANGE 0 ${num_entries}
342 \ Append To List ${patch_list} ${empty_dict}
343
George Keishing98ffa862019-05-23 10:07:45 -0500344 # We need not check for existence of IP on BMC while adding.
Vijayde3bf7b2019-04-16 04:56:09 -0500345 Append To List ${patch_list} ${ip_data}
346 ${data}= Create Dictionary IPv4Addresses=${patch_list}
347
348 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
349 ... valid_status_codes=[${valid_status_codes}]
350
351 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK}'
352
353 # Note: Network restart takes around 15-18s after patch request processing.
354 Sleep ${NETWORK_TIMEOUT}s
355 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
356
357 Verify IP On BMC ${ip}
358 Validate Network Config On BMC
359
360
361Delete IP Address
362 [Documentation] Delete IP Address Of BMC.
363 [Arguments] ${ip} ${valid_status_codes}=${HTTP_OK}
364
365 # Description of argument(s):
366 # ip IP address to be deleted (e.g. "10.7.7.7").
367 # valid_status_codes Expected return code from patch operation
368 # (e.g. "200"). See prolog of rest_request
369 # method in redfish_plut.py for details.
370
371 ${empty_dict}= Create Dictionary
372 ${patch_list}= Create List
373
374 @{network_configurations}= Get Network Configuration
375 : FOR ${network_configuration} IN @{network_configurations}
376 \ Run Keyword If '${network_configuration['Address']}' == '${ip}'
377 ... Append To List ${patch_list} ${null}
378 ... ELSE Append To List ${patch_list} ${empty_dict}
379
380 ${ip_found}= Run Keyword And Return Status List Should Contain Value
381 ... ${patch_list} ${null} msg=${ip} does not exist on BMC
382 Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC
383
384 # Run patch command only if given IP is found on BMC
385 ${data}= Create Dictionary IPv4Addresses=${patch_list}
386
387 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
388 ... valid_status_codes=[${valid_status_codes}]
389
390 # Note: Network restart takes around 15-18s after patch request processing
391 Sleep ${NETWORK_TIMEOUT}s
392 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
393
394 ${delete_status}= Run Keyword And Return Status Verify IP On BMC ${ip}
395 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
396 ... Should Be True ${delete_status} == ${False}
397 ... ELSE Should Be True ${delete_status} == ${True}
398
399 Validate Network Config On BMC
400
401
402Validate Network Config On BMC
403 [Documentation] Check that network info obtained via redfish matches info
404 ... obtained via CLI.
405
406 @{network_configurations}= Get Network Configuration
407 ${ip_data}= Get BMC IP Info
408 : FOR ${network_configuration} IN @{network_configurations}
409 \ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
410 ... msg=IP address does not exist.
411
George Keishing5d467552019-02-08 23:30:48 -0600412
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600413Verify Netmask On BMC
414 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600415 [Arguments] ${netmask}
416
417 # Description of the argument(s):
418 # netmask netmask value to be verified.
419
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600420 ${prefix_length}= Netmask Prefix Length ${netmask}
421
422 Should Contain Match ${ip_data} */${prefix_length}
423 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600424
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600425Verify Gateway On BMC
426 [Documentation] Verify gateway on BMC.
427 [Arguments] ${gateway_ip}=0.0.0.0
428
429 # Description of argument(s):
430 # gateway_ip Gateway IP address.
431
432 ${route_info}= Get BMC Route Info
433
434 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
435
436 Run Keyword If '${gateway_ip}' == '0.0.0.0'
437 ... Pass Execution Gateway IP is "0.0.0.0".
438 ... ELSE
439 ... Should Contain ${route_info} ${gateway_ip}
440 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600441
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600442Verify IP And Netmask On BMC
443 [Documentation] Verify IP and netmask on BMC.
444 [Arguments] ${ip} ${netmask}
445
446 # Description of the argument(s):
447 # ip IP address to be verified.
448 # netmask netmask value to be verified.
449
450 ${prefix_length}= Netmask Prefix Length ${netmask}
451 @{ip_data}= Get BMC IP Info
452
453 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
454 Should Contain ${ip_data} ${ip_with_netmask}
455 ... msg=IP and netmask pair does not exist.
456
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500457Validate Hostname On BMC
458 [Documentation] Verify that the hostname read via Redfish is the same as the
459 ... hostname configured on system.
460 [Arguments] ${hostname}
461
462 # Description of argument(s):
463 # hostname A hostname value which is to be compared to the hostname
464 # configured on system.
465
466 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500467 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500468 ... ignore_case=True msg=Hostname does not exist.
469
Prashanth Kattif58cce02019-02-06 03:05:14 -0600470Test Teardown Execution
471 [Documentation] Test teardown execution.
472
473 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600474 Redfish.Logout
Prashanth Kattia8442512019-06-07 06:47:09 -0500475
476Clear IP Settings On Fail
477 [Documentation] Clear IP settings on fail.
478 [Arguments] ${ip}
479
480 # Description of argument(s):
481 # ip IP address to be deleted.
482
483 Run Keyword If '${TEST STATUS}' == 'FAIL'
484 ... Delete IP Address ${ip}
485
486 Test Teardown Execution
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500487