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 |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 8 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 9 | Suite Setup Initiate Power On |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 10 | Test Teardown Log FFDC |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 11 | |
| 12 | *** Test Cases *** |
| 13 | |
| 14 | Get 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 | |
| 20 | Set 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 | |
| 38 | Set 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 | |
| 49 | Set 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 | |
| 60 | Disable 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 | |
| 71 | Get 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 | |
| 82 | Get 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 | |
| 87 | Get 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 | |
| 92 | Get 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 | |
| 97 | Set 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 | |
| 104 | Get PowerCap |
| 105 | ${resp} = OpenBMC Get Request /org/openbmc/sensors/host/PowerCap |
| 106 | ${jsondata}= To Json ${resp.content} |
| 107 | [return] ${jsondata["data"]["value"]} |
| 108 | |
| 109 | Get 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 | |
| 118 | Get 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 | |
| 125 | Get 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} |