blob: 31471f953407a9b59a606ef974a0ed741f715539 [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
11Test Teardown Log FFDC
Chris Austenb29d2e82016-06-07 12:25:35 -050012
13*** Test Cases ***
14
15Get OCC status
16 [Documentation] This testcase is to test the OCCstatus for the system
17 ... is Enabled or not
18 ${status}= Get OCC status
19 Should Be Equal ${status} Enabled
20
21Set and Get PowerCap
22 [Documentation] This testcase is to test get/set powercap feature.
23 ... In the testcase we are reading min, max value and then
24 ... try set the random in that range.
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050025 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
26 [Tags] known_issue
27
Chris Austenb29d2e82016-06-07 12:25:35 -050028 ${min}= Get Minimum PowerCap
29 log ${min}
30 ${max}= Get Maximum PowerCap
31 log ${max}
32 ${rand_power_cap}= Evaluate random.randint(${min}, ${max}) modules=random
33 log ${rand_power_cap}
34 ${resp}= Set PowerCap ${rand_power_cap}
35 should be equal as strings ${resp.status_code} ${HTTP_OK}
36 Sleep ${DBUS_POLL_INTERVAL}
37 ${power_cap}= Get PowerCap
38 Should Be Equal ${power_cap} ${rand_power_cap}
39 ${user_power_cap}= Get User PowerCap
40 Should Be Equal ${user_power_cap} ${rand_power_cap}
41
42Set Less Than Minimum PowerCAP
43 [Documentation] Test set powercap with less than min powercap value
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050044 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
45 [Tags] known_issue
46
Chris Austenb29d2e82016-06-07 12:25:35 -050047 ${org_power_cap}= Get PowerCap
48 ${min}= Get Minimum PowerCap
49 ${sample_invalid_pcap}= Evaluate ${min}-${100}
50 ${resp}= Set PowerCap ${sample_invalid_pcap}
51 Sleep ${DBUS_POLL_INTERVAL}
52 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
53 ${power_cap}= Get PowerCap
54 Should Be Equal ${org_power_cap} ${power_cap}
55
56Set More Than Maximum PowerCAP
57 [Documentation] Test set powercap with more than max powercap value
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050058 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
59 [Tags] known_issue
60
Chris Austenb29d2e82016-06-07 12:25:35 -050061 ${org_power_cap}= Get PowerCap
62 ${min}= Get Maximum PowerCap
63 ${sample_invalid_pcap}= Evaluate ${min}+${100}
64 ${resp}= Set PowerCap ${sample_invalid_pcap}
65 Sleep ${DBUS_POLL_INTERVAL}
66 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
67 ${power_cap}= Get PowerCap
68 Should Be Equal ${org_power_cap} ${power_cap}
69
70Disable PowerCap
71 [Documentation] Test set powercap with 0 and make sure powercap is
72 ... disabled by checking whether the value is set to 0
73 ${resp}= Set PowerCap ${0}
74 should be equal as strings ${resp.status_code} ${HTTP_OK}
75 Sleep ${DBUS_POLL_INTERVAL}
76 ${power_cap}= Get PowerCap
77 Should Be Equal ${power_cap} ${0}
78 ${user_power_cap}= Get User PowerCap
79 Should Be Equal ${user_power_cap} ${0}
80
81Get System Power Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050082 [Documentation] Get the current system power consumption and check if the
Chris Austenb29d2e82016-06-07 12:25:35 -050083 ... value is greater than zero
George Keishing1a2007e2016-09-15 12:16:11 -050084
Chris Austenb29d2e82016-06-07 12:25:35 -050085 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/system_power
86 should be equal as strings ${resp.status_code} ${HTTP_OK}
87 ${jsondata}= To Json ${resp.content}
88 Should Be True ${jsondata["data"]["value"]} > 0
89
90*** Keywords ***
91
92Get Minimum PowerCap
93 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/min_cap
94 ${jsondata}= To Json ${resp.content}
95 [return] ${jsondata["data"]["value"]}
96
97Get Maximum PowerCap
98 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/max_cap
99 ${jsondata}= To Json ${resp.content}
100 [return] ${jsondata["data"]["value"]}
101
102Get User PowerCap
103 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/user_cap
104 ${jsondata}= To Json ${resp.content}
105 [return] ${jsondata["data"]["value"]}
106
107Set PowerCap
108 [Arguments] ${powercap_value}
109 @{pcap_list} = Create List ${powercap_value}
110 ${data} = create dictionary data=@{pcap_list}
George Keishing1a2007e2016-09-15 12:16:11 -0500111 ${resp} = openbmc post request /org/openbmc/sensors/host/powercap/action/setValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500112 [return] ${resp}
113
114Get PowerCap
George Keishing1a2007e2016-09-15 12:16:11 -0500115 ${resp} = OpenBMC Get Request /org/openbmc/sensors/host/powercap
Chris Austenb29d2e82016-06-07 12:25:35 -0500116 ${jsondata}= To Json ${resp.content}
117 [return] ${jsondata["data"]["value"]}
118
119Get OCC status link
120 ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/list
121 ${jsondata}= To Json ${resp.content}
122 log ${jsondata}
123 : FOR ${ELEMENT} IN @{jsondata["data"]}
124 \ log ${ELEMENT}
125 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *host/cpu*/OccStatus
126 \ Return From Keyword If '${found}' != '' ${found}
127
128Get OCC status
129 ${occstatus_link}= Get OCC status link
130 ${data} = create dictionary data=@{EMPTY}
131 ${resp} = openbmc post request ${occstatus_link}/action/getValue data=${data}
132 ${jsondata}= To Json ${resp.content}
133 [return] ${jsondata["data"]}
134
135Get Chassis URI
136 ${resp}= OpenBMC Get Request /org/openbmc/control/
137 ${jsondata}= To Json ${resp.content}
138 log ${jsondata}
139 : FOR ${ELEMENT} IN @{jsondata["data"]}
140 \ log ${ELEMENT}
141 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis*
142 \ Return From Keyword If '${found}' != '' ${found}
George Keishing1a2007e2016-09-15 12:16:11 -0500143
144
145Check OCC Readiness
146 [Documentation] Poweron If BMC power state is off. Check the OCC powercap
147 ... if the interface attributes are activated.
148
149 ${status}=
150 ... Run Keyword and Return Status Check Power Off States
151 Run Keyword If '${status}' == '${True}'
152 ... BMC Power On
153 Wait Until Keyword Succeeds 5min 10sec
154 ... Powercap Attributes Activated
155
156
157Powercap Attributes Activated
158 [Documentation] Verify if the response contains the pre-define list
159
160 @{precheck}= Create List /org/openbmc/sensors/powercap/user_cap
161 ... /org/openbmc/sensors/powercap/system_power
162 ... /org/openbmc/sensors/powercap/curr_cap
163 ... /org/openbmc/sensors/powercap/max_cap
164 ... /org/openbmc/sensors/powercap/min_cap
165
166 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/
167 ${jsondata}= To Json ${resp.content}
168 List Should Contain Sub List ${jsondata["data"]} ${precheck}
169 ... msg=Failed to activate powercap interface attributes
170