blob: c424b5eb03684356d642a2337dbee13ceac03240 [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
Chris Austenb29d2e82016-06-07 12:25:35 -050015*** Test Cases ***
16
17Get OCC status
18 [Documentation] This testcase is to test the OCCstatus for the system
19 ... is Enabled or not
George Keishing9aa0f652016-11-08 03:28:56 -060020 [Tags] Get_OCC_status
Chris Austenb29d2e82016-06-07 12:25:35 -050021 ${status}= Get OCC status
22 Should Be Equal ${status} Enabled
23
24Set and Get PowerCap
25 [Documentation] This testcase is to test get/set powercap feature.
26 ... In the testcase we are reading min, max value and then
27 ... try set the random in that range.
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050028 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
29 [Tags] known_issue
30
Chris Austenb29d2e82016-06-07 12:25:35 -050031 ${min}= Get Minimum PowerCap
32 log ${min}
33 ${max}= Get Maximum PowerCap
34 log ${max}
35 ${rand_power_cap}= Evaluate random.randint(${min}, ${max}) modules=random
36 log ${rand_power_cap}
37 ${resp}= Set PowerCap ${rand_power_cap}
38 should be equal as strings ${resp.status_code} ${HTTP_OK}
39 Sleep ${DBUS_POLL_INTERVAL}
40 ${power_cap}= Get PowerCap
41 Should Be Equal ${power_cap} ${rand_power_cap}
42 ${user_power_cap}= Get User PowerCap
43 Should Be Equal ${user_power_cap} ${rand_power_cap}
44
45Set Less Than Minimum PowerCAP
46 [Documentation] Test set powercap with less than min powercap value
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050047 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
48 [Tags] known_issue
49
Chris Austenb29d2e82016-06-07 12:25:35 -050050 ${org_power_cap}= Get PowerCap
51 ${min}= Get Minimum PowerCap
52 ${sample_invalid_pcap}= Evaluate ${min}-${100}
53 ${resp}= Set PowerCap ${sample_invalid_pcap}
54 Sleep ${DBUS_POLL_INTERVAL}
55 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
56 ${power_cap}= Get PowerCap
57 Should Be Equal ${org_power_cap} ${power_cap}
58
59Set More Than Maximum PowerCAP
60 [Documentation] Test set powercap with more than max powercap value
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050061 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
62 [Tags] known_issue
63
Chris Austenb29d2e82016-06-07 12:25:35 -050064 ${org_power_cap}= Get PowerCap
65 ${min}= Get Maximum PowerCap
66 ${sample_invalid_pcap}= Evaluate ${min}+${100}
67 ${resp}= Set PowerCap ${sample_invalid_pcap}
68 Sleep ${DBUS_POLL_INTERVAL}
69 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
70 ${power_cap}= Get PowerCap
71 Should Be Equal ${org_power_cap} ${power_cap}
72
73Disable PowerCap
74 [Documentation] Test set powercap with 0 and make sure powercap is
75 ... disabled by checking whether the value is set to 0
Rahul Maheshwaribb20f732016-10-24 06:27:14 -050076 [Tags] Disable_PowerCap
77
Chris Austenb29d2e82016-06-07 12:25:35 -050078 ${resp}= Set PowerCap ${0}
79 should be equal as strings ${resp.status_code} ${HTTP_OK}
80 Sleep ${DBUS_POLL_INTERVAL}
81 ${power_cap}= Get PowerCap
82 Should Be Equal ${power_cap} ${0}
83 ${user_power_cap}= Get User PowerCap
84 Should Be Equal ${user_power_cap} ${0}
85
86Get System Power Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050087 [Documentation] Get the current system power consumption and check if the
Chris Austenb29d2e82016-06-07 12:25:35 -050088 ... value is greater than zero
George Keishing9aa0f652016-11-08 03:28:56 -060089 [Tags] Get_System_Power_Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050090
Gunnar Mills1cd544d2016-12-06 11:19:22 -060091 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/system_power
Chris Austenb29d2e82016-06-07 12:25:35 -050092 should be equal as strings ${resp.status_code} ${HTTP_OK}
93 ${jsondata}= To Json ${resp.content}
94 Should Be True ${jsondata["data"]["value"]} > 0
95
96*** Keywords ***
97
98Get Minimum PowerCap
Gunnar Mills1cd544d2016-12-06 11:19:22 -060099 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/min_cap
Chris Austenb29d2e82016-06-07 12:25:35 -0500100 ${jsondata}= To Json ${resp.content}
101 [return] ${jsondata["data"]["value"]}
102
103Get Maximum PowerCap
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600104 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/max_cap
Chris Austenb29d2e82016-06-07 12:25:35 -0500105 ${jsondata}= To Json ${resp.content}
106 [return] ${jsondata["data"]["value"]}
107
108Get User PowerCap
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600109 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/user_cap
Chris Austenb29d2e82016-06-07 12:25:35 -0500110 ${jsondata}= To Json ${resp.content}
111 [return] ${jsondata["data"]["value"]}
112
113Set PowerCap
114 [Arguments] ${powercap_value}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600115 @{pcap_list}= Create List ${powercap_value}
116 ${data}= create dictionary data=@{pcap_list}
117 ${resp}= openbmc post request /org/openbmc/sensors/host/powercap/action/setValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500118 [return] ${resp}
119
120Get PowerCap
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600121 ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/powercap
Chris Austenb29d2e82016-06-07 12:25:35 -0500122 ${jsondata}= To Json ${resp.content}
123 [return] ${jsondata["data"]["value"]}
124
125Get OCC status link
126 ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/list
127 ${jsondata}= To Json ${resp.content}
128 log ${jsondata}
129 : FOR ${ELEMENT} IN @{jsondata["data"]}
130 \ log ${ELEMENT}
131 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *host/cpu*/OccStatus
132 \ Return From Keyword If '${found}' != '' ${found}
133
134Get OCC status
135 ${occstatus_link}= Get OCC status link
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600136 ${data}= create dictionary data=@{EMPTY}
137 ${resp}= openbmc post request ${occstatus_link}/action/getValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500138 ${jsondata}= To Json ${resp.content}
139 [return] ${jsondata["data"]}
140
141Get Chassis URI
142 ${resp}= OpenBMC Get Request /org/openbmc/control/
143 ${jsondata}= To Json ${resp.content}
144 log ${jsondata}
145 : FOR ${ELEMENT} IN @{jsondata["data"]}
146 \ log ${ELEMENT}
147 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis*
148 \ Return From Keyword If '${found}' != '' ${found}
George Keishing1a2007e2016-09-15 12:16:11 -0500149
150
151Check OCC Readiness
152 [Documentation] Poweron If BMC power state is off. Check the OCC powercap
153 ... if the interface attributes are activated.
154
155 ${status}=
156 ... Run Keyword and Return Status Check Power Off States
157 Run Keyword If '${status}' == '${True}'
158 ... BMC Power On
159 Wait Until Keyword Succeeds 5min 10sec
160 ... Powercap Attributes Activated
161
162
163Powercap Attributes Activated
164 [Documentation] Verify if the response contains the pre-define list
165
166 @{precheck}= Create List /org/openbmc/sensors/powercap/user_cap
167 ... /org/openbmc/sensors/powercap/system_power
168 ... /org/openbmc/sensors/powercap/curr_cap
169 ... /org/openbmc/sensors/powercap/max_cap
170 ... /org/openbmc/sensors/powercap/min_cap
171
172 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/
173 ${jsondata}= To Json ${resp.content}
174 List Should Contain Sub List ${jsondata["data"]} ${precheck}
175 ... msg=Failed to activate powercap interface attributes
176