blob: e5ce8f07d41adf2587b3f06485aebc2e5385418b [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite is for testing OCC: Power capping setting
3
4Resource ../lib/rest_client.robot
5Resource ../lib/resource.txt
6Resource ../lib/utils.robot
George Keishingd55a4be2016-08-26 03:28:17 -05007Resource ../lib/openbmc_ffdc.robot
George Keishing1a2007e2016-09-15 12:16:11 -05008Resource ../lib/boot/boot_resource_master.robot
Chris Austenb29d2e82016-06-07 12:25:35 -05009
George Keishing1a2007e2016-09-15 12:16:11 -050010Suite Setup Check OCC Readiness
Gunnar Millseac1af22016-11-14 15:30:09 -060011Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -050012
George Keishing9aa0f652016-11-08 03:28:56 -060013Force Tags powercapping
14
George Keishingab1bd922016-12-05 05:29:59 -060015*** Variables ***
16
Chris Austenb29d2e82016-06-07 12:25:35 -050017*** Test Cases ***
18
19Get OCC status
20 [Documentation] This testcase is to test the OCCstatus for the system
21 ... is Enabled or not
George Keishing9aa0f652016-11-08 03:28:56 -060022 [Tags] Get_OCC_status
Chris Austenb29d2e82016-06-07 12:25:35 -050023 ${status}= Get OCC status
24 Should Be Equal ${status} Enabled
25
26Set and Get PowerCap
27 [Documentation] This testcase is to test get/set powercap feature.
28 ... In the testcase we are reading min, max value and then
29 ... try set the random in that range.
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050030 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
31 [Tags] known_issue
32
Chris Austenb29d2e82016-06-07 12:25:35 -050033 ${min}= Get Minimum PowerCap
34 log ${min}
35 ${max}= Get Maximum PowerCap
36 log ${max}
37 ${rand_power_cap}= Evaluate random.randint(${min}, ${max}) modules=random
38 log ${rand_power_cap}
39 ${resp}= Set PowerCap ${rand_power_cap}
40 should be equal as strings ${resp.status_code} ${HTTP_OK}
41 Sleep ${DBUS_POLL_INTERVAL}
42 ${power_cap}= Get PowerCap
43 Should Be Equal ${power_cap} ${rand_power_cap}
44 ${user_power_cap}= Get User PowerCap
45 Should Be Equal ${user_power_cap} ${rand_power_cap}
46
47Set Less Than Minimum PowerCAP
48 [Documentation] Test set powercap with less than min powercap value
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050049 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
50 [Tags] known_issue
51
Chris Austenb29d2e82016-06-07 12:25:35 -050052 ${org_power_cap}= Get PowerCap
53 ${min}= Get Minimum PowerCap
54 ${sample_invalid_pcap}= Evaluate ${min}-${100}
55 ${resp}= Set PowerCap ${sample_invalid_pcap}
56 Sleep ${DBUS_POLL_INTERVAL}
57 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
58 ${power_cap}= Get PowerCap
59 Should Be Equal ${org_power_cap} ${power_cap}
60
61Set More Than Maximum PowerCAP
62 [Documentation] Test set powercap with more than max powercap value
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050063 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
64 [Tags] known_issue
65
Chris Austenb29d2e82016-06-07 12:25:35 -050066 ${org_power_cap}= Get PowerCap
67 ${min}= Get Maximum PowerCap
68 ${sample_invalid_pcap}= Evaluate ${min}+${100}
69 ${resp}= Set PowerCap ${sample_invalid_pcap}
70 Sleep ${DBUS_POLL_INTERVAL}
71 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
72 ${power_cap}= Get PowerCap
73 Should Be Equal ${org_power_cap} ${power_cap}
74
75Disable PowerCap
76 [Documentation] Test set powercap with 0 and make sure powercap is
77 ... disabled by checking whether the value is set to 0
Rahul Maheshwaribb20f732016-10-24 06:27:14 -050078 [Tags] Disable_PowerCap
79
Chris Austenb29d2e82016-06-07 12:25:35 -050080 ${resp}= Set PowerCap ${0}
81 should be equal as strings ${resp.status_code} ${HTTP_OK}
82 Sleep ${DBUS_POLL_INTERVAL}
83 ${power_cap}= Get PowerCap
84 Should Be Equal ${power_cap} ${0}
85 ${user_power_cap}= Get User PowerCap
86 Should Be Equal ${user_power_cap} ${0}
87
88Get System Power Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050089 [Documentation] Get the current system power consumption and check if the
Chris Austenb29d2e82016-06-07 12:25:35 -050090 ... value is greater than zero
George Keishing9aa0f652016-11-08 03:28:56 -060091 [Tags] Get_System_Power_Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050092
George Keishingab1bd922016-12-05 05:29:59 -060093 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/system_power
Chris Austenb29d2e82016-06-07 12:25:35 -050094 should be equal as strings ${resp.status_code} ${HTTP_OK}
95 ${jsondata}= To Json ${resp.content}
96 Should Be True ${jsondata["data"]["value"]} > 0
97
98*** Keywords ***
99
100Get Minimum PowerCap
George Keishingab1bd922016-12-05 05:29:59 -0600101 ${resp}= OpenBMC Get Request
102 ... ${SENSORS_URI}powercap/min_cap
Chris Austenb29d2e82016-06-07 12:25:35 -0500103 ${jsondata}= To Json ${resp.content}
104 [return] ${jsondata["data"]["value"]}
105
106Get Maximum PowerCap
George Keishingab1bd922016-12-05 05:29:59 -0600107 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/max_cap
Chris Austenb29d2e82016-06-07 12:25:35 -0500108 ${jsondata}= To Json ${resp.content}
109 [return] ${jsondata["data"]["value"]}
110
111Get User PowerCap
George Keishingab1bd922016-12-05 05:29:59 -0600112 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/user_cap
Chris Austenb29d2e82016-06-07 12:25:35 -0500113 ${jsondata}= To Json ${resp.content}
114 [return] ${jsondata["data"]["value"]}
115
116Set PowerCap
117 [Arguments] ${powercap_value}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600118 @{pcap_list}= Create List ${powercap_value}
119 ${data}= create dictionary data=@{pcap_list}
George Keishingab1bd922016-12-05 05:29:59 -0600120 ${resp}= openbmc post request
121 ... ${SENSORS_URI}host/powercap/action/setValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500122 [return] ${resp}
123
124Get PowerCap
George Keishingab1bd922016-12-05 05:29:59 -0600125 ${resp}= OpenBMC Get Request
126 ... ${SENSORS_URI}host/powercap
Chris Austenb29d2e82016-06-07 12:25:35 -0500127 ${jsondata}= To Json ${resp.content}
128 [return] ${jsondata["data"]["value"]}
129
130Get OCC status link
George Keishingab1bd922016-12-05 05:29:59 -0600131 ${resp}= OpenBMC Get Request
132 ... ${SENSORS_URI}host/list
Chris Austenb29d2e82016-06-07 12:25:35 -0500133 ${jsondata}= To Json ${resp.content}
134 log ${jsondata}
135 : FOR ${ELEMENT} IN @{jsondata["data"]}
136 \ log ${ELEMENT}
137 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *host/cpu*/OccStatus
138 \ Return From Keyword If '${found}' != '' ${found}
139
140Get OCC status
141 ${occstatus_link}= Get OCC status link
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600142 ${data}= create dictionary data=@{EMPTY}
143 ${resp}= openbmc post request ${occstatus_link}/action/getValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500144 ${jsondata}= To Json ${resp.content}
145 [return] ${jsondata["data"]}
146
147Get Chassis URI
George Keishingab1bd922016-12-05 05:29:59 -0600148 ${resp}= OpenBMC Get Request ${OPENBMC_BASE_URI}control/
Chris Austenb29d2e82016-06-07 12:25:35 -0500149 ${jsondata}= To Json ${resp.content}
150 log ${jsondata}
151 : FOR ${ELEMENT} IN @{jsondata["data"]}
152 \ log ${ELEMENT}
153 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis*
154 \ Return From Keyword If '${found}' != '' ${found}
George Keishing1a2007e2016-09-15 12:16:11 -0500155
156
157Check OCC Readiness
158 [Documentation] Poweron If BMC power state is off. Check the OCC powercap
159 ... if the interface attributes are activated.
160
161 ${status}=
162 ... Run Keyword and Return Status Check Power Off States
163 Run Keyword If '${status}' == '${True}'
164 ... BMC Power On
165 Wait Until Keyword Succeeds 5min 10sec
166 ... Powercap Attributes Activated
167
168
169Powercap Attributes Activated
170 [Documentation] Verify if the response contains the pre-define list
171
George Keishingab1bd922016-12-05 05:29:59 -0600172 @{precheck}= Create List ${SENSORS_URI}powercap/user_cap
173 ... ${SENSORS_URI}powercap/system_power
174 ... ${SENSORS_URI}powercap/curr_cap
175 ... ${SENSORS_URI}powercap/max_cap
176 ... ${SENSORS_URI}powercap/min_cap
George Keishing1a2007e2016-09-15 12:16:11 -0500177
George Keishingab1bd922016-12-05 05:29:59 -0600178 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/
George Keishing1a2007e2016-09-15 12:16:11 -0500179 ${jsondata}= To Json ${resp.content}
180 List Should Contain Sub List ${jsondata["data"]} ${precheck}
181 ... msg=Failed to activate powercap interface attributes
182