Added testcases for IPMI power cycle, power reset and chassis status.
Testcases :
- Verify Chassis Power Cycle And Check Chassis Status Via IPMI
- Verify Chassis Power Reset And Check Chassis Status Via IPMI
- Verify Chassis Status Via IPMI
Request data for chassis status present in data/ipmi_raw_cmd_table.py
Verify Chassis Power Cycle And Check Chassis Status Via IPMI - Executes IPMI Chassis power cycle and verifies the chassis status using IPMI command.
Verify Chassis Power Reset And Check Chassis Status Via IPMI - Executes IPMI Chassis power reset and verifies the chassis status using IPMI command.
Verify Chassis Status Via IPMI - Sets chassis power policy and verifies the power policy status via IPMI chassis status raw command. Also verifies the last ‘Power is on’ state was entered via IPMI command bit in Last Power Event byte of IPMI raw chassis status.
Tested: Run robot ipmi/test_ipmi_chassis.robot
Signed-off-by: chithrag <chithrag@ami.com>
Change-Id: I86a7a8ced16738f0846bddc76eb5df2ee654d4cc
diff --git a/ipmi/test_ipmi_chassis.robot b/ipmi/test_ipmi_chassis.robot
index 91f6afe..880283b 100644
--- a/ipmi/test_ipmi_chassis.robot
+++ b/ipmi/test_ipmi_chassis.robot
@@ -5,10 +5,12 @@
Resource ../lib/openbmc_ffdc.robot
Resource ../lib/boot_utils.robot
Library ../lib/ipmi_utils.py
+Variables ../data/ipmi_raw_cmd_table.py
Suite Setup Redfish.Login
Suite Teardown Redfish.Logout
-Test Teardown FFDC On Test Case Fail
+Test Teardown Test Teardown Execution
+
*** Test Cases ***
@@ -58,6 +60,26 @@
Wait Until Keyword Succeeds 3 min 10 sec Is Host Off Via IPMI
+Verify Chassis Power Cycle And Check Chassis Status Via IPMI
+ [Documentation] Verify chassis power Cycle operation and check the Chassis Power Status using external IPMI command.
+ [Tags] Verify_Chassis_Power_Cycle_And_Check_Chassis_Status_Via_IPMI
+
+ # Chassis power cycle command via IPMI
+ IPMI Power Cycle
+ ${ipmi_state}= Get Host State Via External IPMI
+ Valid Value ipmi_state ['on']
+
+
+Verify Chassis Power Reset And Check Chassis Status Via IPMI
+ [Documentation] Verify chassis power Reset operation and check the Chassis Power Status using external IPMI command.
+ [Tags] Verify_Chassis_Power_Reset_And_Check_Chassis_Status_Via_IPMI
+
+ # Chassis power reset command via IPMI
+ IPMI Power Reset
+ ${ipmi_state}= Get Host State Via External IPMI
+ Valid Value ipmi_state ['on']
+
+
Verify Chassis Power Policy
[Documentation] Verify setting chassis power policy via IPMI command.
[Tags] Verify_Chassis_Power_Policy
@@ -72,6 +94,20 @@
previous
+Verify Chassis Status Via IPMI
+ [Documentation] Verify Chassis Status via IPMI command.
+ [Tags] Verify_Chassis_Status_Via_IPMI
+ [Setup] Test Setup Execution
+ [Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Run IPMI Standard Command chassis policy ${initial_power_policy}
+ [Template] Check Chassis Status Via IPMI
+
+ # power_policy
+ always-off
+ always-on
+ previous
+
+
*** Keywords ***
Set Chassis Power Policy Via IPMI And Verify
@@ -86,9 +122,57 @@
Valid Value resp['power_restore_policy'] ['${power_policy}']
+Check Chassis Status Via IPMI
+ [Documentation] Set Chassis Status via IPMI and verify and verify chassis status.
+ [Arguments] ${power_policy}
+
+ # Sets power policy according to requested policy
+ Set Chassis Power Policy Via IPMI And Verify ${power_policy}
+
+ # Gets chassis status via IPMI raw command and validate byte 1
+ ${status}= Run External IPMI Raw Command ${IPMI_RAW_CMD['Chassis_status']['get'][0]}
+ ${status}= Split String ${status}
+ ${state}= Convert To Binary ${status[0]} base=16
+ ${state}= Zfill Data ${state} 8
+
+ # Last bit corresponds whether Power is on
+ Should Be Equal As Strings ${state[-1]} 1
+ # bit 1-2 corresponds to power restore policy
+ ${policy}= Set Variable ${state[1:3]}
+
+ # condition to verify each power policy
+ IF '${power_policy}' == 'always-off'
+ Should Be Equal As Strings ${policy} 00
+ ELSE IF '${power_policy}' == 'always-on'
+ Should Be Equal As Strings ${policy} 10
+ ELSE IF '${power_policy}' == 'previous'
+ Should Be Equal As Strings ${policy} 01
+ ELSE
+ Log Power Restore Policy is Unknown
+ Should Be Equal As Strings ${policy} 11
+ END
+
+ # Last Power Event - 4th bit should be 1b i.e, last ‘Power is on’ state was entered via IPMI command
+ ${last_power_event}= Convert To Binary ${status[1]} base=16
+ ${last_power_event}= Zfill Data ${last_power_event} 8
+ Should Be Equal As Strings ${last_power_event[3]} 1
+
+
Test Setup Execution
[Documentation] Do test setup tasks.
${chassis_status}= Get Chassis Status
Set Test Variable ${initial_power_policy} ${chassis_status['power_restore_policy']}
+
+Test Teardown Execution
+ [Documentation] Do Test Teardown tasks.
+
+ ${resp}= Run IPMI Standard Command chassis status
+ ${power_status}= Get Lines Containing String ${resp} System Power
+ @{powertolist}= Split String ${power_status} :
+ ${status}= Get From List ${powertolist} 1
+ # Chassis Power ON if status is off
+ Run Keyword If '${status.strip()}' != 'on'
+ ... Redfish Power On
+ FFDC On Test Case Fail