Energy scale: test REST interface
Add REST utilities to the library and verify the
escale REST interfaces.
Resolves openbmc/openbmc-test-automation#1153
Change-Id: Id5d0f69862c1c62c5f320cb7199e60ff576f82d1
Signed-off-by: Steven Sombar <ssombar@us.ibm.com>
diff --git a/lib/energy_scale_utils.robot b/lib/energy_scale_utils.robot
index a2f85fd..5a15810 100755
--- a/lib/energy_scale_utils.robot
+++ b/lib/energy_scale_utils.robot
@@ -90,6 +90,71 @@
... msg=DCMI power is not deactivated.
+Get DCMI Power Limit Via REST
+ [Documentation] Return the system's current DCMI power_limit
+ ... watts setting using REST interface.
+
+ ${power_limit}= Read Attribute ${CONTROL_HOST_URI}power_cap PowerCap
+ [Return] ${power_limit}
+
+
+Set DCMI Power Limit Via REST
+ [Documentation] Set system power limit via REST command.
+ [Arguments] ${power_limit} ${verify}=${True}
+
+ # Description of argument(s):
+ # power_limit The power limit in watts.
+ # verify If True, read the power setting to confirm.
+
+ ${data}= Create Dictionary data=${power_limit}
+ Write Attribute ${CONTROL_HOST_URI}power_cap PowerCap data=${data}
+ Return From Keyword If ${verify} == ${False}
+ ${power}= Read Attribute ${CONTROL_HOST_URI}power_cap PowerCap
+ Should Be True ${power} == ${power_limit}
+ ... msg=Failed setting power limit to ${power_limit} watts via REST.
+
+
+Activate DCMI Power Via REST
+ [Documentation] Activate DCMI power limiting via REST.
+ [Arguments] ${verify}=${True}
+
+ # Description of argument(s):
+ # verify If True, read the setting to confirm.
+
+ ${data}= Create Dictionary data=${True}
+ Write Attribute ${CONTROL_HOST_URI}power_cap PowerCapEnable
+ ... data=${data}
+ Return From Keyword If ${verify} == ${False}
+ ${setting}= Get DCMI Power Acivation Via REST
+ Should Be True ${setting} == ${1}
+ ... msg=Failed to activate power limiting via REST.
+
+
+Deactivate DCMI Power Via REST
+ [Documentation] Deactivate DCMI power limiting via REST.
+ [Arguments] ${verify}=${True}
+
+ # Description of argument(s):
+ # verify If True, read the setting to confirm.
+
+ ${data}= Create Dictionary data=${False}
+ Write Attribute ${CONTROL_HOST_URI}power_cap PowerCapEnable
+ ... data=${data}
+ Return From Keyword If ${verify} == ${False}
+ ${setting}= Get DCMI Power Acivation Via REST
+ Should Be True ${setting} == ${0}
+ ... msg=Failed to deactivate power limiting via REST.
+
+
+Get DCMI Power Acivation Via REST
+ [Documentation] Return the system's current DCMI power activation
+ ... state setting using REST interface.
+
+ ${power_activation_setting}= Read Attribute
+ ... ${CONTROL_HOST_URI}power_cap PowerCapEnable
+ [Return] ${power_activation_setting}
+
+
OCC Tool Upload Setup
[Documentation] Upload occtoolp9 to /tmp on the OS.
diff --git a/tests/test_escale_base.robot b/tests/test_escale_base.robot
index 51e08eb..4907ae2 100755
--- a/tests/test_escale_base.robot
+++ b/tests/test_escale_base.robot
@@ -23,11 +23,10 @@
${min_power} 500
${below_min_power} 499
${zero_power} 0
-# The power limits are documented at
+# The power limits shown above are documented at
# open-power/witherspoon-xml/master/witherspoon.xml.
-
*** Test Cases ***
@@ -40,13 +39,62 @@
Escale Base Test Active Monitoring
- [Documentation] Run base power tests with DCMI power montoring on.
+ [Documentation] Run base power tests with DCMI power monitoring on.
[Tags] Escale_Base_Test_Active_Monitoring
Activate DCMI Power And Verify
Verify Power Limits
+Escale Power Setting Via REST And Verify
+ [Documentation] Set power via REST and check using IPMI.
+ [Tags] Escale_Power_Setting_Via_REST_And_Verify
+
+ # A convenient power level bewtwwn maximum and minimum.
+ ${test_power}= Set Variable 1700
+
+ # Set the power limit via REST.
+ Set DCMI Power Limit Via REST ${test_power}
+
+ # Read the power limit using IPMI.
+ ${power_limit}= Get DCMI Power Limit
+ Should Be True ${power_limit} == ${test_power}
+ ... msg=Reading Power limit with IPMI failed after setting it with REST.
+
+
+Escale Power Setting Via IPMI And Verify
+ [Documentation] Set power via IPMI then check via REST.
+ [Tags] Escale_Power_Setting_Via_IPMI_And_Verify
+
+ # A convenient power level bewtwwn maximum and minimum.
+ ${test_power}= Set Variable 2200
+
+ # Set DCMI Power via IPMI.
+ Set DCMI Power Limit And Verify ${test_power}
+
+ # Read the limit via REST.
+ ${power_limit}= Get DCMI Power Limit Via REST
+ Should Be True ${power_limit} == ${test_power}
+ ... msg=Reading power limit with REST failed after setting it with IPMI.
+
+
+Escale Activation Test Via REST
+ [Documentation] Activate power monitoring via REST then check via IPMI.
+ [Tags] Escale_Activation_Test_Via_REST
+
+ Activate DCMI Power Via REST
+ # Confirm activation state using IPMI.
+ Fail If DCMI Power Is Not Activated
+
+
+Escale Dectivation Test Via REST
+ [Documentation] Deactivate power monitoring via REST and check via IPMI.
+ [Tags] Escale_Deactivation_Test_Via_REST
+
+ Deactivate DCMI Power Via REST
+ # Confirm activation state using IPMI.
+ Fail If DCMI Power Is Not Deactivated
+
*** Keywords ***