blob: 8f41ad488812bb09d40281550c5ec39b806fca12 [file] [log] [blame]
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -05001*** Settings ***
2Documentation This suite is for testing general IPMI functions.
3
4Resource ../../lib/ipmi_client.robot
5Resource ../../lib/openbmc_ffdc.robot
George Keishing0825a112018-03-30 10:48:07 -05006Resource ../../lib/boot_utils.robot
George Keishing78ce8dc2018-03-30 11:49:06 -05007Resource ../../lib/utils.robot
Sweta Potthurif39022d2018-02-06 03:40:07 -06008Resource ../../lib/bmc_network_utils.robot
George Keishingd6273802018-09-07 07:06:53 -05009Resource ../../lib/logging_utils.robot
George Keishing78ce8dc2018-03-30 11:49:06 -050010Library ../../lib/ipmi_utils.py
George Keishing0825a112018-03-30 10:48:07 -050011Variables ../../data/ipmi_raw_cmd_table.py
Rahul Maheshwaridf6f05d2018-09-04 03:48:37 -050012Library ../../lib/gen_misc.py
Tony Lee9bca44b2019-12-13 09:34:26 +080013Library ../../lib/gen_robot_valid.py
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050014
Michael Walshc9eb34e2019-01-23 11:08:43 -060015Test Setup Log to Console ${EMPTY}
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050016Test Teardown FFDC On Test Case Fail
17
18*** Variables ***
19
Rahul Maheshwari901dcde2018-02-06 03:14:31 -060020${allowed_temp_diff}= ${1}
Rahul Maheshwari615da152018-02-13 23:53:36 -060021${allowed_power_diff}= ${10}
Sweta Potthuri5c6c72e2018-01-23 05:48:35 -060022
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050023*** Test Cases ***
24
Sweta Potthuri0cc60502018-01-24 00:36:17 -060025Verify Chassis Identify via IPMI
26 [Documentation] Verify "chassis identify" using IPMI command.
27 [Tags] Verify_Chassis_Identify_via_IPMI
28
29 # Set to default "chassis identify" and verify that LED blinks for 15s.
30 Run IPMI Standard Command chassis identify
Alvin Wang32f7b3d2019-07-25 02:05:39 -050031 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060032
Tony Lee2afe9982020-02-11 17:31:14 +080033 Sleep 18s
Alvin Wang32f7b3d2019-07-25 02:05:39 -050034 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060035
36 # Set "chassis identify" to 10s and verify that the LED blinks for 10s.
37 Run IPMI Standard Command chassis identify 10
Alvin Wang32f7b3d2019-07-25 02:05:39 -050038 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060039
Tony Lee2afe9982020-02-11 17:31:14 +080040 Sleep 12s
Alvin Wang32f7b3d2019-07-25 02:05:39 -050041 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060042
Sweta Potthurif39022d2018-02-06 03:40:07 -060043
Sweta Potthuri0cc60502018-01-24 00:36:17 -060044Verify Chassis Identify Off And Force Identify On via IPMI
45 [Documentation] Verify "chassis identify" off
46 ... and "force identify on" via IPMI.
47 [Tags] Verify_Chassis_Identify_Off_And_Force_Identify_On_via_IPMI
48
49 # Set the LED to "Force Identify On".
50 Run IPMI Standard Command chassis identify force
Alvin Wang32f7b3d2019-07-25 02:05:39 -050051 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060052
53 # Set "chassis identify" to 0 and verify that the LED turns off.
54 Run IPMI Standard Command chassis identify 0
Alvin Wang32f7b3d2019-07-25 02:05:39 -050055 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060056
Sweta Potthurif39022d2018-02-06 03:40:07 -060057
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -060058Test Watchdog Reset Via IPMI And Verify Using REST
59 [Documentation] Test watchdog reset via IPMI and verify using REST.
60 [Tags] Test_Watchdog_Reset_Via_IPMI_And_Verify_Using_REST
61
62 Initiate Host Boot
63
64 Set Watchdog Enabled Using REST ${1}
65
66 Watchdog Object Should Exist
67
68 # Resetting the watchdog via IPMI.
69 Run IPMI Standard Command mc watchdog reset
70
71 # Verify the watchdog is reset using REST after an interval of 1000ms.
72 Sleep 1000ms
73 ${watchdog_time_left}=
74 ... Read Attribute ${HOST_WATCHDOG_URI} TimeRemaining
75 Should Be True
76 ... ${watchdog_time_left}<${1200000} and ${watchdog_time_left}>${2000}
77 ... msg=Watchdog timer didn't reset.
78
Sweta Potthurif39022d2018-02-06 03:40:07 -060079
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -060080Test Watchdog Off Via IPMI And Verify Using REST
81 [Documentation] Test watchdog off via IPMI and verify using REST.
82 [Tags] Test_Watchdog_Off_Via_IPMI_And_Verify_Using_REST
83
84 Initiate Host Boot
85
86 Set Watchdog Enabled Using REST ${1}
87
88 Watchdog Object Should Exist
89
90 # Turn off the watchdog via IPMI.
91 Run IPMI Standard Command mc watchdog off
92
93 # Verify the watchdog is off using REST
94 ${watchdog_state}= Read Attribute ${HOST_WATCHDOG_URI} Enabled
95 Should Be Equal ${watchdog_state} ${0}
96 ... msg=msg=Verification failed for watchdog off check.
Rahul Maheshwari901dcde2018-02-06 03:14:31 -060097
98
Rahul Maheshwarife8639b2018-02-05 22:42:24 -060099Verify Get Device ID
100 [Documentation] Verify get device ID command output.
101 [Tags] Verify_Get_Device_ID
102
103 # Example of get device ID command output:
104 # Device ID : 0
105 # Device Revision : 0
106 # Firmware Revision : 2.01
107 # IPMI Version : 2.0
108 # Manufacturer ID : 42817
109 # Manufacturer Name : Unknown (0xA741)
110 # Product ID : 16975 (0x424f)
111 # Product Name : Unknown (0x424F)
112 # Device Available : yes
113 # Provides Device SDRs : yes
114 # Additional Device Support :
115 # Sensor Device
116 # SEL Device
117 # FRU Inventory Device
118 # Chassis Device
119 # Aux Firmware Rev Info :
George Keishing3511a3f2018-04-19 10:38:30 -0500120 # 0x04
121 # 0x38
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600122 # 0x00
George Keishing3511a3f2018-04-19 10:38:30 -0500123 # 0x03
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600124
Tony Lee9bca44b2019-12-13 09:34:26 +0800125 # Verify Manufacturer and Product IDs, etc. directly from json file.
126 ${device_id_config}= Get Device Id Config
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600127 ${mc_info}= Get MC Info
128
Tony Lee9bca44b2019-12-13 09:34:26 +0800129 Rprint Vars device_id_config mc_info
130 Valid Value ${mc_info['device_id']} [${device_id_config['id']}]
131 Valid Value ${mc_info['device_revision']} [${device_id_config['device_revision']}]
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600132
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500133 # Get firmware revision from mc info command output i.e. 2.01
134 ${ipmi_fw_major_version} ${ipmi_fw_minor_version}=
135 ... Split String ${mc_info['firmware_revision']} .
136 # Convert minor firmware version from BCD format to integer. i.e. 01 to 1
137 ${ipmi_fw_minor_version}= Convert To Integer ${ipmi_fw_minor_version}
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600138
George Keishinge0a81282018-06-08 10:02:30 -0500139 # Get BMC version from BMC CLI i.e. 2.2 from "v2.2-253-g00050f1"
George Keishing3511a3f2018-04-19 10:38:30 -0500140 ${bmc_version_full}= Get BMC Version
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500141 ${bmc_version}=
George Keishing3511a3f2018-04-19 10:38:30 -0500142 ... Remove String Using Regexp ${bmc_version_full} ^[^0-9]+ [^0-9\.].*
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500143
144 # Get major and minor version from BMC version i.e. 2 and 1 from 2.1
George Keishingc95e9982019-01-14 09:27:45 -0600145 @{major_minor_version}= Split String ${bmc_version} .
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500146
George Keishingc95e9982019-01-14 09:27:45 -0600147 Should Be Equal As Strings ${ipmi_fw_major_version} ${major_minor_version[0]}
George Keishing2ee2f002019-02-16 09:36:02 -0600148 ... msg=Major version mismatch.
George Keishingc95e9982019-01-14 09:27:45 -0600149 Should Be Equal As Strings ${ipmi_fw_minor_version} ${major_minor_version[1]}
George Keishing2ee2f002019-02-16 09:36:02 -0600150 ... msg=Minor version mismatch.
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500151
Tony Lee9bca44b2019-12-13 09:34:26 +0800152 Valid Value mc_info['ipmi_version'] ['2.0']
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600153
Tony Lee9bca44b2019-12-13 09:34:26 +0800154 Valid Value ${mc_info['manufacturer_id']} [${device_id_config['manuf_id']}]
155 ${product_id_hex} = Convert To Hex ${device_id_config['prod_id']} lowercase=True
156 Valid Value mc_info['product_id'] ['${device_id_config['prod_id']} (0x${product_id_hex})']
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600157
Tony Lee9bca44b2019-12-13 09:34:26 +0800158 Valid Value mc_info['device_available'] ['yes']
159 Valid Value mc_info['provides_device_sdrs'] ['yes']
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600160 Should Contain ${mc_info['additional_device_support']} Sensor Device
161 Should Contain ${mc_info['additional_device_support']} SEL Device
162 Should Contain
163 ... ${mc_info['additional_device_support']} FRU Inventory Device
164 Should Contain ${mc_info['additional_device_support']} Chassis Device
George Keishingb746d3f2018-04-19 10:53:10 -0500165
George Keishing3511a3f2018-04-19 10:38:30 -0500166 # Auxiliary revision data verification.
167 ${aux_version}= Get Aux Version ${bmc_version_full}
168
169 # From aux_firmware_rev_info field ['0x04', '0x38', '0x00', '0x03']
170 ${bmc_aux_version}= Catenate
171 ... SEPARATOR=
172 ... ${mc_info['aux_firmware_rev_info'][0][2:]}
173 ... ${mc_info['aux_firmware_rev_info'][1][2:]}
174 ... ${mc_info['aux_firmware_rev_info'][2][2:]}
175 ... ${mc_info['aux_firmware_rev_info'][3][2:]}
176
177 Should Be Equal As Integers
178 ... ${bmc_aux_version} ${aux_version}
179 ... msg=BMC aux version ${bmc_aux_version} does not match expected value of ${aux_version}.
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600180
181
George Keishinge85113a2019-06-07 08:21:51 -0500182Test IPMI Restriction Mode
183 [Documentation] Set restricition mode via REST and verify IPMI operation.
184 [Tags] Test_IPMI_Restriction_Mode
185 # Forego normal test setup:
186 [Setup] No Operation
187 [Teardown] Run Keywords FFDC On Test Case Fail AND
188 ... Set IPMI Restriction Mode xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None
189
190 # By default no IPMI operations are restricted.
191 # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode
192 # {
193 # "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None",
194 # "message": "200 OK",
195 # "status": "ok"
196 # }
197
198 # Refer to: #openbmc/phosphor-host-ipmid/blob/master/host-ipmid-whitelist.conf
Sushma M M8cd1d3e2020-07-13 02:14:30 -0500199 # Set the restriction mode to Allowed list IPMI commands only:
George Keishinge85113a2019-06-07 08:21:51 -0500200 # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode
201 # {
202 # "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist",
203 # "message": "200 OK",
204 # "status": "ok"
205 # }
206
207 Set IPMI Restriction Mode xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist
208
Sushma M M8cd1d3e2020-07-13 02:14:30 -0500209 # Attempt allowed listed operation expecting success.
George Keishinge85113a2019-06-07 08:21:51 -0500210 IPMI Power On
211
Sushma M M8cd1d3e2020-07-13 02:14:30 -0500212 # Attempt non allowed listed operation expecting failure.
George Keishinge85113a2019-06-07 08:21:51 -0500213 Run Keyword And Expect Error *Insufficient privilege level*
Rahul Maheshwari40193982019-10-11 00:55:08 -0500214 ... Run Inband IPMI Standard Command lan set 1 access on
George Keishinge85113a2019-06-07 08:21:51 -0500215
216
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -0500217*** Keywords ***
Sweta Potthuri5c6c72e2018-01-23 05:48:35 -0600218
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600219Set Watchdog Enabled Using REST
220 [Documentation] Set watchdog Enabled field using REST.
221 [Arguments] ${value}
222
223 # Description of argument(s):
224 # value Integer value (eg. "0-Disabled", "1-Enabled").
225
226 ${value_dict}= Create Dictionary data=${value}
Steven Sombaraaaab222018-12-19 13:16:23 -0600227 ${resp}= OpenBMC Put Request ${HOST_WATCHDOG_URI}attr/Enabled
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600228 ... data=${value_dict}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600229
230
Sweta Potthurif39022d2018-02-06 03:40:07 -0600231Fetch Details From LAN Print
232 [Documentation] Fetch details from LAN print.
233 [Arguments] ${field_name}
234
235 # Description of argument(s):
236 # ${field_name} Field name to be fetched from LAN print
237 # (e.g. "MAC Address", "Source").
238
Rahul Maheshwarid8037d32018-12-17 00:59:57 -0600239 ${stdout}= Run IPMI Standard Command lan print
Sweta Potthurif39022d2018-02-06 03:40:07 -0600240 ${fetch_value}= Get Lines Containing String ${stdout} ${field_name}
241 ${value_fetch}= Fetch From Right ${fetch_value} :${SPACE}
242 [Return] ${value_fetch}
243
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600244
George Keishinge85113a2019-06-07 08:21:51 -0500245Set IPMI Restriction Mode
246 [Documentation] Set the IPMI restriction mode.
247 [Arguments] ${restriction_mode}
248
249 # Description of argument(s):
250 # restriction_mode IPMI valid restriction modes.
251
252 ${valueDict}= Create Dictionary data=${restriction_mode}
253
254 Write Attribute ${CONTROL_HOST_URI}restriction_mode/
255 ... RestrictionMode data=${valueDict}