blob: 4ccf6d8a45d80a4d8c6ce5eb159949cf99c23c4d [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -06002Documentation This suite is for testing OCC: Power capping setting
Chris Austenb29d2e82016-06-07 12:25:35 -05003
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -06004Resource ../lib/rest_client.robot
5Resource ../lib/resource.txt
6Resource ../lib/utils.robot
7Resource ../lib/openbmc_ffdc.robot
8Resource ../lib/state_manager.robot
Chris Austenb29d2e82016-06-07 12:25:35 -05009
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060010Suite Setup Check OCC Readiness
11Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -050012
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060013Force Tags powercapping
George Keishing9aa0f652016-11-08 03:28:56 -060014
George Keishingab1bd922016-12-05 05:29:59 -060015*** Variables ***
16
Chris Austenb29d2e82016-06-07 12:25:35 -050017*** Test Cases ***
18
19Get OCC status
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060020 [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
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060024 Should Be Equal ${status} Enabled
Chris Austenb29d2e82016-06-07 12:25:35 -050025
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060026Set 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.
30 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
31 [Tags] Set_And_Get_Powercap known_issue
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050032
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060033 ${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}
Chris Austenb29d2e82016-06-07 12:25:35 -050046
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060047Set Less Than Minimum Powercap
48 [Documentation] Test set powercap with less than min powercap value
49 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
50 [Tags] Set_Less_Than_Minimum_Powercap known_issue
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050051
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060052 ${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}
Chris Austenb29d2e82016-06-07 12:25:35 -050060
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060061Set More Than Maximum Powercap
62 [Documentation] Test set powercap with more than max powercap value
63 ... Existing Issue: https://github.com/openbmc/openbmc/issues/552
64 [Tags] Set_More_Than_Maximum_Powercap known_issue
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050065
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060066 ${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}
Chris Austenb29d2e82016-06-07 12:25:35 -050074
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060075Disable Powercap
76 [Documentation] Test set powercap with 0 and make sure powercap is
77 ... disabled by checking whether the value is set to 0
78 [Tags] Disable_Powercap
Rahul Maheshwaribb20f732016-10-24 06:27:14 -050079
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060080 ${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}
Chris Austenb29d2e82016-06-07 12:25:35 -050087
88Get System Power Consumption
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060089 [Documentation] Get the current system power consumption and check if the
90 ... 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
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -060093 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/system_power
94 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
95 ${jsondata}= To JSON ${resp.content}
96 Should Be True ${jsondata["data"]["value"]} > 0
Chris Austenb29d2e82016-06-07 12:25:35 -050097
98*** Keywords ***
99
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600100Get Minimum Powercap
101 ${resp}= OpenBMC Get Request
102 ... ${SENSORS_URI}powercap/min_cap
103 ${jsondata}= To JSON ${resp.content}
104 [Return] ${jsondata["data"]["value"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500105
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600106Get Maximum Powercap
107 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/max_cap
108 ${jsondata}= To JSON ${resp.content}
109 [Return] ${jsondata["data"]["value"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500110
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600111Get User Powercap
112 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/user_cap
113 ${jsondata}= To JSON ${resp.content}
114 [Return] ${jsondata["data"]["value"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500115
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600116Set Powercap
117 [Arguments] ${powercap_value}
118 @{pcap_list}= Create List ${powercap_value}
119 ${data}= Create Dictionary data=@{pcap_list}
120 ${resp}= OpenBMC Post Request
121 ... ${SENSORS_URI}host/powercap/action/setValue data=${data}
122 [Return] ${resp}
Chris Austenb29d2e82016-06-07 12:25:35 -0500123
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600124Get Powercap
125 ${resp}= OpenBMC Get Request
126 ... ${SENSORS_URI}host/powercap
127 ${jsondata}= To JSON ${resp.content}
128 [Return] ${jsondata["data"]["value"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500129
130Get OCC status link
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600131 ${resp}= OpenBMC Get Request
132 ... ${SENSORS_URI}host/list
133 ${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}
Chris Austenb29d2e82016-06-07 12:25:35 -0500139
140Get OCC status
141 ${occstatus_link}= Get OCC status link
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600142 ${data}= Create Dictionary data=@{EMPTY}
143 ${resp}= OpenBMC Post Request
144 ... ${occstatus_link}/action/getValue data=${data}
145 ${jsondata}= To JSON ${resp.content}
146 [Return] ${jsondata["data"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500147
148Get Chassis URI
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600149 ${resp}= OpenBMC Get Request ${OPENBMC_BASE_URI}control/
150 ${jsondata}= To JSON ${resp.content}
151 Log ${jsondata}
152 : FOR ${ELEMENT} IN @{jsondata["data"]}
153 \ Log ${ELEMENT}
154 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis*
155 \ Return From Keyword If '${found}' != '' ${found}
George Keishing1a2007e2016-09-15 12:16:11 -0500156
157
158Check OCC Readiness
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600159 [Documentation] Poweron If BMC power state is off. Check the OCC powercap
160 ... if the interface attributes are activated.
George Keishing1a2007e2016-09-15 12:16:11 -0500161
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600162 ${status}= Run Keyword and Return Status Is Host Off
163 Run Keyword If '${status}' == '${True}' Initiate Host Boot
164 Wait Until Keyword Succeeds 5min 10sec Powercap Attributes Activated
George Keishing1a2007e2016-09-15 12:16:11 -0500165
166
167Powercap Attributes Activated
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600168 [Documentation] Verify if the response contains the pre-define list
George Keishing1a2007e2016-09-15 12:16:11 -0500169
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600170 @{precheck}= Create List ${SENSORS_URI}powercap/user_cap
171 ... ${SENSORS_URI}powercap/system_power
172 ... ${SENSORS_URI}powercap/curr_cap
173 ... ${SENSORS_URI}powercap/max_cap
174 ... ${SENSORS_URI}powercap/min_cap
George Keishing1a2007e2016-09-15 12:16:11 -0500175
Rahul Maheshwari09cff6e2017-02-21 05:31:52 -0600176 ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/
177 ${jsondata}= To JSON ${resp.content}
178 List Should Contain Sub List ${jsondata["data"]} ${precheck}
179 ... msg=Failed to activate powercap interface attributes