blob: 5350715f81b5152b512079dd354cf9e2e57822af [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
Chris Austenb29d2e82016-06-07 12:25:35 -05008
root442f0ef2016-08-04 20:23:05 +00009Suite Setup Initiate Power On
George Keishingd55a4be2016-08-26 03:28:17 -050010Test Teardown Log FFDC
Chris Austenb29d2e82016-06-07 12:25:35 -050011
12*** Test Cases ***
13
14Get OCC status
15 [Documentation] This testcase is to test the OCCstatus for the system
16 ... is Enabled or not
17 ${status}= Get OCC status
18 Should Be Equal ${status} Enabled
19
20Set and Get PowerCap
21 [Documentation] This testcase is to test get/set powercap feature.
22 ... In the testcase we are reading min, max value and then
23 ... try set the random in that range.
24 ${min}= Get Minimum PowerCap
25 log ${min}
26 ${max}= Get Maximum PowerCap
27 log ${max}
28 ${rand_power_cap}= Evaluate random.randint(${min}, ${max}) modules=random
29 log ${rand_power_cap}
30 ${resp}= Set PowerCap ${rand_power_cap}
31 should be equal as strings ${resp.status_code} ${HTTP_OK}
32 Sleep ${DBUS_POLL_INTERVAL}
33 ${power_cap}= Get PowerCap
34 Should Be Equal ${power_cap} ${rand_power_cap}
35 ${user_power_cap}= Get User PowerCap
36 Should Be Equal ${user_power_cap} ${rand_power_cap}
37
38Set Less Than Minimum PowerCAP
39 [Documentation] Test set powercap with less than min powercap value
40 ${org_power_cap}= Get PowerCap
41 ${min}= Get Minimum PowerCap
42 ${sample_invalid_pcap}= Evaluate ${min}-${100}
43 ${resp}= Set PowerCap ${sample_invalid_pcap}
44 Sleep ${DBUS_POLL_INTERVAL}
45 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
46 ${power_cap}= Get PowerCap
47 Should Be Equal ${org_power_cap} ${power_cap}
48
49Set More Than Maximum PowerCAP
50 [Documentation] Test set powercap with more than max powercap value
51 ${org_power_cap}= Get PowerCap
52 ${min}= Get Maximum PowerCap
53 ${sample_invalid_pcap}= Evaluate ${min}+${100}
54 ${resp}= Set PowerCap ${sample_invalid_pcap}
55 Sleep ${DBUS_POLL_INTERVAL}
56 Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
57 ${power_cap}= Get PowerCap
58 Should Be Equal ${org_power_cap} ${power_cap}
59
60Disable PowerCap
61 [Documentation] Test set powercap with 0 and make sure powercap is
62 ... disabled by checking whether the value is set to 0
63 ${resp}= Set PowerCap ${0}
64 should be equal as strings ${resp.status_code} ${HTTP_OK}
65 Sleep ${DBUS_POLL_INTERVAL}
66 ${power_cap}= Get PowerCap
67 Should Be Equal ${power_cap} ${0}
68 ${user_power_cap}= Get User PowerCap
69 Should Be Equal ${user_power_cap} ${0}
70
71Get System Power Consumption
72 [Documentation] Get the current system power consumption and check if the
73 ... value is greater than zero
74
75 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/system_power
76 should be equal as strings ${resp.status_code} ${HTTP_OK}
77 ${jsondata}= To Json ${resp.content}
78 Should Be True ${jsondata["data"]["value"]} > 0
79
80*** Keywords ***
81
82Get Minimum PowerCap
83 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/min_cap
84 ${jsondata}= To Json ${resp.content}
85 [return] ${jsondata["data"]["value"]}
86
87Get Maximum PowerCap
88 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/max_cap
89 ${jsondata}= To Json ${resp.content}
90 [return] ${jsondata["data"]["value"]}
91
92Get User PowerCap
93 ${resp} = OpenBMC Get Request /org/openbmc/sensors/powercap/user_cap
94 ${jsondata}= To Json ${resp.content}
95 [return] ${jsondata["data"]["value"]}
96
97Set PowerCap
98 [Arguments] ${powercap_value}
99 @{pcap_list} = Create List ${powercap_value}
100 ${data} = create dictionary data=@{pcap_list}
101 ${resp} = openbmc post request /org/openbmc/sensors/host/PowerCap/action/setValue data=${data}
102 [return] ${resp}
103
104Get PowerCap
105 ${resp} = OpenBMC Get Request /org/openbmc/sensors/host/PowerCap
106 ${jsondata}= To Json ${resp.content}
107 [return] ${jsondata["data"]["value"]}
108
109Get OCC status link
110 ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/list
111 ${jsondata}= To Json ${resp.content}
112 log ${jsondata}
113 : FOR ${ELEMENT} IN @{jsondata["data"]}
114 \ log ${ELEMENT}
115 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *host/cpu*/OccStatus
116 \ Return From Keyword If '${found}' != '' ${found}
117
118Get OCC status
119 ${occstatus_link}= Get OCC status link
120 ${data} = create dictionary data=@{EMPTY}
121 ${resp} = openbmc post request ${occstatus_link}/action/getValue data=${data}
122 ${jsondata}= To Json ${resp.content}
123 [return] ${jsondata["data"]}
124
125Get Chassis URI
126 ${resp}= OpenBMC Get Request /org/openbmc/control/
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} *control/chassis*
132 \ Return From Keyword If '${found}' != '' ${found}