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