Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite is for testing OCC: Power capping setting |
| 3 | |
| 4 | Resource ../lib/rest_client.robot |
| 5 | Resource ../lib/resource.txt |
| 6 | Resource ../lib/utils.robot |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 7 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 8 | Resource ../lib/boot/boot_resource_master.robot |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 9 | |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 10 | Suite Setup Check OCC Readiness |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 11 | Test Teardown FFDC On Test Case Fail |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | |
George Keishing | 9aa0f65 | 2016-11-08 03:28:56 -0600 | [diff] [blame] | 13 | Force Tags powercapping |
| 14 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 15 | *** Test Cases *** |
| 16 | |
| 17 | Get OCC status |
| 18 | [Documentation] This testcase is to test the OCCstatus for the system |
| 19 | ... is Enabled or not |
George Keishing | 9aa0f65 | 2016-11-08 03:28:56 -0600 | [diff] [blame] | 20 | [Tags] Get_OCC_status |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 21 | ${status}= Get OCC status |
| 22 | Should Be Equal ${status} Enabled |
| 23 | |
| 24 | Set and Get PowerCap |
| 25 | [Documentation] This testcase is to test get/set powercap feature. |
| 26 | ... In the testcase we are reading min, max value and then |
| 27 | ... try set the random in that range. |
Rahul Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 28 | ... Existing Issue: https://github.com/openbmc/openbmc/issues/552 |
| 29 | [Tags] known_issue |
| 30 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 31 | ${min}= Get Minimum PowerCap |
| 32 | log ${min} |
| 33 | ${max}= Get Maximum PowerCap |
| 34 | log ${max} |
| 35 | ${rand_power_cap}= Evaluate random.randint(${min}, ${max}) modules=random |
| 36 | log ${rand_power_cap} |
| 37 | ${resp}= Set PowerCap ${rand_power_cap} |
| 38 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 39 | Sleep ${DBUS_POLL_INTERVAL} |
| 40 | ${power_cap}= Get PowerCap |
| 41 | Should Be Equal ${power_cap} ${rand_power_cap} |
| 42 | ${user_power_cap}= Get User PowerCap |
| 43 | Should Be Equal ${user_power_cap} ${rand_power_cap} |
| 44 | |
| 45 | Set Less Than Minimum PowerCAP |
| 46 | [Documentation] Test set powercap with less than min powercap value |
Rahul Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 47 | ... Existing Issue: https://github.com/openbmc/openbmc/issues/552 |
| 48 | [Tags] known_issue |
| 49 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 50 | ${org_power_cap}= Get PowerCap |
| 51 | ${min}= Get Minimum PowerCap |
| 52 | ${sample_invalid_pcap}= Evaluate ${min}-${100} |
| 53 | ${resp}= Set PowerCap ${sample_invalid_pcap} |
| 54 | Sleep ${DBUS_POLL_INTERVAL} |
| 55 | Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 56 | ${power_cap}= Get PowerCap |
| 57 | Should Be Equal ${org_power_cap} ${power_cap} |
| 58 | |
| 59 | Set More Than Maximum PowerCAP |
| 60 | [Documentation] Test set powercap with more than max powercap value |
Rahul Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 61 | ... Existing Issue: https://github.com/openbmc/openbmc/issues/552 |
| 62 | [Tags] known_issue |
| 63 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 64 | ${org_power_cap}= Get PowerCap |
| 65 | ${min}= Get Maximum PowerCap |
| 66 | ${sample_invalid_pcap}= Evaluate ${min}+${100} |
| 67 | ${resp}= Set PowerCap ${sample_invalid_pcap} |
| 68 | Sleep ${DBUS_POLL_INTERVAL} |
| 69 | Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 70 | ${power_cap}= Get PowerCap |
| 71 | Should Be Equal ${org_power_cap} ${power_cap} |
| 72 | |
| 73 | Disable PowerCap |
| 74 | [Documentation] Test set powercap with 0 and make sure powercap is |
| 75 | ... disabled by checking whether the value is set to 0 |
Rahul Maheshwari | bb20f73 | 2016-10-24 06:27:14 -0500 | [diff] [blame] | 76 | [Tags] Disable_PowerCap |
| 77 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 78 | ${resp}= Set PowerCap ${0} |
| 79 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 80 | Sleep ${DBUS_POLL_INTERVAL} |
| 81 | ${power_cap}= Get PowerCap |
| 82 | Should Be Equal ${power_cap} ${0} |
| 83 | ${user_power_cap}= Get User PowerCap |
| 84 | Should Be Equal ${user_power_cap} ${0} |
| 85 | |
| 86 | Get System Power Consumption |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 87 | [Documentation] Get the current system power consumption and check if the |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 88 | ... value is greater than zero |
George Keishing | 9aa0f65 | 2016-11-08 03:28:56 -0600 | [diff] [blame] | 89 | [Tags] Get_System_Power_Consumption |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 90 | |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 91 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/system_power |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 92 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 93 | ${jsondata}= To Json ${resp.content} |
| 94 | Should Be True ${jsondata["data"]["value"]} > 0 |
| 95 | |
| 96 | *** Keywords *** |
| 97 | |
| 98 | Get Minimum PowerCap |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 99 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/min_cap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 100 | ${jsondata}= To Json ${resp.content} |
| 101 | [return] ${jsondata["data"]["value"]} |
| 102 | |
| 103 | Get Maximum PowerCap |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 104 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/max_cap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 105 | ${jsondata}= To Json ${resp.content} |
| 106 | [return] ${jsondata["data"]["value"]} |
| 107 | |
| 108 | Get User PowerCap |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 109 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/user_cap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 110 | ${jsondata}= To Json ${resp.content} |
| 111 | [return] ${jsondata["data"]["value"]} |
| 112 | |
| 113 | Set PowerCap |
| 114 | [Arguments] ${powercap_value} |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 115 | @{pcap_list}= Create List ${powercap_value} |
| 116 | ${data}= create dictionary data=@{pcap_list} |
| 117 | ${resp}= openbmc post request /org/openbmc/sensors/host/powercap/action/setValue data=${data} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 118 | [return] ${resp} |
| 119 | |
| 120 | Get PowerCap |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 121 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/powercap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 122 | ${jsondata}= To Json ${resp.content} |
| 123 | [return] ${jsondata["data"]["value"]} |
| 124 | |
| 125 | Get OCC status link |
| 126 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/host/list |
| 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} *host/cpu*/OccStatus |
| 132 | \ Return From Keyword If '${found}' != '' ${found} |
| 133 | |
| 134 | Get OCC status |
| 135 | ${occstatus_link}= Get OCC status link |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 136 | ${data}= create dictionary data=@{EMPTY} |
| 137 | ${resp}= openbmc post request ${occstatus_link}/action/getValue data=${data} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 138 | ${jsondata}= To Json ${resp.content} |
| 139 | [return] ${jsondata["data"]} |
| 140 | |
| 141 | Get Chassis URI |
| 142 | ${resp}= OpenBMC Get Request /org/openbmc/control/ |
| 143 | ${jsondata}= To Json ${resp.content} |
| 144 | log ${jsondata} |
| 145 | : FOR ${ELEMENT} IN @{jsondata["data"]} |
| 146 | \ log ${ELEMENT} |
| 147 | \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/chassis* |
| 148 | \ Return From Keyword If '${found}' != '' ${found} |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 149 | |
| 150 | |
| 151 | Check OCC Readiness |
| 152 | [Documentation] Poweron If BMC power state is off. Check the OCC powercap |
| 153 | ... if the interface attributes are activated. |
| 154 | |
| 155 | ${status}= |
| 156 | ... Run Keyword and Return Status Check Power Off States |
| 157 | Run Keyword If '${status}' == '${True}' |
| 158 | ... BMC Power On |
| 159 | Wait Until Keyword Succeeds 5min 10sec |
| 160 | ... Powercap Attributes Activated |
| 161 | |
| 162 | |
| 163 | Powercap Attributes Activated |
| 164 | [Documentation] Verify if the response contains the pre-define list |
| 165 | |
| 166 | @{precheck}= Create List /org/openbmc/sensors/powercap/user_cap |
| 167 | ... /org/openbmc/sensors/powercap/system_power |
| 168 | ... /org/openbmc/sensors/powercap/curr_cap |
| 169 | ... /org/openbmc/sensors/powercap/max_cap |
| 170 | ... /org/openbmc/sensors/powercap/min_cap |
| 171 | |
| 172 | ${resp}= OpenBMC Get Request /org/openbmc/sensors/powercap/ |
| 173 | ${jsondata}= To Json ${resp.content} |
| 174 | List Should Contain Sub List ${jsondata["data"]} ${precheck} |
| 175 | ... msg=Failed to activate powercap interface attributes |
| 176 | |