blob: 9383425de1939959791bd38e8a3c6363536d03a8 [file] [log] [blame]
Rahul Maheshwari07d91d22019-07-31 01:12:05 -05001*** Settings ***
2
3Documentation Module to test IPMI chassis functionality.
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
George Keishing6f395fd2021-08-18 02:18:53 -05006Resource ../lib/boot_utils.robot
Rahul Maheshwarif724a002020-02-21 05:17:02 -06007Library ../lib/ipmi_utils.py
chithragf4595402022-03-30 16:35:03 +00008Variables ../data/ipmi_raw_cmd_table.py
Rahul Maheshwari07d91d22019-07-31 01:12:05 -05009
George Keishing2d0edad2021-08-18 11:44:10 -050010Suite Setup Redfish.Login
11Suite Teardown Redfish.Logout
chithragf4595402022-03-30 16:35:03 +000012Test Teardown Test Teardown Execution
13
George Keishingf6280172022-07-08 01:51:27 -050014*** Variables ***
15
16# Timeout value in minutes. Default 3 minutes.
17${IPMI_POWEROFF_WAIT_TIMEOUT} 3
Rahul Maheshwari07d91d22019-07-31 01:12:05 -050018
19*** Test Cases ***
20
21IPMI Chassis Status On
22 [Documentation] This test case verfies system power on status
23 ... using IPMI Get Chassis status command.
24 [Tags] IPMI_Chassis_Status_On
25
26 Redfish Power On stack_mode=skip quiet=1
27 ${resp}= Run IPMI Standard Command chassis status
28 ${power_status}= Get Lines Containing String ${resp} System Power
29 Should Contain ${power_status} on
30
31IPMI Chassis Status Off
32 [Documentation] This test case verfies system power off status
33 ... using IPMI Get Chassis status command.
34 [Tags] IPMI_Chassis_Status_Off
35
36 Redfish Power Off stack_mode=skip quiet=1
37 ${resp}= Run IPMI Standard Command chassis status
38 ${power_status}= Get Lines Containing String ${resp} System Power
39 Should Contain ${power_status} off
Sushma M M1cc21272020-01-05 23:47:46 -060040
41Verify Host PowerOff Via IPMI
42 [Documentation] Verify host power off operation using external IPMI command.
43 [Tags] Verify_Host_PowerOff_Via_IPMI
44
45 IPMI Power Off
46 ${ipmi_state}= Get Host State Via External IPMI
47 Valid Value ipmi_state ['off']
48
49Verify Host PowerOn Via IPMI
50 [Documentation] Verify host power on operation using external IPMI command.
51 [Tags] Verify_Host_PowerOn_Via_IPMI
52
53 IPMI Power On
54 ${ipmi_state}= Get Host State Via External IPMI
Rahul Maheshwari460778d2020-02-23 22:37:22 -060055 Valid Value ipmi_state ['on']
56
57
58Verify Soft Shutdown
59 [Documentation] Verify host OS shutdown softly via IPMI command.
George Keishingfba5ad92021-11-08 02:52:35 -060060 [Tags] Verify_Soft_Shutdown
Rahul Maheshwari460778d2020-02-23 22:37:22 -060061
62 Redfish Power On stack_mode=skip
63 Run IPMI Standard Command chassis power soft
George Keishingf6280172022-07-08 01:51:27 -050064 Wait Until Keyword Succeeds ${IPMI_POWEROFF_WAIT_TIMEOUT} min 10 sec Is Host Off Via IPMI
Rahul Maheshwari460778d2020-02-23 22:37:22 -060065
Rahul Maheshwarif724a002020-02-21 05:17:02 -060066
chithragf4595402022-03-30 16:35:03 +000067Verify Chassis Power Cycle And Check Chassis Status Via IPMI
George Keishing6e641262022-05-05 10:46:22 -050068 [Documentation] Verify chassis power Cycle operation and check the Chassis
69 ... Power Status using external IPMI command.
chithragf4595402022-03-30 16:35:03 +000070 [Tags] Verify_Chassis_Power_Cycle_And_Check_Chassis_Status_Via_IPMI
71
72 # Chassis power cycle command via IPMI
73 IPMI Power Cycle
74 ${ipmi_state}= Get Host State Via External IPMI
75 Valid Value ipmi_state ['on']
76
77
78Verify Chassis Power Reset And Check Chassis Status Via IPMI
George Keishing6e641262022-05-05 10:46:22 -050079 [Documentation] Verify chassis power Reset operation and check the Chassis
80 ... Power Status using external IPMI command.
chithragf4595402022-03-30 16:35:03 +000081 [Tags] Verify_Chassis_Power_Reset_And_Check_Chassis_Status_Via_IPMI
82
83 # Chassis power reset command via IPMI
84 IPMI Power Reset
85 ${ipmi_state}= Get Host State Via External IPMI
86 Valid Value ipmi_state ['on']
87
88
Rahul Maheshwarif724a002020-02-21 05:17:02 -060089Verify Chassis Power Policy
90 [Documentation] Verify setting chassis power policy via IPMI command.
91 [Tags] Verify_Chassis_Power_Policy
92 [Setup] Test Setup Execution
93 [Teardown] Run Keywords FFDC On Test Case Fail AND
94 ... Run IPMI Standard Command chassis policy ${initial_power_policy}
95 [Template] Set Chassis Power Policy Via IPMI And Verify
96
97 # power_policy
98 always-off
99 always-on
100 previous
101
102
chithragf4595402022-03-30 16:35:03 +0000103Verify Chassis Status Via IPMI
104 [Documentation] Verify Chassis Status via IPMI command.
105 [Tags] Verify_Chassis_Status_Via_IPMI
106 [Setup] Test Setup Execution
107 [Teardown] Run Keywords FFDC On Test Case Fail AND
108 ... Run IPMI Standard Command chassis policy ${initial_power_policy}
109 [Template] Check Chassis Status Via IPMI
110
111 # power_policy
112 always-off
113 always-on
114 previous
115
116
Rahul Maheshwarif724a002020-02-21 05:17:02 -0600117*** Keywords ***
118
119Set Chassis Power Policy Via IPMI And Verify
120 [Documentation] Set chasiss power policy via IPMI and verify.
121 [Arguments] ${power_policy}
122
123 # Description of argument(s):
124 # power_policy Chassis power policy to be set(e.g. "always-off", "always-on").
125
126 Run IPMI Standard Command chassis policy ${power_policy}
127 ${resp}= Get Chassis Status
128 Valid Value resp['power_restore_policy'] ['${power_policy}']
129
130
chithragf4595402022-03-30 16:35:03 +0000131Check Chassis Status Via IPMI
132 [Documentation] Set Chassis Status via IPMI and verify and verify chassis status.
133 [Arguments] ${power_policy}
134
135 # Sets power policy according to requested policy
136 Set Chassis Power Policy Via IPMI And Verify ${power_policy}
137
138 # Gets chassis status via IPMI raw command and validate byte 1
139 ${status}= Run External IPMI Raw Command ${IPMI_RAW_CMD['Chassis_status']['get'][0]}
140 ${status}= Split String ${status}
141 ${state}= Convert To Binary ${status[0]} base=16
142 ${state}= Zfill Data ${state} 8
143
144 # Last bit corresponds whether Power is on
145 Should Be Equal As Strings ${state[-1]} 1
146 # bit 1-2 corresponds to power restore policy
147 ${policy}= Set Variable ${state[1:3]}
148
149 # condition to verify each power policy
150 IF '${power_policy}' == 'always-off'
151 Should Be Equal As Strings ${policy} 00
152 ELSE IF '${power_policy}' == 'always-on'
153 Should Be Equal As Strings ${policy} 10
154 ELSE IF '${power_policy}' == 'previous'
155 Should Be Equal As Strings ${policy} 01
156 ELSE
157 Log Power Restore Policy is Unknown
158 Should Be Equal As Strings ${policy} 11
159 END
160
161 # Last Power Event - 4th bit should be 1b i.e, last ‘Power is on’ state was entered via IPMI command
162 ${last_power_event}= Convert To Binary ${status[1]} base=16
163 ${last_power_event}= Zfill Data ${last_power_event} 8
164 Should Be Equal As Strings ${last_power_event[3]} 1
165
166
Rahul Maheshwarif724a002020-02-21 05:17:02 -0600167Test Setup Execution
168 [Documentation] Do test setup tasks.
169
170 ${chassis_status}= Get Chassis Status
171 Set Test Variable ${initial_power_policy} ${chassis_status['power_restore_policy']}
172
chithragf4595402022-03-30 16:35:03 +0000173
174Test Teardown Execution
175 [Documentation] Do Test Teardown tasks.
176
177 ${resp}= Run IPMI Standard Command chassis status
178 ${power_status}= Get Lines Containing String ${resp} System Power
179 @{powertolist}= Split String ${power_status} :
180 ${status}= Get From List ${powertolist} 1
181 # Chassis Power ON if status is off
182 Run Keyword If '${status.strip()}' != 'on'
183 ... Redfish Power On
184 FFDC On Test Case Fail