| 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 | 
 | 73 |     ${resp}=  Set PowerCap    ${0} | 
 | 74 |     should be equal as strings      ${resp.status_code}     ${HTTP_OK} | 
 | 75 |     Sleep   ${DBUS_POLL_INTERVAL} | 
 | 76 |     ${power_cap}=       Get PowerCap | 
 | 77 |     Should Be Equal     ${power_cap}    ${0} | 
 | 78 |     ${user_power_cap}=  Get User PowerCap | 
 | 79 |     Should Be Equal     ${user_power_cap}    ${0} | 
 | 80 |  | 
 | 81 | Get System Power Consumption | 
| George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 82 |     [Documentation]   Get the current system power consumption and check if the | 
| Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 83 |     ...               value is greater than zero | 
| George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 84 |  | 
| Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 85 |     ${resp} =   OpenBMC Get Request   /org/openbmc/sensors/powercap/system_power | 
 | 86 |     should be equal as strings   ${resp.status_code}   ${HTTP_OK} | 
 | 87 |     ${jsondata}=   To Json    ${resp.content} | 
 | 88 |     Should Be True   ${jsondata["data"]["value"]} > 0 | 
 | 89 |  | 
 | 90 | *** Keywords *** | 
 | 91 |  | 
 | 92 | Get Minimum PowerCap | 
 | 93 |     ${resp} =   OpenBMC Get Request    /org/openbmc/sensors/powercap/min_cap | 
 | 94 |     ${jsondata}=   To Json    ${resp.content} | 
 | 95 |     [return]    ${jsondata["data"]["value"]} | 
 | 96 |  | 
 | 97 | Get Maximum PowerCap | 
 | 98 |     ${resp} =   OpenBMC Get Request    /org/openbmc/sensors/powercap/max_cap | 
 | 99 |     ${jsondata}=   To Json    ${resp.content} | 
 | 100 |     [return]    ${jsondata["data"]["value"]} | 
 | 101 |  | 
 | 102 | Get User PowerCap | 
 | 103 |     ${resp} =   OpenBMC Get Request    /org/openbmc/sensors/powercap/user_cap | 
 | 104 |     ${jsondata}=   To Json    ${resp.content} | 
 | 105 |     [return]    ${jsondata["data"]["value"]} | 
 | 106 |  | 
 | 107 | Set PowerCap | 
 | 108 |     [Arguments]    ${powercap_value} | 
 | 109 |     @{pcap_list} =   Create List     ${powercap_value} | 
 | 110 |     ${data} =   create dictionary   data=@{pcap_list} | 
| George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 111 |     ${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] | 112 |     [return]    ${resp} | 
 | 113 |  | 
 | 114 | Get PowerCap | 
| George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 115 |     ${resp} =   OpenBMC Get Request    /org/openbmc/sensors/host/powercap | 
| Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 116 |     ${jsondata}=   To Json    ${resp.content} | 
 | 117 |     [return]    ${jsondata["data"]["value"]} | 
 | 118 |  | 
 | 119 | Get OCC status link | 
 | 120 |     ${resp}=    OpenBMC Get Request     /org/openbmc/sensors/host/list | 
 | 121 |     ${jsondata}=   To Json    ${resp.content} | 
 | 122 |     log     ${jsondata} | 
 | 123 |     : FOR    ${ELEMENT}    IN    @{jsondata["data"]} | 
 | 124 |     \   log     ${ELEMENT} | 
 | 125 |     \   ${found}=   Get Lines Matching Pattern      ${ELEMENT}      *host/cpu*/OccStatus | 
 | 126 |     \   Return From Keyword If     '${found}' != ''     ${found} | 
 | 127 |  | 
 | 128 | Get OCC status | 
 | 129 |     ${occstatus_link}=  Get OCC status link | 
 | 130 |     ${data} =   create dictionary   data=@{EMPTY} | 
 | 131 |     ${resp} =   openbmc post request    ${occstatus_link}/action/getValue      data=${data} | 
 | 132 |     ${jsondata}=   To Json    ${resp.content} | 
 | 133 |     [return]    ${jsondata["data"]} | 
 | 134 |  | 
 | 135 | Get Chassis URI | 
 | 136 |     ${resp}=    OpenBMC Get Request     /org/openbmc/control/ | 
 | 137 |     ${jsondata}=   To Json    ${resp.content} | 
 | 138 |     log     ${jsondata} | 
 | 139 |     : FOR    ${ELEMENT}    IN    @{jsondata["data"]} | 
 | 140 |     \   log     ${ELEMENT} | 
 | 141 |     \   ${found}=   Get Lines Matching Pattern      ${ELEMENT}      *control/chassis* | 
 | 142 |     \   Return From Keyword If     '${found}' != ''     ${found} | 
| George Keishing | 1a2007e | 2016-09-15 12:16:11 -0500 | [diff] [blame] | 143 |  | 
 | 144 |  | 
 | 145 | Check OCC Readiness | 
 | 146 |     [Documentation]   Poweron If BMC power state is off. Check the OCC powercap | 
 | 147 |     ...               if the interface attributes are activated. | 
 | 148 |  | 
 | 149 |     ${status}= | 
 | 150 |     ...   Run Keyword and Return Status    Check Power Off States | 
 | 151 |     Run Keyword If   '${status}' == '${True}' | 
 | 152 |     ...   BMC Power On | 
 | 153 |     Wait Until Keyword Succeeds   5min  10sec | 
 | 154 |     ...   Powercap Attributes Activated | 
 | 155 |  | 
 | 156 |  | 
 | 157 | Powercap Attributes Activated | 
 | 158 |     [Documentation]   Verify if the response contains the pre-define list | 
 | 159 |  | 
 | 160 |     @{precheck}=   Create List   /org/openbmc/sensors/powercap/user_cap | 
 | 161 |     ...                          /org/openbmc/sensors/powercap/system_power | 
 | 162 |     ...                          /org/openbmc/sensors/powercap/curr_cap | 
 | 163 |     ...                          /org/openbmc/sensors/powercap/max_cap | 
 | 164 |     ...                          /org/openbmc/sensors/powercap/min_cap | 
 | 165 |  | 
 | 166 |     ${resp}=    OpenBMC Get Request   /org/openbmc/sensors/powercap/ | 
 | 167 |     ${jsondata}=   To Json    ${resp.content} | 
 | 168 |     List Should Contain Sub List   ${jsondata["data"]}    ${precheck} | 
 | 169 |     ...     msg=Failed to activate powercap interface attributes | 
 | 170 |  |