blob: 02f1a26bc18bd1724b3ba482c755875ad41c5a1e [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.
25 ${min}= Get Minimum PowerCap
26 log ${min}
27 ${max}= Get Maximum PowerCap
28 log ${max}
29 ${rand_power_cap}= Evaluate random.randint(${min}, ${max}) modules=random
30 log ${rand_power_cap}
31 ${resp}= Set PowerCap ${rand_power_cap}
32 should be equal as strings ${resp.status_code} ${HTTP_OK}
33 Sleep ${DBUS_POLL_INTERVAL}
34 ${power_cap}= Get PowerCap
35 Should Be Equal ${power_cap} ${rand_power_cap}
36 ${user_power_cap}= Get User PowerCap
37 Should Be Equal ${user_power_cap} ${rand_power_cap}
38
39Set Less Than Minimum PowerCAP
40 [Documentation] Test set powercap with less than min powercap value
41 ${org_power_cap}= Get PowerCap
42 ${min}= Get Minimum PowerCap
43 ${sample_invalid_pcap}= Evaluate ${min}-${100}
44 ${resp}= Set PowerCap ${sample_invalid_pcap}
45 Sleep ${DBUS_POLL_INTERVAL}
46 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
47 ${power_cap}= Get PowerCap
48 Should Be Equal ${org_power_cap} ${power_cap}
49
50Set More Than Maximum PowerCAP
51 [Documentation] Test set powercap with more than max powercap value
52 ${org_power_cap}= Get PowerCap
53 ${min}= Get Maximum 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
61Disable PowerCap
62 [Documentation] Test set powercap with 0 and make sure powercap is
63 ... disabled by checking whether the value is set to 0
64 ${resp}= Set PowerCap ${0}
65 should be equal as strings ${resp.status_code} ${HTTP_OK}
66 Sleep ${DBUS_POLL_INTERVAL}
67 ${power_cap}= Get PowerCap
68 Should Be Equal ${power_cap} ${0}
69 ${user_power_cap}= Get User PowerCap
70 Should Be Equal ${user_power_cap} ${0}
71
72Get System Power Consumption
George Keishing1a2007e2016-09-15 12:16:11 -050073 [Documentation] Get the current system power consumption and check if the
Chris Austenb29d2e82016-06-07 12:25:35 -050074 ... value is greater than zero
George Keishing1a2007e2016-09-15 12:16:11 -050075
Chris Austenb29d2e82016-06-07 12:25:35 -050076 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/system_power
77 should be equal as strings ${resp.status_code} ${HTTP_OK}
78 ${jsondata}= To Json ${resp.content}
79 Should Be True ${jsondata["data"]["value"]} > 0
80
81*** Keywords ***
82
83Get Minimum PowerCap
84 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/min_cap
85 ${jsondata}= To Json ${resp.content}
86 [return] ${jsondata["data"]["value"]}
87
88Get Maximum PowerCap
89 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/max_cap
90 ${jsondata}= To Json ${resp.content}
91 [return] ${jsondata["data"]["value"]}
92
93Get User PowerCap
94 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/user_cap
95 ${jsondata}= To Json ${resp.content}
96 [return] ${jsondata["data"]["value"]}
97
98Set PowerCap
99 [Arguments] ${powercap_value}
100 @{pcap_list} = Create List ${powercap_value}
101 ${data} = create dictionary data=@{pcap_list}
George Keishing1a2007e2016-09-15 12:16:11 -0500102 ${resp} = openbmc post request /org/openbmc/sensors/host/powercap/action/setValue data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500103 [return] ${resp}
104
105Get PowerCap
George Keishing1a2007e2016-09-15 12:16:11 -0500106 ${resp} = OpenBMC Get Request /org/openbmc/sensors/host/powercap
Chris Austenb29d2e82016-06-07 12:25:35 -0500107 ${jsondata}= To Json ${resp.content}
108 [return] ${jsondata["data"]["value"]}
109
110Get OCC status link
111 ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/list
112 ${jsondata}= To Json ${resp.content}
113 log ${jsondata}
114 : FOR ${ELEMENT} IN @{jsondata["data"]}
115 \ log ${ELEMENT}
116 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *host/cpu*/OccStatus
117 \ Return From Keyword If '${found}' != '' ${found}
118
119Get OCC status
120 ${occstatus_link}= Get OCC status link
121 ${data} = create dictionary data=@{EMPTY}
122 ${resp} = openbmc post request ${occstatus_link}/action/getValue data=${data}
123 ${jsondata}= To Json ${resp.content}
124 [return] ${jsondata["data"]}
125
126Get Chassis URI
127 ${resp}= OpenBMC Get Request /org/openbmc/control/
128 ${jsondata}= To Json ${resp.content}
129 log ${jsondata}
130 : FOR ${ELEMENT} IN @{jsondata["data"]}
131 \ log ${ELEMENT}
132 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis*
133 \ Return From Keyword If '${found}' != '' ${found}
George Keishing1a2007e2016-09-15 12:16:11 -0500134
135
136Check OCC Readiness
137 [Documentation] Poweron If BMC power state is off. Check the OCC powercap
138 ... if the interface attributes are activated.
139
140 ${status}=
141 ... Run Keyword and Return Status Check Power Off States
142 Run Keyword If '${status}' == '${True}'
143 ... BMC Power On
144 Wait Until Keyword Succeeds 5min 10sec
145 ... Powercap Attributes Activated
146
147
148Powercap Attributes Activated
149 [Documentation] Verify if the response contains the pre-define list
150
151 @{precheck}= Create List /org/openbmc/sensors/powercap/user_cap
152 ... /org/openbmc/sensors/powercap/system_power
153 ... /org/openbmc/sensors/powercap/curr_cap
154 ... /org/openbmc/sensors/powercap/max_cap
155 ... /org/openbmc/sensors/powercap/min_cap
156
157 ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/
158 ${jsondata}= To Json ${resp.content}
159 List Should Contain Sub List ${jsondata["data"]} ${precheck}
160 ... msg=Failed to activate powercap interface attributes
161