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