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