Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 2 | Documentation This suite is for testing OCC: Power capping setting |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 3 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 4 | Resource ../lib/rest_client.robot |
| 5 | Resource ../lib/resource.txt |
| 6 | Resource ../lib/utils.robot |
| 7 | Resource ../lib/openbmc_ffdc.robot |
| 8 | Resource ../lib/state_manager.robot |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 9 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 10 | Suite Setup Check OCC Readiness |
| 11 | Test Teardown FFDC On Test Case Fail |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 13 | Force Tags powercapping |
George Keishing | 9aa0f65 | 2016-11-08 03:28:56 -0600 | [diff] [blame] | 14 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 15 | *** Variables *** |
| 16 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 17 | *** Test Cases *** |
| 18 | |
| 19 | Get OCC status |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 20 | [Documentation] This testcase is to test the OCCstatus for the system |
| 21 | ... is Enabled or not |
George Keishing | 9aa0f65 | 2016-11-08 03:28:56 -0600 | [diff] [blame] | 22 | [Tags] Get_OCC_status |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 23 | ${status}= Get OCC status |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 24 | Should Be Equal ${status} Enabled |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 25 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 26 | Set 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 Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 32 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 33 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 46 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 47 | Set 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 Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 51 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 52 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 60 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 61 | Set 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 Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 65 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 66 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 74 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 75 | Disable 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 Maheshwari | bb20f73 | 2016-10-24 06:27:14 -0500 | [diff] [blame] | 79 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 80 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 87 | |
| 88 | Get System Power Consumption |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 89 | [Documentation] Get the current system power consumption and check if the |
| 90 | ... value is greater than zero |
George Keishing | 9aa0f65 | 2016-11-08 03:28:56 -0600 | [diff] [blame] | 91 | [Tags] Get_System_Power_Consumption |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 92 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 93 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 97 | |
| 98 | *** Keywords *** |
| 99 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 100 | Get 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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 105 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 106 | Get Maximum Powercap |
| 107 | ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/max_cap |
| 108 | ${jsondata}= To JSON ${resp.content} |
| 109 | [Return] ${jsondata["data"]["value"]} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 110 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 111 | Get User Powercap |
| 112 | ${resp}= OpenBMC Get Request ${SENSORS_URI}powercap/user_cap |
| 113 | ${jsondata}= To JSON ${resp.content} |
| 114 | [Return] ${jsondata["data"]["value"]} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 115 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 116 | Set 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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 123 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 124 | Get Powercap |
| 125 | ${resp}= OpenBMC Get Request |
| 126 | ... ${SENSORS_URI}host/powercap |
| 127 | ${jsondata}= To JSON ${resp.content} |
| 128 | [Return] ${jsondata["data"]["value"]} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 129 | |
| 130 | Get OCC status link |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 131 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 139 | |
| 140 | Get OCC status |
| 141 | ${occstatus_link}= Get OCC status link |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 142 | ${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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 147 | |
| 148 | Get Chassis URI |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 149 | ${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 Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 156 | |
| 157 | |
| 158 | Check OCC Readiness |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 159 | [Documentation] Poweron If BMC power state is off. Check the OCC powercap |
| 160 | ... if the interface attributes are activated. |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 161 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 162 | ${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 Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 165 | |
| 166 | |
| 167 | Powercap Attributes Activated |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 168 | [Documentation] Verify if the response contains the pre-define list |
George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 169 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 170 | @{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 Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 175 | |
Rahul Maheshwari | 09cff6e | 2017-02-21 05:31:52 -0600 | [diff] [blame] | 176 | ${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 |