blob: 3cc7b64fba7cb7a6b8c294bb63b10ce454855d05 [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
Rahul Maheshwaribb20f732016-10-24 06:27:14 -050073 [Tags] Disable_PowerCap
74
Chris Austenb29d2e82016-06-07 12:25:35 -050075 ${resp}= Set PowerCap ${0}
76 should be equal as strings ${resp.status_code} ${HTTP_OK}
77 Sleep ${DBUS_POLL_INTERVAL}
78 ${power_cap}= Get PowerCap
79 Should Be Equal ${power_cap} ${0}
80 ${user_power_cap}= Get User PowerCap
81 Should Be Equal ${user_power_cap} ${0}
82
83Get System Power Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050084 [Documentation] Get the current system power consumption and check if the
Chris Austenb29d2e82016-06-07 12:25:35 -050085 ... value is greater than zero
George Keishing1a2007e2016-09-15 12:16:11 -050086
Chris Austenb29d2e82016-06-07 12:25:35 -050087 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/system_power
88 should be equal as strings ${resp.status_code} ${HTTP_OK}
89 ${jsondata}= To Json ${resp.content}
90 Should Be True ${jsondata["data"]["value"]} > 0
91
92*** Keywords ***
93
94Get Minimum PowerCap
95 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/min_cap
96 ${jsondata}= To Json ${resp.content}
97 [return] ${jsondata["data"]["value"]}
98
99Get Maximum PowerCap
100 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/max_cap
101 ${jsondata}= To Json ${resp.content}
102 [return] ${jsondata["data"]["value"]}
103
104Get User PowerCap
105 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/user_cap
106 ${jsondata}= To Json ${resp.content}
107 [return] ${jsondata["data"]["value"]}
108
109Set PowerCap
110 [Arguments] ${powercap_value}
111 @{pcap_list} = Create List ${powercap_value}
112 ${data} = create dictionary data=@{pcap_list}
George Keishing1a2007e2016-09-15 12:16:11 -0500113 ${resp} = openbmc post request /org/openbmc/sensors/host/powercap/action/setValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500114 [return] ${resp}
115
116Get PowerCap
George Keishing1a2007e2016-09-15 12:16:11 -0500117 ${resp} = OpenBMC Get Request /org/openbmc/sensors/host/powercap
Chris Austenb29d2e82016-06-07 12:25:35 -0500118 ${jsondata}= To Json ${resp.content}
119 [return] ${jsondata["data"]["value"]}
120
121Get OCC status link
122 ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/list
123 ${jsondata}= To Json ${resp.content}
124 log ${jsondata}
125 : FOR ${ELEMENT} IN @{jsondata["data"]}
126 \ log ${ELEMENT}
127 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *host/cpu*/OccStatus
128 \ Return From Keyword If '${found}' != '' ${found}
129
130Get OCC status
131 ${occstatus_link}= Get OCC status link
132 ${data} = create dictionary data=@{EMPTY}
133 ${resp} = openbmc post request ${occstatus_link}/action/getValue data=${data}
134 ${jsondata}= To Json ${resp.content}
135 [return] ${jsondata["data"]}
136
137Get Chassis URI
138 ${resp}= OpenBMC Get Request /org/openbmc/control/
139 ${jsondata}= To Json ${resp.content}
140 log ${jsondata}
141 : FOR ${ELEMENT} IN @{jsondata["data"]}
142 \ log ${ELEMENT}
143 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis*
144 \ Return From Keyword If '${found}' != '' ${found}
George Keishing1a2007e2016-09-15 12:16:11 -0500145
146
147Check OCC Readiness
148 [Documentation] Poweron If BMC power state is off. Check the OCC powercap
149 ... if the interface attributes are activated.
150
151 ${status}=
152 ... Run Keyword and Return Status Check Power Off States
153 Run Keyword If '${status}' == '${True}'
154 ... BMC Power On
155 Wait Until Keyword Succeeds 5min 10sec
156 ... Powercap Attributes Activated
157
158
159Powercap Attributes Activated
160 [Documentation] Verify if the response contains the pre-define list
161
162 @{precheck}= Create List /org/openbmc/sensors/powercap/user_cap
163 ... /org/openbmc/sensors/powercap/system_power
164 ... /org/openbmc/sensors/powercap/curr_cap
165 ... /org/openbmc/sensors/powercap/max_cap
166 ... /org/openbmc/sensors/powercap/min_cap
167
168 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/
169 ${jsondata}= To Json ${resp.content}
170 List Should Contain Sub List ${jsondata["data"]} ${precheck}
171 ... msg=Failed to activate powercap interface attributes
172