Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 2 | Documentation This suite will verifiy the Generic Configuration Rest Interfaces |
| 3 | ... Details of valid interfaces can be found here... |
| 4 | ... https://github.com/openbmc/docs/blob/master/rest-api.md |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 5 | |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 6 | Resource ../lib/rest_client.robot |
| 7 | Resource ../lib/openbmc_ffdc.robot |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 8 | Test Teardown FFDC On Test Case Fail |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 9 | |
| 10 | |
| 11 | *** Variables *** |
George Keishing | 69019e1 | 2016-10-06 06:29:57 -0500 | [diff] [blame] | 12 | ${MIN_POWER_VALUE} ${0} |
| 13 | ${MAX_POWER_VALUE} ${1000} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 14 | |
George Keishing | ec80737 | 2016-12-05 03:54:51 -0600 | [diff] [blame] | 15 | ${SETTING_HOST} ${SETTINGS_URI}host0 |
| 16 | |
George Keishing | e46afd3 | 2017-01-17 13:01:42 -0600 | [diff] [blame] | 17 | ${RANGE_MSG_ERR} ValueError: Invalid input. Data not in allowed range |
| 18 | ${VALUE_MSG_ERR} ValueError: Invalid input. Data not in allowed values |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 19 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 20 | *** Test Cases *** |
| 21 | |
Sridevi Ramesh | 83f5c59 | 2017-01-20 04:35:13 -0600 | [diff] [blame] | 22 | Get Power Value |
George Keishing | 69019e1 | 2016-10-06 06:29:57 -0500 | [diff] [blame] | 23 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 24 | [Documentation] ***GOOD PATH*** |
George Keishing | 69019e1 | 2016-10-06 06:29:57 -0500 | [diff] [blame] | 25 | ... This test case tries to get the power value and it should be |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 26 | ... between ${MIN_POWER_VALUE} and ${MAX_POWER_VALUE} |
Sridevi Ramesh | 83f5c59 | 2017-01-20 04:35:13 -0600 | [diff] [blame] | 27 | [Tags] Get_Power_Value |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 28 | |
George Keishing | ec80737 | 2016-12-05 03:54:51 -0600 | [diff] [blame] | 29 | ${powerValue}= Read Attribute ${SETTING_HOST} power_cap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 30 | should be true ${powerValue} >= ${MIN_POWER_VALUE} and ${powerValue} <= ${MAX_POWER_VALUE} |
| 31 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 32 | |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 33 | Set Powercap Value With String |
| 34 | [Documentation] Set the power values with string and expect error. |
| 35 | [Tags] Set_Powercap_Value_With_String |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 36 | |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 37 | ${valueToBeSet}= Set Variable abcdefg |
| 38 | ${error_msg}= Run Keyword And Expect Error |
George Keishing | e46afd3 | 2017-01-17 13:01:42 -0600 | [diff] [blame] | 39 | ... * Write To Power Attribute power_cap ${valueToBeSet} |
| 40 | Should Contain ${error_msg} ${RANGE_MSG_ERR} |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 41 | |
George Keishing | ec80737 | 2016-12-05 03:54:51 -0600 | [diff] [blame] | 42 | ${value}= Read Attribute ${SETTING_HOST} power_cap |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 43 | Should Not Be True '${value}'=='${valueToBeSet}' |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 44 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 45 | |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 46 | Set Powercap Value Greater Than Allowed Range |
| 47 | [Documentation] Set the power value greater then MAX_ALLOWED_VALUE |
| 48 | ... and expect error. |
| 49 | [Tags] Set_Powercap_Value_Greater_Than_Allowed_Range |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 50 | |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 51 | ${valueToBeSet}= Set Variable ${1010} |
| 52 | ${error_msg}= Run Keyword And Expect Error |
George Keishing | e46afd3 | 2017-01-17 13:01:42 -0600 | [diff] [blame] | 53 | ... * Write To Power Attribute power_cap ${valueToBeSet} |
| 54 | Should Contain ${error_msg} ${RANGE_MSG_ERR} |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 55 | |
| 56 | ${value}= Read Attribute ${SETTING_HOST} power_cap |
| 57 | Should Not Be Equal ${value} ${valueToBeSet} |
| 58 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 59 | |
Sridevi Ramesh | 83f5c59 | 2017-01-20 04:35:13 -0600 | [diff] [blame] | 60 | Set Power With Min Power Value |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 61 | |
| 62 | [Documentation] ***BAD PATH*** |
Rahul Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 63 | ... This test case sets the power value less then |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 64 | ... MIN_ALLOWED_VALUE,Expectation is it should get error. |
Sridevi Ramesh | 83f5c59 | 2017-01-20 04:35:13 -0600 | [diff] [blame] | 65 | [Tags] Set_Power_With_Min_Power_Value |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 66 | |
| 67 | ${valueToBeSet}= Set Variable ${MIN_POWER_VALUE} |
| 68 | ${valueDict}= create dictionary data=${valueToBeSet} |
George Keishing | ec80737 | 2016-12-05 03:54:51 -0600 | [diff] [blame] | 69 | Write Attribute ${SETTING_HOST} power_cap data=${valueDict} |
| 70 | ${value}= Read Attribute ${SETTING_HOST} power_cap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 71 | Should Be Equal ${value} ${valueToBeSet} |
| 72 | |
Sridevi Ramesh | 83f5c59 | 2017-01-20 04:35:13 -0600 | [diff] [blame] | 73 | Set Power With Max Power Value |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 74 | |
| 75 | [Documentation] ***GOOD PATH*** |
| 76 | ... This test case sets the power value with MAX_POWER_VALUE |
| 77 | ... and it should be set. |
Sridevi Ramesh | 83f5c59 | 2017-01-20 04:35:13 -0600 | [diff] [blame] | 78 | [Tags] Set_Power_With_Max_Power_Value |
Rahul Maheshwari | 08fd617 | 2016-09-21 12:04:43 -0500 | [diff] [blame] | 79 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 80 | ${valueToBeSet}= Set Variable ${MAX_POWER_VALUE} |
| 81 | ${valueDict}= create dictionary data=${valueToBeSet} |
George Keishing | ec80737 | 2016-12-05 03:54:51 -0600 | [diff] [blame] | 82 | Write Attribute ${SETTING_HOST} power_cap data=${valueDict} |
| 83 | ${value}= Read Attribute ${SETTING_HOST} power_cap |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 84 | Should Be Equal ${value} ${valueToBeSet} |
| 85 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 86 | |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 87 | *** Keywords *** |
| 88 | |
George Keishing | e46afd3 | 2017-01-17 13:01:42 -0600 | [diff] [blame] | 89 | Write To Power Attribute |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 90 | [Documentation] Write to Powercap value. |
George Keishing | e46afd3 | 2017-01-17 13:01:42 -0600 | [diff] [blame] | 91 | [Arguments] ${attrib} ${args} |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 92 | ${value}= Create Dictionary data=${args} |
| 93 | ${resp}= OpenBMC Put Request |
George Keishing | e46afd3 | 2017-01-17 13:01:42 -0600 | [diff] [blame] | 94 | ... ${SETTING_HOST}/attr/${attrib} data=${value} |
George Keishing | 9aa0342 | 2017-01-11 10:26:48 -0600 | [diff] [blame] | 95 | ${jsondata}= To JSON ${resp.content} |
| 96 | Should Be Equal ${jsondata['status']} ${HTTP_OK} |
| 97 | ... msg=${jsondata} |
| 98 | |