1*** Settings *** 2Documentation This suite verifies the power restore policy setting at 3... at various host states after BMC reboot. 4 5Resource ../../lib/utils.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/bmc_redfish_utils.robot 8Library ../../lib/state_map.py 9 10Test Teardown Test Teardown Execution 11Suite Teardown Suite Teardown Execution 12 13Test Tags Power_Restore_Reboot 14 15 16*** Test Cases *** 17 18Test Restore Policy ALWAYS_POWER_ON With Host Running After Reboot 19 [Documentation] Verify the BMC restore policy is ALWAYS_POWER_ON while the Host is running 20 ... after BMC reboot. 21 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running_After_Reboot 22 [Template] Verify Restore Policy After Reboot 23 24 # Policy Initial Host State Expected Host State 25 AlwaysOn Running Running 26 27 28Test Restore Policy ALWAYS_POWER_ON With Host Off After Reboot 29 [Documentation] Validate ALWAYS_POWER_ON restore policy functionality after BMC reboot. 30 ... Policy: 31 ... System policy set to ALWAYS_POWER_OFF. 32 ... Initial Host State: 33 ... State where system should be before running the 34 ... test case. 35 ... Expected Host State: 36 ... After BMC reset, system should reach this 37 ... specific state. 38 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Off_After_Reboot 39 [Template] Verify Restore Policy After Reboot 40 41 # Policy Initial Host State Expected Host State 42 AlwaysOn Off Running 43 44 45Test Restore Policy ALWAYS_POWER_OFF With Host Off After Reboot 46 [Documentation] Validate ALWAYS_POWER_OFF restore policy functionality after BMC reboot. 47 ... Policy: 48 ... System policy set to ALWAYS_POWER_OFF. 49 ... Initial Host State: 50 ... State where system should be before running the 51 ... test case. 52 ... Expected Host State: 53 ... After BMC reset, system should reach this 54 ... specific state. 55 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Off_After_Reboot 56 [Template] Verify Restore Policy After Reboot 57 58 # Policy Initial Host State Expected Host State 59 AlwaysOff Off Off 60 61 62Test Restore Policy ALWAYS_POWER_OFF With Host Running After Reboot 63 [Documentation] Verify that the BMC restore policy is ALWAYS_POWER_OFF while the Host is running 64 ... after BMC reboot. 65 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Running_After_Reboot 66 [Template] Verify Restore Policy After Reboot 67 68 # Policy Initial Host State Expected Host State 69 AlwaysOff Running Running 70 71 72Test Restore Policy Restore Last State With Host Running After Reboot 73 [Documentation] Validate RESTORE_LAST_STATE restore policy functionality after BMC reboot. 74 ... Policy: 75 ... System policy set to RESTORE_LAST_STATE. 76 ... Initial Host State: 77 ... State where system should be before running the 78 ... test case. 79 ... Expected Host State: 80 ... After BMC reset, system should reach this 81 ... specific state. 82 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Running_After_Reboot 83 [Template] Verify Restore Policy After Reboot 84 85 # Policy Initial Host State Expected Host State 86 LastState Running Running 87 88 89Test Restore Policy Restore Last State With Host Off After Reboot 90 [Documentation] Verify the RESTORE_LAST_STATE restore policy functionality while the Host is off 91 ... after BMC reboot. 92 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Off_After_Reboot 93 [Template] Verify Restore Policy After Reboot 94 95 # Policy Initial Host State Expected Host State 96 LastState Off Off 97 98 99*** Keywords *** 100 101Verify Restore Policy After Reboot 102 [Documentation] Set given policy, reset BMC and expect specified end 103 ... state. 104 [Arguments] ${policy} ${expectedState} ${nextState} 105 106 # Description of argument(s): 107 # policy System policy state string. 108 # expectedState Test initial host state. 109 # nextState Test end host state. 110 111 Set Initial Test State ${expectedState} 112 113 Redfish Set Power Restore Policy ${policy} 114 115 Redfish BMC Reset Operation 116 Sleep 20s 117 Wait For BMC Online 118 119 Wait Until Keyword Succeeds 120 ... 10 min 20 sec Valid Boot States ${nextState} 121 122 123Valid Boot States 124 [Documentation] Verify boot states for a given system state. 125 [Arguments] ${sys_state} 126 127 # Description of argument(s): 128 # sys_state system state list 129 # (e.g. "Off", "On", "Reboot", etc.). 130 131 ${current_state}= Redfish Get States 132 Redfish Valid Boot State ${sys_state} ${current_state} 133 134 135Set Initial Test State 136 [Documentation] Poweron if ON expected, Poweroff if OFF expected 137 ... to initial state of the test. 138 [Arguments] ${expectedState} 139 140 # Description of argument(s): 141 # expectedState Test initial host state. 142 143 Redfish.Login 144 145 IF '${expectedState}' == 'Running' 146 Redfish Power On stack_mode=skip 147 END 148 149 IF '${expectedState}' == 'Off' 150 Redfish Power Off stack_mode=skip 151 END 152 153 154Test Teardown Execution 155 [Documentation] Do the post test teardown. 156 157 FFDC On Test Case Fail 158 Close All Connections 159 160 161Suite Teardown Execution 162 [Documentation] Do the post suite teardown. 163 164 Run Keyword And Ignore Error Redfish Set Power Restore Policy AlwaysOn 165 Redfish.Logout 166 167 168Wait For BMC Online 169 [Documentation] Wait for Host to be online. Checks every X seconds 170 ... interval for Y minutes and fails if timed out. 171 ... Default MAX timedout is 10 min, interval 10 seconds. 172 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min 173 ... ${interval}=10 sec 174 175 # Description of argument(s): 176 # max_timeout Maximum time to wait. 177 # This should be expressed in Robot Framework's time format 178 # (e.g. "10 minutes"). 179 # interval Interval to wait between status checks. 180 # This should be expressed in Robot Framework's time format 181 # (e.g. "5 seconds"). 182 183 Wait Until Keyword Succeeds 184 ... ${max_timeout} ${interval} Verify Ping SSH And Redfish Authentication 185