blob: 8a6a5c0cc0e92d976789e944247a1cf307b33acb [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
George Keishingd55a4be2016-08-26 03:28:17 -05002Documentation 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 Austenb29d2e82016-06-07 12:25:35 -05005
George Keishingd55a4be2016-08-26 03:28:17 -05006Resource ../lib/rest_client.robot
7Resource ../lib/openbmc_ffdc.robot
Gunnar Millseac1af22016-11-14 15:30:09 -06008Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -05009
10
11*** Variables ***
George Keishing69019e12016-10-06 06:29:57 -050012${MIN_POWER_VALUE} ${0}
13${MAX_POWER_VALUE} ${1000}
Chris Austenb29d2e82016-06-07 12:25:35 -050014
George Keishingec807372016-12-05 03:54:51 -060015${SETTING_HOST} ${SETTINGS_URI}host0
16
George Keishinge46afd32017-01-17 13:01:42 -060017${RANGE_MSG_ERR} ValueError: Invalid input. Data not in allowed range
18${VALUE_MSG_ERR} ValueError: Invalid input. Data not in allowed values
George Keishing9aa03422017-01-11 10:26:48 -060019
Chris Austenb29d2e82016-06-07 12:25:35 -050020*** Test Cases ***
21
22
23Get the boot_flags
24
25 [Documentation] ***GOOD PATH***
26 ... This test case tries to get the boot flags
George Keishing69019e12016-10-06 06:29:57 -050027 ...
Chris Austenb29d2e82016-06-07 12:25:35 -050028
George Keishingec807372016-12-05 03:54:51 -060029 ${resp}= Read Attribute ${SETTING_HOST} boot_flags
Chris Austenb29d2e82016-06-07 12:25:35 -050030 should not be empty ${resp}
31
32Get the power
George Keishing69019e12016-10-06 06:29:57 -050033
Chris Austenb29d2e82016-06-07 12:25:35 -050034 [Documentation] ***GOOD PATH***
George Keishing69019e12016-10-06 06:29:57 -050035 ... This test case tries to get the power value and it should be
Chris Austenb29d2e82016-06-07 12:25:35 -050036 ... between ${MIN_POWER_VALUE} and ${MAX_POWER_VALUE}
37
George Keishingec807372016-12-05 03:54:51 -060038 ${powerValue}= Read Attribute ${SETTING_HOST} power_cap
Chris Austenb29d2e82016-06-07 12:25:35 -050039 should be true ${powerValue} >= ${MIN_POWER_VALUE} and ${powerValue} <= ${MAX_POWER_VALUE}
40
Chris Austenb29d2e82016-06-07 12:25:35 -050041
George Keishing9aa03422017-01-11 10:26:48 -060042Set Powercap Value With String
43 [Documentation] Set the power values with string and expect error.
44 [Tags] Set_Powercap_Value_With_String
Chris Austenb29d2e82016-06-07 12:25:35 -050045
George Keishing9aa03422017-01-11 10:26:48 -060046 ${valueToBeSet}= Set Variable abcdefg
47 ${error_msg}= Run Keyword And Expect Error
George Keishinge46afd32017-01-17 13:01:42 -060048 ... * Write To Power Attribute power_cap ${valueToBeSet}
49 Should Contain ${error_msg} ${RANGE_MSG_ERR}
George Keishing9aa03422017-01-11 10:26:48 -060050
George Keishingec807372016-12-05 03:54:51 -060051 ${value}= Read Attribute ${SETTING_HOST} power_cap
George Keishing9aa03422017-01-11 10:26:48 -060052 Should Not Be True '${value}'=='${valueToBeSet}'
Chris Austenb29d2e82016-06-07 12:25:35 -050053
Chris Austenb29d2e82016-06-07 12:25:35 -050054
George Keishing9aa03422017-01-11 10:26:48 -060055Set Powercap Value Greater Than Allowed Range
56 [Documentation] Set the power value greater then MAX_ALLOWED_VALUE
57 ... and expect error.
58 [Tags] Set_Powercap_Value_Greater_Than_Allowed_Range
Chris Austenb29d2e82016-06-07 12:25:35 -050059
George Keishing9aa03422017-01-11 10:26:48 -060060 ${valueToBeSet}= Set Variable ${1010}
61 ${error_msg}= Run Keyword And Expect Error
George Keishinge46afd32017-01-17 13:01:42 -060062 ... * Write To Power Attribute power_cap ${valueToBeSet}
63 Should Contain ${error_msg} ${RANGE_MSG_ERR}
George Keishing9aa03422017-01-11 10:26:48 -060064
65 ${value}= Read Attribute ${SETTING_HOST} power_cap
66 Should Not Be Equal ${value} ${valueToBeSet}
67
Chris Austenb29d2e82016-06-07 12:25:35 -050068
69Set the power with MIN_POWER_VALUE
70
71 [Documentation] ***BAD PATH***
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050072 ... This test case sets the power value less then
Chris Austenb29d2e82016-06-07 12:25:35 -050073 ... MIN_ALLOWED_VALUE,Expectation is it should get error.
74
75 ${valueToBeSet}= Set Variable ${MIN_POWER_VALUE}
76 ${valueDict}= create dictionary data=${valueToBeSet}
George Keishingec807372016-12-05 03:54:51 -060077 Write Attribute ${SETTING_HOST} power_cap data=${valueDict}
78 ${value}= Read Attribute ${SETTING_HOST} power_cap
Chris Austenb29d2e82016-06-07 12:25:35 -050079 Should Be Equal ${value} ${valueToBeSet}
80
81Set the power with MAX_POWER_VALUE
82
83 [Documentation] ***GOOD PATH***
84 ... This test case sets the power value with MAX_POWER_VALUE
85 ... and it should be set.
Rahul Maheshwari08fd6172016-09-21 12:04:43 -050086
Chris Austenb29d2e82016-06-07 12:25:35 -050087 ${valueToBeSet}= Set Variable ${MAX_POWER_VALUE}
88 ${valueDict}= create dictionary data=${valueToBeSet}
George Keishingec807372016-12-05 03:54:51 -060089 Write Attribute ${SETTING_HOST} power_cap data=${valueDict}
90 ${value}= Read Attribute ${SETTING_HOST} power_cap
Chris Austenb29d2e82016-06-07 12:25:35 -050091 Should Be Equal ${value} ${valueToBeSet}
92
Chris Austenb29d2e82016-06-07 12:25:35 -050093
George Keishinge46afd32017-01-17 13:01:42 -060094Set Boot Flag With String
95 [Documentation] Set boot flag with invalid string and expect error.
96 [Tags] Set_Boot_Flag_With_String
Chris Austenb29d2e82016-06-07 12:25:35 -050097
98 ${valueToBeSet}= Set Variable 3ab56f
George Keishinge46afd32017-01-17 13:01:42 -060099 ${error_msg}= Run Keyword And Expect Error
100 ... * Write To Power Attribute boot_flags ${valueToBeSet}
101 Should Contain ${error_msg} ${VALUE_MSG_ERR}
102 ${value}= Read Attribute ${SETTING_HOST} boot_flags
103 Should Not Be Equal ${value} ${valueToBeSet}
Chris Austenb29d2e82016-06-07 12:25:35 -0500104
George Keishing9aa03422017-01-11 10:26:48 -0600105
106*** Keywords ***
107
George Keishinge46afd32017-01-17 13:01:42 -0600108Write To Power Attribute
George Keishing9aa03422017-01-11 10:26:48 -0600109 [Documentation] Write to Powercap value.
George Keishinge46afd32017-01-17 13:01:42 -0600110 [Arguments] ${attrib} ${args}
George Keishing9aa03422017-01-11 10:26:48 -0600111 ${value}= Create Dictionary data=${args}
112 ${resp}= OpenBMC Put Request
George Keishinge46afd32017-01-17 13:01:42 -0600113 ... ${SETTING_HOST}/attr/${attrib} data=${value}
George Keishing9aa03422017-01-11 10:26:48 -0600114 ${jsondata}= To JSON ${resp.content}
115 Should Be Equal ${jsondata['status']} ${HTTP_OK}
116 ... msg=${jsondata}
117