1*** Settings *** 2Documentation Test BMC Manager functionality. 3Resource ../../lib/resource.robot 4Resource ../../lib/bmc_redfish_resource.robot 5Resource ../../lib/common_utils.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/boot_utils.robot 8Resource ../../lib/open_power_utils.robot 9Resource ../../lib/bmc_network_utils.robot 10Library ../../lib/gen_robot_valid.py 11 12Test Setup Test Setup Execution 13Test Teardown Test Teardown Execution 14 15 16*** Variables *** 17 18${SYSTEM_SHUTDOWN_TIME} ${5} 19 20# Strings to check from journald. 21${REBOOT_REGEX} ^\-- Boot | Startup finished 22 23*** Test Cases *** 24 25Verify Redfish BMC Firmware Version 26 [Documentation] Get firmware version from BMC manager. 27 [Tags] Verify_Redfish_BMC_Firmware_Version 28 29 Redfish.Login 30 ${resp}= Redfish.Get /redfish/v1/Managers/${MANAGER_ID} 31 Should Be Equal As Strings ${resp.status} ${HTTP_OK} 32 ${bmc_version}= Get BMC Version 33 Should Be Equal As Strings 34 ... ${resp.dict["FirmwareVersion"]} ${bmc_version.strip('"')} 35 36 37Verify Redfish BMC Manager Properties 38 [Documentation] Verify BMC managers resource properties. 39 [Tags] Verify_Redfish_BMC_Manager_Properties 40 41 Redfish.Login 42 ${resp}= Redfish.Get /redfish/v1/Managers/${MANAGER_ID} 43 Should Be Equal As Strings ${resp.status} ${HTTP_OK} 44 # Example: 45 # "Description": "Baseboard Management Controller" 46 # "Id": "bmc" 47 # "Model": "OpenBmc", 48 # "Name": "OpenBmc Manager", 49 # "UUID": "xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx" 50 # "PowerState": "On" 51 52 Should Be Equal As Strings 53 ... ${resp.dict["Description"]} Baseboard Management Controller 54 Should Be Equal As Strings ${resp.dict["Id"]} bmc 55 Should Be Equal As Strings ${resp.dict["Name"]} OpenBmc Manager 56 Should Not Be Empty ${resp.dict["UUID"]} 57 Should Be Equal As Strings ${resp.dict["PowerState"]} On 58 59 60Verify MAC Address Property Is Populated 61 [Documentation] Verify BMC managers resource properties. 62 [Tags] Verify_MAC_Address_Property_Is_Populated 63 64 # Get OrderedDict from the BMC which contains active ethernet channel. 65 # Example: ([('1', {'name': 'eth0', 66 # 'is_valid': True, 67 # 'active_sessions': 0, 68 # 'channel_info': {'medium_type': 'lan-802.3', 69 # 'protocol_type': 'ipmb-1.0', 70 # 'session_supported': 'multi-session', 71 # 'is_ipmi': True 72 # } 73 # } 74 # )]) 75 76 ${active_channel_config}= Get Active Channel Config 77 78 FOR ${channel_number} IN @{active_channel_config.keys()} 79 Log Dictionary ${active_channel_config["${channel_number}"]} 80 81 # Skip channel if is_valid is false for the channel number 82 IF ${active_channel_config["${channel_number}"]["is_valid"]}==${FALSE} CONTINUE 83 84 # Get ethernet valid paths in redfish. 85 # Example: ['/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces'] 86 ${eth_interface}= redfish_utils.Get Endpoint Path List 87 ... /redfish/v1/Managers/ EthernetInterfaces 88 89 # Get the MACAddress attrivute value with the 'name': 'eth0'. 90 # Example: /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0 91 ${redfish_mac_addr}= Redfish.Get Attribute 92 ... ${eth_interface[0]}/${active_channel_config["${channel_number}"]["name"]} 93 ... MACAddress 94 END 95 96 Rprint Vars redfish_mac_addr fmt=terse 97 Valid Value redfish_mac_addr 98 99 ${ipaddr_mac_addr}= Get BMC MAC Address List 100 Rprint Vars ipaddr_mac_addr fmt=terse 101 102 List Should Contain Value ${ipaddr_mac_addr} ${redfish_mac_addr} 103 104 105Redfish BMC Manager GracefulRestart When Host Off 106 [Documentation] BMC graceful restart when host is powered off. 107 [Tags] Redfish_BMC_Manager_GracefulRestart_When_Host_Off 108 109 # "Actions": { 110 # "#Manager.Reset": { 111 # "ResetType@Redfish.AllowableValues": [ 112 # "GracefulRestart", 113 # "ForceRestart" 114 # ], 115 # "target": "/redfish/v1/Managers/${MANAGER_ID}/Actions/Manager.Reset" 116 # } 117 118 ${test_file_path}= Set Variable /tmp/before_bmcreboot 119 BMC Execute Command touch ${test_file_path} 120 121 Redfish Power Off stack_mode=skip 122 123 Redfish BMC Reset Operation reset_type=GracefulRestart 124 125 Is BMC Standby 126 127 ${stdout} ${stderr} ${rc}= BMC Execute Command test ! -f ${test_file_path} print_out=1 128 Verify BMC RTC And UTC Time Drift 129 130 # Check for journald persistency post reboot. 131 Wait Until Keyword Succeeds 3 min 10 sec 132 ... Check For Regex In Journald ${REBOOT_REGEX} error_check=${1} 133 134 135Redfish BMC Manager ForceRestart When Host Off 136 [Documentation] BMC force restart when host is powered off. 137 [Tags] Redfish_BMC_Manager_ForceRestart_When_Host_Off 138 139 # "Actions": { 140 # "#Manager.Reset": { 141 # "ResetType@Redfish.AllowableValues": [ 142 # "GracefulRestart", 143 # "ForceRestart" 144 # ], 145 # "target": "/redfish/v1/Managers/${MANAGER_ID}/Actions/Manager.Reset" 146 # } 147 148 ${test_file_path}= Set Variable /tmp/before_bmcreboot 149 BMC Execute Command touch ${test_file_path} 150 151 Redfish Power Off stack_mode=skip 152 153 Redfish BMC Reset Operation reset_type=ForceRestart 154 155 Is BMC Standby 156 157 ${stdout} ${stderr} ${rc}= BMC Execute Command test ! -f ${test_file_path} print_out=1 158 Verify BMC RTC And UTC Time Drift 159 160 # Check for journald persistency post reboot. 161 Wait Until Keyword Succeeds 3 min 10 sec 162 ... Check For Regex In Journald ${REBOOT_REGEX} error_check=${1} 163 164 165Verify Boot Count After BMC Reboot 166 [Documentation] Verify boot count increments on BMC reboot. 167 [Tags] Verify_Boot_Count_After_BMC_Reboot 168 [Setup] Run Keywords Update NTP Test Initial Status AND 169 ... Set NTP state ${TRUE} 170 [Teardown] Restore NTP Status 171 172 Set BMC Boot Count ${0} 173 Redfish OBMC Reboot (off) 174 ${boot_count}= Get BMC Boot Count 175 Should Be Equal ${boot_count} ${1} msg=Boot count is not incremented. 176 177 178Redfish BMC Manager GracefulRestart When Host Booted 179 [Documentation] BMC graceful restart when host is running. 180 [Tags] Redfish_BMC_Manager_GracefulRestart_When_Host_Booted 181 182 Redfish OBMC Reboot (run) 183 184 # TODO: Replace OCC state check with redfish property when available. 185 Wait Until Keyword Succeeds 10 min 30 sec Verify OCC State 186 187 188*** Keywords *** 189 190Test Setup Execution 191 [Documentation] Do test case setup tasks. 192 193 redfish.Login 194 195 196Test Teardown Execution 197 [Documentation] Do the post test teardown. 198 199 FFDC On Test Case Fail 200 Run Keyword And Ignore Error redfish.Logout 201 202 203Update NTP Test Initial Status 204 [Documentation] Update the initial status of NTP. 205 206 Redfish.Login 207 ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP 208 Set Suite Variable ${original_ntp} 209 210 211Set NTP state 212 [Documentation] Set NTP service inactive. 213 [Arguments] ${state} 214 215 Redfish.Login 216 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${state}}} 217 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 218 219 220Restore NTP Status 221 [Documentation] Restore NTP Status. 222 223 IF '${original_ntp["ProtocolEnabled"]}' == 'True' 224 Set NTP state ${TRUE} 225 ELSE 226 Set NTP state ${FALSE} 227 END 228